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;
54 static void __global(void *data, struct wl_registry *registry,
55 uint32_t name, const char *interface, uint32_t version)
57 struct tizen_surface **tz_surface = NULL;
64 tz_surface = (struct tizen_surface **)data;
67 LOGW("NULL interface");
71 /*LOGI("interface %s", interface);*/
73 if (strcmp(interface, "tizen_surface") == 0) {
74 LOGD("binding tizen surface for wayland");
76 *tz_surface = wl_registry_bind(registry, name, &tizen_surface_interface, version);
77 if (*tz_surface == NULL)
78 LOGE("failed to bind");
86 static void __global_remove(void *data, struct wl_registry *wl_registry, uint32_t name)
92 static const struct wl_registry_listener _camera_wl_registry_listener = {
97 void __parent_id_getter(void *data, struct tizen_resource *tizen_resource, uint32_t id)
104 *((unsigned int *)data) = id;
106 LOGD("[CLIENT] got parent_id [%u] from server", id);
111 static const struct tizen_resource_listener _camera_tz_resource_listener = {
115 int _camera_get_wl_info(Evas_Object *obj, camera_wl_info_s *wl_info)
117 int ret = CAMERA_ERROR_NONE;
118 Ecore_Wl_Window *window = NULL;
119 struct wl_display *display = NULL;
120 struct wl_display *display_wrapper = NULL;
121 struct wl_surface *surface = NULL;
122 struct wl_registry *registry = NULL;
123 struct wl_event_queue *queue = NULL;
124 struct tizen_surface *tz_surface = NULL;
125 struct tizen_resource *tz_resource = NULL;
127 if (!obj || !wl_info) {
128 LOGE("NULL parameter %p %p", obj, wl_info);
129 return CAMERA_ERROR_INVALID_OPERATION;
132 window = elm_win_wl_window_get(obj);
134 LOGE("failed to get wayland window");
135 ret = CAMERA_ERROR_INVALID_OPERATION;
139 surface = (struct wl_surface *)ecore_wl_window_surface_get(window);
141 LOGE("failed to get wayland surface");
142 ret = CAMERA_ERROR_INVALID_OPERATION;
146 display = (struct wl_display *)ecore_wl_display_get();
148 LOGE("failed to get wayland display");
149 ret = CAMERA_ERROR_INVALID_OPERATION;
153 display_wrapper = wl_proxy_create_wrapper(display);
154 if (!display_wrapper) {
155 LOGE("failed to create wl display wrapper");
156 ret = CAMERA_ERROR_INVALID_OPERATION;
160 queue = wl_display_create_queue(display);
162 LOGE("failed to create wl display queue");
163 ret = CAMERA_ERROR_INVALID_OPERATION;
167 wl_proxy_set_queue((struct wl_proxy *)display_wrapper, queue);
169 registry = wl_display_get_registry(display_wrapper);
171 LOGE("failed to get wayland registry");
172 ret = CAMERA_ERROR_INVALID_OPERATION;
176 wl_registry_add_listener(registry, &_camera_wl_registry_listener, &tz_surface);
178 wl_display_dispatch_queue(display, queue);
179 wl_display_roundtrip_queue(display, queue);
182 LOGE("failed to get tizen surface");
183 ret = CAMERA_ERROR_INVALID_OPERATION;
187 /* Get parent_id which is unique in a entire systemw. */
188 tz_resource = tizen_surface_get_tizen_resource(tz_surface, surface);
190 LOGE("failed to get tizen resurce");
191 ret = CAMERA_ERROR_INVALID_OPERATION;
195 wl_info->parent_id = 0;
197 tizen_resource_add_listener(tz_resource, &_camera_tz_resource_listener, &wl_info->parent_id);
199 wl_display_roundtrip_queue(display, queue);
201 if (wl_info->parent_id > 0) {
203 Ecore_Evas *ecore_evas = NULL;
204 ret = CAMERA_ERROR_NONE;
206 wl_info->evas_obj = obj;
208 evas_object_geometry_get(obj, &wl_info->window_x, &wl_info->window_y,
209 &wl_info->window_width, &wl_info->window_height);
211 ecore_evas = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
213 rotation = ecore_evas_rotation_get(ecore_evas);
214 if (rotation == 90 || rotation == 270) {
215 int temp = wl_info->window_width;
217 LOGD("swap width and height %d, %d", wl_info->window_width, wl_info->window_height);
219 wl_info->window_width = wl_info->window_height;
220 wl_info->window_height = temp;
223 LOGW("failed to get ecore_evas.. skip rotation check");
226 LOGD("evas object : %p, rotation : %d, parent id : %u, window : %d,%d,%dx%d",
227 wl_info->evas_obj, rotation, wl_info->parent_id,
228 wl_info->window_x, wl_info->window_y,
229 wl_info->window_width, wl_info->window_height);
231 ret = CAMERA_ERROR_INVALID_OPERATION;
232 LOGE("failed to get parent id");
237 tizen_surface_destroy(tz_surface);
242 tizen_resource_destroy(tz_resource);
247 wl_registry_destroy(registry);
252 wl_event_queue_destroy(queue);
256 if (display_wrapper) {
257 wl_proxy_wrapper_destroy(display_wrapper);
258 display_wrapper = NULL;
265 static void __camera_device_state_changed_cb(GDBusConnection *connection,
266 const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
267 const gchar *signal_name, GVariant *param, gpointer user_data)
270 camera_device_e device = CAMERA_DEVICE_CAMERA0;
271 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
272 GList *tmp_list = NULL;
273 camera_cb_info *info = NULL;
275 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
277 if (!g_cam_dev_state_changed_cb_list || !param) {
278 LOGW("no callback or NULL param %p", param);
282 /* get device and state */
283 g_variant_get(param, "(i)", &value);
285 device = value >> 16;
286 state = 0x0000ffff & value;
288 LOGD("device %d, state %d", device, state);
290 tmp_list = g_cam_dev_state_changed_cb_list;
293 info = (camera_cb_info *)tmp_list->data;
296 if (info->callback) {
297 LOGD("start id[%d] callback", info->id);
298 ((camera_device_state_changed_cb)info->callback)(device, state, info->user_data);
299 LOGD("returned id[%d] callback", info->id);
301 LOGW("NULL callback for id %d", info->id);
305 tmp_list = tmp_list->next;
309 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
315 static int _camera_import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle)
317 tbm_bo tmp_bo = NULL;
318 tbm_bo_handle tmp_bo_handle = {NULL, };
320 if (!bufmgr || !bo || !bo_handle || !tbm_key) {
321 LOGE("invalid parameter - %p %p %p, key %d",
322 bufmgr, bo, bo_handle, tbm_key);
326 tmp_bo = tbm_bo_import(bufmgr, tbm_key);
327 if (tmp_bo == NULL) {
328 LOGE("import failed - key %d", tbm_key);
332 tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
333 if (tmp_bo_handle.ptr == NULL) {
334 LOGE("map failed %p", tmp_bo);
335 tbm_bo_unref(tmp_bo);
340 tbm_bo_unmap(tmp_bo);
342 /* set bo and bo_handle */
344 *bo_handle = tmp_bo_handle;
349 static void _camera_release_imported_bo(tbm_bo *bo)
362 static int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
364 int ret = CAMERA_ERROR_NONE;
367 /*LOGD("Enter api : %d", api);*/
369 if (!cb_info->is_server_connected) {
370 LOGE("server is disconnected");
371 return CAMERA_ERROR_SERVICE_DISCONNECTED;
374 g_mutex_lock(&(cb_info->api_mutex[api]));
376 if (cb_info->api_activating[api] == 0) {
377 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
378 if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
379 ret = cb_info->api_ret[api];
380 cb_info->api_activating[api] = 0;
382 /*LOGD("return value : 0x%x", ret);*/
384 ret = CAMERA_ERROR_INVALID_OPERATION;
385 LOGE("api %d was TIMED OUT!", api);
388 ret = cb_info->api_ret[api];
389 cb_info->api_activating[api] = 0;
391 /*LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);*/
394 g_mutex_unlock(&(cb_info->api_mutex[api]));
396 if (ret != CAMERA_ERROR_NONE) {
397 LOGE("api %d : error 0x%x", api, ret);
399 if (ret == CAMERA_ERROR_SOUND_POLICY)
400 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
401 else if (ret == CAMERA_ERROR_SOUND_POLICY_BY_CALL)
402 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
403 else if (ret == CAMERA_ERROR_SOUND_POLICY_BY_ALARM)
404 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
411 static void _camera_msg_send(int api, camera_cb_info_s *cb_info,
412 int *ret, int timeout)
418 LOGE("NULL info - api %d", api);
421 *ret = CAMERA_ERROR_INVALID_PARAMETER;
426 msg = muse_core_msg_json_factory_new(api, NULL);
428 LOGE("msg failed: api %d", api);
431 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
436 /*LOGD("send msg %s", msg);*/
438 if (cb_info->is_server_connected) {
439 g_mutex_lock(&cb_info->fd_lock);
440 send_ret = muse_core_ipc_send_msg(cb_info->fd, msg);
441 g_mutex_unlock(&cb_info->fd_lock);
445 LOGE("msg send failed");
447 *ret = CAMERA_ERROR_INVALID_OPERATION;
450 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
453 muse_core_msg_json_factory_free(msg);
459 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
460 int *ret, camera_msg_param *param, int timeout)
465 if (!cb_info || !param) {
466 LOGE("invalid pointer : api %d - %p %p", api, cb_info, param);
469 *ret = CAMERA_ERROR_INVALID_PARAMETER;
474 /*LOGD("type %d, name %s", param->type, param->name);*/
476 switch (param->type) {
478 msg = muse_core_msg_json_factory_new(api,
479 param->type, param->name, param->value.value_INT,
482 case MUSE_TYPE_STRING:
483 msg = muse_core_msg_json_factory_new(api,
484 param->type, param->name, param->value.value_STRING,
488 LOGE("unknown type %d", param->type);
493 LOGE("msg failed: api %d", api);
496 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
501 /*LOGD("send msg %s", msg);*/
503 if (cb_info->is_server_connected) {
504 g_mutex_lock(&cb_info->fd_lock);
505 send_ret = muse_core_ipc_send_msg(cb_info->fd, msg);
506 g_mutex_unlock(&cb_info->fd_lock);
510 LOGE("msg send failed");
513 *ret = CAMERA_ERROR_INVALID_OPERATION;
516 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
519 muse_core_msg_json_factory_free(msg);
525 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
527 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
528 in_format >= MM_PIXEL_FORMAT_NUM ||
529 out_format == NULL) {
530 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
531 return CAMERA_ERROR_INVALID_PARAMETER;
535 case MM_PIXEL_FORMAT_NV12:
536 case MM_PIXEL_FORMAT_NV12T:
537 *out_format = TBM_FORMAT_NV12;
539 case MM_PIXEL_FORMAT_NV16:
540 *out_format = TBM_FORMAT_NV16;
542 case MM_PIXEL_FORMAT_NV21:
543 *out_format = TBM_FORMAT_NV21;
545 case MM_PIXEL_FORMAT_YUYV:
546 *out_format = TBM_FORMAT_YUYV;
548 case MM_PIXEL_FORMAT_UYVY:
549 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
550 *out_format = TBM_FORMAT_UYVY;
552 case MM_PIXEL_FORMAT_422P:
553 *out_format = TBM_FORMAT_YUV422;
555 case MM_PIXEL_FORMAT_I420:
556 *out_format = TBM_FORMAT_YUV420;
558 case MM_PIXEL_FORMAT_YV12:
559 *out_format = TBM_FORMAT_YVU420;
561 case MM_PIXEL_FORMAT_RGB565:
562 *out_format = TBM_FORMAT_RGB565;
564 case MM_PIXEL_FORMAT_RGB888:
565 *out_format = TBM_FORMAT_RGB888;
567 case MM_PIXEL_FORMAT_RGBA:
568 *out_format = TBM_FORMAT_RGBA8888;
570 case MM_PIXEL_FORMAT_ARGB:
571 *out_format = TBM_FORMAT_ARGB8888;
574 LOGE("invalid in_format %d", in_format);
575 return CAMERA_ERROR_INVALID_PARAMETER;
578 return CAMERA_ERROR_NONE;
582 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
584 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
585 in_format >= MM_PIXEL_FORMAT_NUM ||
587 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
588 return CAMERA_ERROR_INVALID_PARAMETER;
592 case MM_PIXEL_FORMAT_NV12:
593 case MM_PIXEL_FORMAT_NV12T:
594 *mimetype = MEDIA_FORMAT_NV12;
596 case MM_PIXEL_FORMAT_NV16:
597 *mimetype = MEDIA_FORMAT_NV16;
599 case MM_PIXEL_FORMAT_NV21:
600 *mimetype = MEDIA_FORMAT_NV21;
602 case MM_PIXEL_FORMAT_YUYV:
603 *mimetype = MEDIA_FORMAT_YUYV;
605 case MM_PIXEL_FORMAT_UYVY:
606 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
607 *mimetype = MEDIA_FORMAT_UYVY;
609 case MM_PIXEL_FORMAT_422P:
610 *mimetype = MEDIA_FORMAT_422P;
612 case MM_PIXEL_FORMAT_I420:
613 *mimetype = MEDIA_FORMAT_I420;
615 case MM_PIXEL_FORMAT_YV12:
616 *mimetype = MEDIA_FORMAT_YV12;
618 case MM_PIXEL_FORMAT_RGB565:
619 *mimetype = MEDIA_FORMAT_RGB565;
621 case MM_PIXEL_FORMAT_RGB888:
622 *mimetype = MEDIA_FORMAT_RGB888;
624 case MM_PIXEL_FORMAT_RGBA:
625 *mimetype = MEDIA_FORMAT_RGBA;
627 case MM_PIXEL_FORMAT_ARGB:
628 *mimetype = MEDIA_FORMAT_ARGB;
631 LOGE("invalid in_format %d", in_format);
632 return CAMERA_ERROR_INVALID_PARAMETER;
635 return CAMERA_ERROR_NONE;
638 void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_key,
639 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame)
642 unsigned char *buf_pos = NULL;
644 if (stream == NULL || buffer_bo_handle == NULL || frame == NULL) {
645 LOGE("invalid parameter - stream:%p, buffer_bo_handle:%p", stream, buffer_bo_handle);
650 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
651 frame->format = MM_PIXEL_FORMAT_UYVY;
653 frame->format = stream->format;
655 frame->width = stream->width;
656 frame->height = stream->height;
657 frame->timestamp = stream->timestamp;
658 frame->num_of_planes = stream->num_planes;
660 if (num_buffer_key == 0) {
662 if (!data_bo_handle || !data_bo_handle->ptr) {
663 LOGE("NULL pointer");
667 buf_pos = data_bo_handle->ptr;
669 if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) {
670 frame->data.encoded_plane.data = buf_pos;
671 frame->data.encoded_plane.size = stream->data.encoded.length_data;
672 total_size = stream->data.encoded.length_data;
674 switch (stream->num_planes) {
676 frame->data.single_plane.yuv = buf_pos;
677 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
678 total_size = stream->data.yuv420.length_yuv;
681 frame->data.double_plane.y = buf_pos;
682 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
683 buf_pos += stream->data.yuv420sp.length_y;
684 frame->data.double_plane.uv = buf_pos;
685 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
686 total_size = stream->data.yuv420sp.length_y + \
687 stream->data.yuv420sp.length_uv;
690 frame->data.triple_plane.y = buf_pos;
691 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
692 buf_pos += stream->data.yuv420p.length_y;
693 frame->data.triple_plane.u = buf_pos;
694 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
695 buf_pos += stream->data.yuv420p.length_u;
696 frame->data.triple_plane.v = buf_pos;
697 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
698 total_size = stream->data.yuv420p.length_y + \
699 stream->data.yuv420p.length_u + \
700 stream->data.yuv420p.length_v;
708 switch (stream->num_planes) {
710 frame->data.single_plane.yuv = buffer_bo_handle[0].ptr;
711 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
712 total_size = stream->data.yuv420.length_yuv;
715 frame->data.double_plane.y = buffer_bo_handle[0].ptr;
716 if (stream->num_planes == (unsigned int)num_buffer_key)
717 frame->data.double_plane.uv = buffer_bo_handle[1].ptr;
719 frame->data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
720 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
721 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
722 total_size = stream->data.yuv420sp.length_y + \
723 stream->data.yuv420sp.length_uv;
726 frame->data.triple_plane.y = buffer_bo_handle[0].ptr;
727 if (stream->num_planes == (unsigned int)num_buffer_key) {
728 frame->data.triple_plane.u = buffer_bo_handle[1].ptr;
729 frame->data.triple_plane.v = buffer_bo_handle[2].ptr;
731 frame->data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y;
732 frame->data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u;
734 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
735 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
736 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
737 total_size = stream->data.yuv420p.length_y + \
738 stream->data.yuv420p.length_u + \
739 stream->data.yuv420p.length_v;
747 LOGD("format %d, %dx%d, size %d plane num %d",
748 frame.format, frame.width, frame.height, total_size, frame.num_of_planes);
754 int _camera_media_packet_data_create(int tbm_key, int num_buffer_key, tbm_bo bo,
755 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
758 int ret = CAMERA_ERROR_NONE;
759 camera_media_packet_data *tmp_mp_data = NULL;
761 if (*mp_data == NULL) {
762 tmp_mp_data = g_new0(camera_media_packet_data, 1);
764 tmp_mp_data->tbm_key = tbm_key;
765 tmp_mp_data->num_buffer_key = num_buffer_key;
766 tmp_mp_data->bo = bo;
767 tmp_mp_data->data_bo = data_bo;
768 tmp_mp_data->ref_cnt++;
770 for (i = 0 ; i < num_buffer_key ; i++)
771 tmp_mp_data->buffer_bo[i] = buffer_bo[i];
773 *mp_data = tmp_mp_data;
774 /*LOGD("mp_data %p", tmp_mp_data);*/
776 ret = CAMERA_ERROR_OUT_OF_MEMORY;
777 LOGE("failed to alloc media packet data");
780 ((camera_media_packet_data *)*mp_data)->ref_cnt++;
786 void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
790 camera_msg_param param;
792 if (!mp_data || !cb_info) {
793 LOGE("NULL pointer %p %p", mp_data, cb_info);
797 if (mp_data->ref_cnt > 1) {
799 LOGD("ref count %d", mp_data->ref_cnt);
801 /* release imported bo */
802 for (i = 0 ; i < mp_data->num_buffer_key ; i++) {
803 tbm_bo_unref(mp_data->buffer_bo[i]);
804 mp_data->buffer_bo[i] = NULL;
808 _camera_release_imported_bo(&mp_data->bo);
809 _camera_release_imported_bo(&mp_data->data_bo);
812 tbm_key = mp_data->tbm_key;
814 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
816 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
825 int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
826 camera_media_packet_data *mp_data, media_packet_h *packet)
828 media_packet_h pkt = NULL;
829 bool make_pkt_fmt = false;
830 tbm_surface_h tsurf = NULL;
831 tbm_surface_info_s tsurf_info;
832 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
833 uint32_t bo_format = 0;
836 int num_buffer_key = 0;
837 tbm_bo *buffer_bo = NULL;
839 if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) {
840 LOGE("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p",
841 cb_info, stream, mp_data, packet);
842 return CAMERA_ERROR_INVALID_PARAMETER;
845 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
846 buffer_bo = mp_data->buffer_bo;
847 num_buffer_key = mp_data->num_buffer_key;
849 /* create tbm surface */
850 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
851 tsurf_info.planes[i].stride = stream->stride[i];
853 /* get tbm surface format */
854 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
855 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
857 if (ret == CAMERA_ERROR_NONE) {
858 tsurf_info.width = stream->width;
859 tsurf_info.height = stream->height;
860 tsurf_info.format = bo_format;
861 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
862 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
864 if (num_buffer_key > 0) {
866 case TBM_FORMAT_NV12:
867 case TBM_FORMAT_NV21:
868 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
869 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
870 tsurf_info.planes[0].offset = 0;
871 if (num_buffer_key == 1)
872 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
873 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
875 case TBM_FORMAT_YUV420:
876 case TBM_FORMAT_YVU420:
877 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
878 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
879 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
880 tsurf_info.planes[0].offset = 0;
881 if (num_buffer_key == 1) {
882 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
883 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
885 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
887 case TBM_FORMAT_UYVY:
888 case TBM_FORMAT_YUYV:
889 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
890 tsurf_info.planes[0].offset = 0;
891 tsurf_info.size = tsurf_info.planes[0].size;
897 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_key);
898 } else if (mp_data->data_bo) {
900 case TBM_FORMAT_NV12:
901 case TBM_FORMAT_NV21:
902 tsurf_info.planes[0].size = stream->width * stream->height;
903 tsurf_info.planes[1].size = (tsurf_info.planes[0].size) >> 1;
904 tsurf_info.planes[0].offset = 0;
905 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
906 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
908 case TBM_FORMAT_YUV420:
909 case TBM_FORMAT_YVU420:
910 tsurf_info.planes[0].size = stream->width * stream->height;
911 tsurf_info.planes[1].size = (stream->width >> 1) * (stream->height >> 1);
912 tsurf_info.planes[2].size = tsurf_info.planes[1].size;
913 tsurf_info.planes[0].offset = 0;
914 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
915 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
916 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
918 case TBM_FORMAT_UYVY:
919 case TBM_FORMAT_YUYV:
920 tsurf_info.planes[0].size = (stream->width * stream->height) << 1;
921 tsurf_info.planes[0].offset = 0;
922 tsurf_info.size = tsurf_info.planes[0].size;
928 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1);
930 /*LOGD("tbm surface %p", tsurf);*/
934 /* check media packet format */
935 if (cb_info->pkt_fmt) {
936 int pkt_fmt_width = 0;
937 int pkt_fmt_height = 0;
938 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
940 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
941 if (pkt_fmt_mimetype != mimetype ||
942 pkt_fmt_width != stream->width ||
943 pkt_fmt_height != stream->height) {
944 LOGW("change fmt: current 0x%x, %dx%d",
945 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
946 media_format_unref(cb_info->pkt_fmt);
947 cb_info->pkt_fmt = NULL;
954 /* create packet format */
956 LOGW("make new pkt_fmt - 0x%x, %dx%d", mimetype, stream->width, stream->height);
957 ret = media_format_create(&cb_info->pkt_fmt);
958 if (ret == MEDIA_FORMAT_ERROR_NONE) {
959 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
960 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
961 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
962 LOGW("media_format_set : 0x%x", ret);
964 LOGW("media_format_create failed 0x%x", ret);
968 /* create media packet */
969 ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt,
970 tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
971 (void *)cb_info, &pkt);
972 if (ret != MEDIA_PACKET_ERROR_NONE) {
973 LOGE("media_packet_create failed 0x%x", ret);
974 tbm_surface_destroy(tsurf);
978 LOGE("tbm surface failed. %dx%d, format %d, num_buffer_key %d, data_bo %p",
979 stream->width, stream->height, stream->format, num_buffer_key, mp_data->data_bo);
983 /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
984 /* set media packet data */
985 ret = media_packet_set_extra(pkt, (void *)mp_data);
986 if (ret != MEDIA_PACKET_ERROR_NONE) {
987 LOGE("media_packet_set_extra failed");
989 _camera_media_packet_data_release(mp_data, cb_info);
992 media_packet_destroy(pkt);
995 /* set timestamp : msec -> nsec */
996 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
997 LOGW("media_packet_set_pts failed");
1006 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
1009 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1010 camera_media_packet_data *mp_data = NULL;
1011 tbm_surface_h tsurf = NULL;
1013 if (!pkt || !cb_info) {
1014 LOGE("NULL pointer %p %p", pkt, cb_info);
1015 return MEDIA_PACKET_FINALIZE;
1018 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1019 if (ret != MEDIA_PACKET_ERROR_NONE) {
1020 LOGE("media_packet_get_extra failed 0x%x", ret);
1021 return MEDIA_PACKET_FINALIZE;
1024 /*LOGD("mp_data %p", mp_data);*/
1026 g_mutex_lock(&cb_info->mp_data_mutex);
1028 _camera_media_packet_data_release(mp_data, cb_info);
1031 g_mutex_unlock(&cb_info->mp_data_mutex);
1033 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1034 if (ret != MEDIA_PACKET_ERROR_NONE)
1035 LOGE("get tbm_surface failed 0x%x", ret);
1038 tbm_surface_destroy(tsurf);
1042 return MEDIA_PACKET_FINALIZE;
1045 static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event)
1051 tbm_bo_handle bo_handle = {NULL, };
1052 camera_msg_param param;
1054 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1055 LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event);
1059 /*LOGD("get camera msg %s, event %d", recv_msg, event);*/
1061 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1062 if (!(CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) &&
1063 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] == NULL &&
1064 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] == NULL) {
1065 LOGW("all preview callback from user are NULL");
1068 } else if (cb_info->user_cb[event] == NULL) {
1069 LOGW("user callback for event %d is not set", event);
1074 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1080 muse_camera_msg_get(previous, recv_msg);
1081 muse_camera_msg_get(current, recv_msg);
1082 muse_camera_msg_get(by_policy, recv_msg);
1084 LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
1085 previous, current, by_policy);
1087 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1088 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1091 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1095 muse_camera_msg_get(state, recv_msg);
1097 LOGD("FOCUS state - %d", state);
1099 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1102 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1103 LOGD("CAPTURE_COMPLETED");
1104 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1106 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1107 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1111 int num_buffer_key = 0;
1112 int buffer_key[BUFFER_MAX_PLANE_NUM] = {0, };
1114 unsigned char *buf_pos = NULL;
1116 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
1117 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
1118 tbm_bo data_bo = NULL;
1119 tbm_bo_handle data_bo_handle = {.ptr = NULL};
1121 camera_preview_data_s frame;
1122 camera_stream_data_s *stream = NULL;
1123 camera_media_packet_data *mp_data = NULL;
1124 media_packet_h pkt = NULL;
1125 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1126 media_packet_h pkt_evas = NULL;
1127 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1129 muse_camera_msg_get(tbm_key, recv_msg);
1130 muse_camera_msg_get(num_buffer_key, recv_msg);
1131 muse_camera_msg_get_array(buffer_key, recv_msg);
1132 muse_camera_msg_get(data_key, recv_msg);
1134 memset(&frame, 0x0, sizeof(camera_preview_data_s));
1137 LOGE("invalid key %d", tbm_key);
1141 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1144 /* import tbm data_bo and get virtual address */
1145 if (!_camera_import_tbm_key(cb_info->bufmgr, data_key, &data_bo, &data_bo_handle)) {
1146 LOGE("failed to import data key %d", data_key);
1147 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1152 /* import tbm bo and get virtual address */
1153 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
1154 LOGE("failed to import key %d", tbm_key);
1155 _camera_release_imported_bo(&data_bo);
1156 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1160 buf_pos = (unsigned char *)bo_handle.ptr;
1162 /* get stream info */
1163 stream = (camera_stream_data_s *)buf_pos;
1165 for (i = 0 ; i < num_buffer_key ; i++) {
1166 /* import buffer bo and get virtual address */
1167 if (!_camera_import_tbm_key(cb_info->bufmgr, buffer_key[i], &buffer_bo[i], &buffer_bo_handle[i])) {
1168 LOGE("failed to import buffer key %d", buffer_key[i]);
1170 /* release imported bo */
1171 _camera_release_imported_bo(&data_bo);
1172 _camera_release_imported_bo(&bo);
1174 for (i -= 1 ; i >= 0 ; i--)
1175 _camera_release_imported_bo(&buffer_bo[i]);
1177 /* send return buffer */
1178 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1184 /* call preview callback */
1185 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
1186 _camera_preview_frame_create(stream, num_buffer_key, buffer_bo_handle, &data_bo_handle, &frame);
1188 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
1189 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
1192 if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
1193 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1194 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
1196 if (ret == CAMERA_ERROR_NONE) {
1197 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt_evas);
1198 if (ret != CAMERA_ERROR_NONE) {
1199 LOGE("create pkt for evas failed");
1200 _camera_media_packet_data_release(mp_data, cb_info);
1204 #else /* TIZEN_FEATURE_EVAS_RENDERER */
1205 LOGW("evas renderer is not supported");
1206 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1209 /* call media packet callback */
1210 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
1211 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
1213 if (ret == CAMERA_ERROR_NONE) {
1214 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt);
1216 if (ret == CAMERA_ERROR_NONE) {
1217 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
1218 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
1220 _camera_media_packet_data_release(mp_data, cb_info);
1226 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1227 /* call evas renderer */
1229 g_mutex_lock(&cb_info->evas_mutex);
1230 if (cb_info->run_evas_render) {
1231 mm_evas_renderer_write(pkt_evas, cb_info->evas_info);
1233 LOGW("evas renderer is stopped, skip this buffer...");
1234 media_packet_destroy(pkt_evas);
1237 g_mutex_unlock(&cb_info->evas_mutex);
1239 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1241 /* send message for preview callback return */
1242 if (!CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS))
1243 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info, NULL, 0);
1245 if (mp_data == NULL) {
1246 /* release imported bo */
1247 for (i = 0 ; i < num_buffer_key ; i++)
1248 _camera_release_imported_bo(&buffer_bo[i]);
1250 /* unmap and unref tbm bo */
1251 _camera_release_imported_bo(&data_bo);
1252 _camera_release_imported_bo(&bo);
1255 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1257 /*LOGD("return buffer Done");*/
1261 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1265 muse_camera_msg_get(percent, recv_msg);
1267 LOGD("HDR progress - %d \%", percent);
1269 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1272 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1278 muse_camera_msg_get(policy, recv_msg);
1279 muse_camera_msg_get(previous, recv_msg);
1280 muse_camera_msg_get(current, recv_msg);
1282 LOGW("INTERRUPTED - policy %d, state previous %d, current %d",
1283 policy, previous, current);
1285 if (policy == CAMERA_POLICY_SOUND)
1286 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND is deprecated and will be removed from next release.");
1287 else if (policy == CAMERA_POLICY_SOUND_BY_CALL)
1288 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_CALL is deprecated and will be removed from next release.");
1289 else if (policy == CAMERA_POLICY_SOUND_BY_ALARM)
1290 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_ALARM is deprecated and will be removed from next release.");
1292 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1293 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1296 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1299 camera_detected_face_s *faces = NULL;
1301 muse_camera_msg_get(count, recv_msg);
1302 muse_camera_msg_get(tbm_key, recv_msg);
1304 if (count > 0 && tbm_key > 0) {
1305 LOGD("FACE_DETECTION - count %d, tbm_key %d", count, tbm_key);
1307 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle))
1311 faces = bo_handle.ptr;
1313 ((camera_face_detected_cb)cb_info->user_cb[event])(faces, count, cb_info->user_data[event]);
1319 for (i = 0 ; i < count ; i++) {
1320 LOGD("id[%2d] - score %d, position (%d,%d,%dx%d)",
1321 i, faces[i].score, faces[i].x, faces[i].y, faces[i].width, faces[i].height);
1327 _camera_release_imported_bo(&bo);
1330 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1331 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1333 /*LOGD("return buffer done");*/
1335 LOGE("invalid message - count %d, key %d", count, tbm_key);
1339 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1342 int current_state = 0;
1344 muse_camera_msg_get(error, recv_msg);
1345 muse_camera_msg_get(current_state, recv_msg);
1347 LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
1349 if (error == CAMERA_ERROR_SOUND_POLICY)
1350 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
1351 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_CALL)
1352 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
1353 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_ALARM)
1354 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
1356 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1357 (camera_state_e)current_state, cb_info->user_data[event]);
1360 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1362 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1363 muse_camera_msg_get(param1, recv_msg);
1364 muse_camera_msg_get(param2, recv_msg);
1366 /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/
1368 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1369 cb_info->user_cb[event] = NULL;
1370 cb_info->user_data[event] = NULL;
1371 LOGW("stop foreach callback for event %d", event);
1374 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1376 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1378 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1380 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1382 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1384 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1386 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1388 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1390 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1392 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1394 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1396 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1398 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1400 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1402 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1403 muse_camera_msg_get(param1, recv_msg);
1405 /*LOGD("event %d SUPPORTED %d ", event, param1);*/
1407 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1408 cb_info->user_cb[event] = NULL;
1409 cb_info->user_data[event] = NULL;
1410 LOGW("stop foreach callback for event %d", event);
1413 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1415 camera_image_data_s *rImage = NULL;
1416 camera_image_data_s *rPostview = NULL;
1417 camera_image_data_s *rThumbnail = NULL;
1418 unsigned char *buf_pos = NULL;
1419 int tbm_key_main = 0;
1420 int tbm_key_post = 0;
1421 int tbm_key_thumb = 0;
1422 tbm_bo bo_main = NULL;
1423 tbm_bo bo_post = NULL;
1424 tbm_bo bo_thumb = NULL;
1425 tbm_bo_handle bo_main_handle = {NULL, };
1426 tbm_bo_handle bo_post_handle = {NULL, };
1427 tbm_bo_handle bo_thumb_handle = {NULL, };
1429 muse_camera_msg_get(tbm_key_main, recv_msg);
1430 muse_camera_msg_get(tbm_key_post, recv_msg);
1431 muse_camera_msg_get(tbm_key_thumb, recv_msg);
1434 LOGD("camera capture callback came in. tbm_key_main %d, tbm_key_post %d, tbm_key_thumb %d",
1435 tbm_key_main, tbm_key_post, tbm_key_thumb);
1438 if (tbm_key_main <= 0) {
1439 LOGE("invalid key %d", tbm_key_main);
1443 /* import tbm bo and get virtual address */
1444 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_main, &bo_main, &bo_main_handle))
1447 buf_pos = (unsigned char *)bo_main_handle.ptr;
1448 rImage = (camera_image_data_s *)buf_pos;
1449 rImage->data = buf_pos + sizeof(camera_image_data_s);
1450 if (rImage->exif && rImage->exif_size > 0) {
1451 rImage->exif = rImage->data + rImage->size;
1453 rImage->exif = NULL;
1454 rImage->exif_size = 0;
1457 LOGD("image info %dx%d, size %d, EXIF info %p, size %d",
1458 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
1460 if (tbm_key_post > 0) {
1461 /* import tbm bo and get virtual address */
1462 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_post, &bo_post, &bo_post_handle))
1465 buf_pos = (unsigned char *)bo_post_handle.ptr;
1466 rPostview = (camera_image_data_s *)buf_pos;
1467 LOGD("rPostview->size : %d", rPostview->size);
1468 rPostview->data = buf_pos + sizeof(camera_image_data_s);
1471 if (tbm_key_thumb > 0) {
1472 /* import tbm bo and get virtual address */
1473 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_thumb, &bo_thumb, &bo_thumb_handle))
1476 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
1478 rThumbnail = (camera_image_data_s *)buf_pos;
1479 LOGD("rThumbnail->size : %d", rThumbnail->size);
1480 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
1483 ((camera_capturing_cb)cb_info->user_cb[event])(rImage, rPostview, rThumbnail, cb_info->user_data[event]);
1485 /* unmap and unref tbm bo */
1486 _camera_release_imported_bo(&bo_main);
1489 tbm_key = tbm_key_main;
1491 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1493 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1495 if (tbm_key_post > 0) {
1496 /* unmap and unref tbm bo */
1497 _camera_release_imported_bo(&bo_post);
1500 param.value.value_INT = tbm_key_post;
1501 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1504 if (tbm_key_thumb > 0) {
1505 /* unmap and unref tbm bo */
1506 _camera_release_imported_bo(&bo_thumb);
1509 param.value.value_INT = tbm_key_thumb;
1510 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1513 LOGD("return buffer done");
1516 default: /* MUSE_CAMERA_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR */
1517 LOGE("render error");
1524 static bool _camera_idle_event_callback(void *data)
1526 camera_cb_info_s *cb_info = NULL;
1527 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1529 if (cam_idle_event == NULL) {
1530 LOGE("cam_idle_event is NULL");
1535 g_mutex_lock(&cam_idle_event->event_mutex);
1537 cb_info = cam_idle_event->cb_info;
1538 if (cb_info == NULL) {
1539 LOGW("camera cb_info is NULL. event %d", cam_idle_event->event);
1540 goto IDLE_EVENT_CALLBACK_DONE;
1543 /* remove event from list */
1544 g_mutex_lock(&cb_info->idle_event_mutex);
1546 if (cb_info->idle_event_list)
1547 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1549 /*LOGD("remove camera idle event %p, %p", cam_idle_event, cb_info->idle_event_list);*/
1550 g_mutex_unlock(&cb_info->idle_event_mutex);
1553 _camera_client_user_callback(cam_idle_event->cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
1555 /* send signal for waiting thread */
1556 g_cond_signal(&cb_info->idle_event_cond);
1558 IDLE_EVENT_CALLBACK_DONE:
1559 /* unlock and release event */
1560 g_mutex_unlock(&cam_idle_event->event_mutex);
1561 g_mutex_clear(&cam_idle_event->event_mutex);
1563 g_free(cam_idle_event);
1564 cam_idle_event = NULL;
1569 static void *_camera_msg_handler_func(gpointer data)
1573 camera_message_s *cam_msg = NULL;
1574 camera_idle_event_s *cam_idle_event = NULL;
1575 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1576 camera_cb_info_s *cb_info = NULL;
1578 if (!handler_info || !handler_info->cb_info) {
1579 LOGE("NULL handler %p", handler_info);
1583 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1584 type = handler_info->type;
1586 LOGD("t:%d start", type);
1588 g_mutex_lock(&handler_info->mutex);
1590 while (g_atomic_int_get(&handler_info->running)) {
1591 if (g_queue_is_empty(handler_info->queue)) {
1592 /*LOGD("t:%d signal wait...", type);*/
1593 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1594 /*LOGD("t:%d signal received", type);*/
1596 if (g_atomic_int_get(&handler_info->running) == 0) {
1597 LOGD("t:%d stop event thread", type);
1602 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1604 g_mutex_unlock(&handler_info->mutex);
1606 if (cam_msg == NULL) {
1607 LOGE("t:%d NULL message", type);
1608 g_mutex_lock(&handler_info->mutex);
1614 if (api < MUSE_CAMERA_API_MAX) {
1617 g_mutex_lock(&cb_info->api_mutex[api]);
1619 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1620 cb_info->api_ret[api] = ret;
1621 cb_info->api_activating[api] = 1;
1623 /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
1625 g_cond_signal(&cb_info->api_cond[api]);
1627 LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1630 g_mutex_unlock(&cb_info->api_mutex[api]);
1631 } else if (api == MUSE_CAMERA_CB_EVENT) {
1632 switch (cam_msg->event_class) {
1633 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1634 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event);
1636 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1637 cam_idle_event = g_new0(camera_idle_event_s, 1);
1638 if (cam_idle_event == NULL) {
1639 LOGE("t:%d cam_idle_event alloc failed", type);
1643 cam_idle_event->event = cam_msg->event;
1644 cam_idle_event->cb_info = cb_info;
1645 g_mutex_init(&cam_idle_event->event_mutex);
1646 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg) - 1);
1648 /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, cam_msg->event, cam_idle_event);*/
1650 g_mutex_lock(&cb_info->idle_event_mutex);
1651 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1652 g_mutex_unlock(&cb_info->idle_event_mutex);
1654 g_idle_add_full(G_PRIORITY_DEFAULT,
1655 (GSourceFunc)_camera_idle_event_callback,
1656 (gpointer)cam_idle_event,
1660 LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
1664 LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1670 g_mutex_lock(&handler_info->mutex);
1673 /* remove remained event */
1674 while (!g_queue_is_empty(handler_info->queue)) {
1675 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1677 LOGD("t:%d remove camera message %p", type, cam_msg);
1681 LOGW("t:%d NULL camera message", type);
1685 g_mutex_unlock(&handler_info->mutex);
1687 LOGD("t:%d return", type);
1693 static void _camera_remove_idle_event_all(camera_cb_info_s *cb_info)
1695 camera_idle_event_s *cam_idle_event = NULL;
1696 gboolean ret = TRUE;
1698 gint64 end_time = 0;
1700 if (cb_info == NULL) {
1701 LOGE("cb_info is NULL");
1705 g_mutex_lock(&cb_info->idle_event_mutex);
1707 if (cb_info->idle_event_list == NULL) {
1708 LOGD("No remained idle event");
1709 g_mutex_unlock(&cb_info->idle_event_mutex);
1713 list = cb_info->idle_event_list;
1716 cam_idle_event = list->data;
1717 list = g_list_next(list);
1719 if (!cam_idle_event) {
1720 LOGW("Fail to remove idle event. The event is NULL");
1724 if (g_mutex_trylock(&cam_idle_event->event_mutex)) {
1725 ret = g_idle_remove_by_data(cam_idle_event);
1727 LOGD("remove idle event [%p], ret[%d]", cam_idle_event, ret);
1730 cam_idle_event->cb_info = NULL;
1731 LOGW("idle event %p will be called later", cam_idle_event);
1734 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1736 g_mutex_unlock(&cam_idle_event->event_mutex);
1739 g_mutex_clear(&cam_idle_event->event_mutex);
1741 g_free(cam_idle_event);
1742 cam_idle_event = NULL;
1744 LOGD("remove idle event done");
1750 LOGW("event lock failed. it's being called...");
1752 end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
1754 if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
1755 LOGW("signal received");
1760 g_list_free(cb_info->idle_event_list);
1761 cb_info->idle_event_list = NULL;
1763 g_mutex_unlock(&cb_info->idle_event_mutex);
1769 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg)
1771 camera_message_s *cam_msg = NULL;
1773 if (!cb_info || !msg) {
1774 LOGE("NULL pointer %p %p", cb_info, msg);
1778 cam_msg = g_new0(camera_message_s, 1);
1780 LOGE("failed to alloc cam_msg for [%s]", msg);
1785 cam_msg->event = event;
1786 cam_msg->event_class = event_class;
1788 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1790 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1792 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1793 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1794 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1795 g_cond_signal(&cb_info->preview_cb_info.cond);
1796 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1797 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1798 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1799 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1800 g_cond_signal(&cb_info->capture_cb_info.cond);
1801 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1803 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1804 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1805 g_cond_signal(&cb_info->msg_handler_info.cond);
1806 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1815 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg)
1817 int ret = CAMERA_ERROR_NONE;
1821 int event_class = -1;
1825 if (!cb_info || !msg) {
1826 LOGE("invalid ptr %p %p", cb_info, msg);
1830 /*LOGD("msg [%s]", msg);*/
1832 if (!muse_camera_msg_get(api, msg)) {
1833 LOGE("failed to get camera api");
1837 if (api == MUSE_CAMERA_CB_EVENT) {
1838 if (!muse_camera_msg_get(event, msg) ||
1839 !muse_camera_msg_get(event_class, msg)) {
1840 LOGE("failed to get camera event or event_class [%s]", msg);
1844 if (!muse_camera_msg_get(api_class, msg)) {
1845 LOGE("failed to get camera api_class [%s]", msg);
1850 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1851 if (api >= MUSE_CAMERA_API_MAX) {
1852 LOGE("invalid api %d", api);
1856 if (!muse_camera_msg_get(ret, msg)) {
1857 LOGE("failed to get camera ret");
1861 g_mutex_lock(&cb_info->api_mutex[api]);
1863 cb_info->api_ret[api] = ret;
1864 cb_info->api_activating[api] = 1;
1867 case MUSE_CAMERA_API_CREATE:
1868 if (ret != CAMERA_ERROR_NONE) {
1869 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1870 LOGE("camera create error 0x%x. close client cb handler", ret);
1873 case MUSE_CAMERA_API_DESTROY:
1874 if (ret == CAMERA_ERROR_NONE) {
1875 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1876 LOGD("camera destroy done. close client cb handler");
1880 muse_camera_msg_get(get_type, msg);
1881 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1882 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1883 muse_camera_msg_get(get_index, msg);
1886 case MUSE_CAMERA_GET_TYPE_INT:
1887 muse_core_msg_json_deserialize("get_value", msg, NULL, &cb_info->get_int[get_index], NULL, MUSE_TYPE_INT);
1889 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1890 muse_core_msg_json_deserialize("get_value0", msg, NULL, &cb_info->get_int_pair[get_index][0], NULL, MUSE_TYPE_INT);
1891 muse_core_msg_json_deserialize("get_value1", msg, NULL, &cb_info->get_int_pair[get_index][1], NULL, MUSE_TYPE_INT);
1893 case MUSE_CAMERA_GET_TYPE_ARRAY:
1894 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
1895 muse_core_msg_json_deserialize("get_value",
1896 msg, NULL, cb_info->get_display_roi_area, NULL, MUSE_TYPE_ARRAY);
1897 LOGD("get display roi %d,%d,%dx%d",
1898 cb_info->get_display_roi_area[0],
1899 cb_info->get_display_roi_area[1],
1900 cb_info->get_display_roi_area[2],
1901 cb_info->get_display_roi_area[3]);
1903 muse_core_msg_json_deserialize("get_value",
1904 msg, NULL, cb_info->get_geotag, NULL, MUSE_TYPE_ARRAY);
1905 LOGD("get geotag %lf, %lf, %lf",
1906 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
1909 case MUSE_CAMERA_GET_TYPE_STRING:
1910 muse_core_msg_json_deserialize("get_value", msg, NULL, cb_info->get_string[get_index], NULL, MUSE_TYPE_STRING);
1913 LOGW("unknown type %d", get_type);
1920 g_cond_signal(&cb_info->api_cond[api]);
1921 g_mutex_unlock(&cb_info->api_mutex[api]);
1922 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
1923 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg);
1925 LOGW("unknown camera api %d, class %d", api, api_class);
1932 static void *_camera_msg_recv_func(gpointer data)
1934 int recv_length = 0;
1935 int single_length = 0;
1936 int remained_length = 0;
1937 char *recv_msg = NULL;
1938 char *single_msg = NULL;
1939 char *remained_msg = NULL;
1943 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
1946 LOGE("cb_info NULL");
1952 single_msg = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
1954 LOGE("single_msg malloc failed");
1958 recv_msg = cb_info->recv_msg;
1960 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
1961 recv_length = muse_core_ipc_recv_msg(cb_info->fd, recv_msg);
1962 if (recv_length <= 0) {
1963 cb_info->is_server_connected = FALSE;
1964 LOGE("receive msg failed - server disconnected");
1972 /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
1974 /* Need to split the combined entering msgs */
1975 for (cur_pos = 0 ; cur_pos < recv_length ; cur_pos++) {
1976 if (recv_msg[cur_pos] == '}') {
1977 single_length = cur_pos - prev_pos + 1;
1979 if (single_length < MUSE_CAMERA_MSG_MAX_LENGTH) {
1980 /* check remained msg */
1981 if (remained_length > 0) {
1983 strncpy(single_msg, remained_msg, remained_length);
1984 strncpy(single_msg + remained_length, recv_msg + prev_pos, single_length);
1985 single_msg[remained_length + single_length] = '\0';
1988 remained_msg = NULL;
1990 strncpy(single_msg, recv_msg + prev_pos, single_length);
1991 single_msg[single_length] = '\0';
1992 LOGE("lost msg [%s], skip...", single_msg);
1995 remained_length = 0;
1997 strncpy(single_msg, recv_msg + prev_pos, single_length);
1998 single_msg[single_length] = '\0';
2001 if (single_msg[0] == '{') {
2003 /*LOGD("splitted msg : [%s], Index : %d", single_msg, num_msg);*/
2004 /* process each message */
2005 __camera_process_msg(cb_info, single_msg);
2007 LOGE("invalid msg [%s]", single_msg);
2010 LOGE("too long message [len %d] skip...", single_length);
2013 prev_pos = cur_pos + 1;
2017 /* check incompleted message */
2018 if (recv_msg[recv_length - 1] != '}') {
2019 remained_length = recv_length - prev_pos;
2021 LOGW("incompleted message [len %d]", remained_length);
2023 remained_msg = (char *)malloc(remained_length + 1);
2025 strncpy(remained_msg, recv_msg + prev_pos, remained_length);
2026 remained_msg[remained_length] = '\0';
2028 LOGE("failed to alloc for remained msg");
2031 remained_length = 0;
2035 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
2037 if (!cb_info->is_server_connected) {
2038 /* send error msg for server disconnection */
2039 char *error_msg = muse_core_msg_json_factory_new(MUSE_CAMERA_CB_EVENT,
2040 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
2041 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
2045 LOGE("error_msg failed");
2046 goto CB_HANDLER_EXIT;
2049 __camera_add_msg_to_queue(cb_info,
2050 MUSE_CAMERA_CB_EVENT,
2051 MUSE_CAMERA_EVENT_TYPE_ERROR,
2052 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
2055 muse_core_msg_json_factory_free(error_msg);
2058 LOGE("add error msg for service disconnection done");
2069 remained_msg = NULL;
2076 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2077 int type, const char *thread_name, camera_cb_info_s *cb_info)
2079 if (!handler_info || !thread_name || !cb_info) {
2080 LOGE("t:%d NULL %p %p %p",
2081 type, handler_info, thread_name, cb_info);
2087 handler_info->type = type;
2088 handler_info->queue = g_queue_new();
2089 if (handler_info->queue == NULL) {
2090 LOGE("t:%d queue failed", type);
2094 g_mutex_init(&handler_info->mutex);
2095 g_cond_init(&handler_info->cond);
2097 handler_info->cb_info = (void *)cb_info;
2098 g_atomic_int_set(&handler_info->running, 1);
2100 handler_info->thread = g_thread_try_new(thread_name,
2101 _camera_msg_handler_func, (gpointer)handler_info, NULL);
2102 if (handler_info->thread == NULL) {
2103 LOGE("t:%d thread failed", type);
2105 g_mutex_clear(&handler_info->mutex);
2106 g_cond_clear(&handler_info->cond);
2107 g_queue_free(handler_info->queue);
2108 handler_info->queue = NULL;
2113 LOGD("t:%d done", type);
2119 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2123 if (!handler_info) {
2124 LOGE("NULL handler");
2128 if (!handler_info->thread) {
2129 LOGW("thread is not created");
2133 type = handler_info->type;
2135 LOGD("t:%d thread %p", type, handler_info->thread);
2137 g_mutex_lock(&handler_info->mutex);
2138 g_atomic_int_set(&handler_info->running, 0);
2139 g_cond_signal(&handler_info->cond);
2140 g_mutex_unlock(&handler_info->mutex);
2142 g_thread_join(handler_info->thread);
2143 g_thread_unref(handler_info->thread);
2144 handler_info->thread = NULL;
2146 g_mutex_clear(&handler_info->mutex);
2147 g_cond_clear(&handler_info->cond);
2148 g_queue_free(handler_info->queue);
2149 handler_info->queue = NULL;
2151 LOGD("t:%d done", type);
2157 static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
2159 camera_cb_info_s *cb_info = NULL;
2162 g_return_val_if_fail(sockfd > 0, NULL);
2164 cb_info = g_new0(camera_cb_info_s, 1);
2165 if (cb_info == NULL) {
2166 LOGE("cb_info failed");
2170 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2171 g_mutex_init(&cb_info->api_mutex[i]);
2172 g_cond_init(&cb_info->api_cond[i]);
2175 g_mutex_init(&cb_info->fd_lock);
2176 g_mutex_init(&cb_info->idle_event_mutex);
2177 g_cond_init(&cb_info->idle_event_cond);
2178 g_mutex_init(&cb_info->mp_data_mutex);
2179 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2180 g_mutex_init(&cb_info->evas_mutex);
2181 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2183 /* message handler thread */
2184 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2185 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2186 LOGE("msg_handler_info failed");
2190 /* message handler thread for preview callback */
2191 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2192 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2193 LOGE("preview_cb_info failed");
2197 /* message handler thread for capture callback */
2198 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2199 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2200 LOGE("capture_cb_info failed");
2204 cb_info->fd = sockfd;
2205 cb_info->preview_cb_flag = 0;
2206 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2207 cb_info->evas_info = NULL;
2208 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2210 /* message receive thread */
2211 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2212 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2213 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2214 if (cb_info->msg_recv_thread == NULL) {
2215 LOGE("message receive thread creation failed");
2219 cb_info->is_server_connected = TRUE;
2225 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2226 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2227 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2229 g_mutex_clear(&cb_info->fd_lock);
2230 g_mutex_clear(&cb_info->idle_event_mutex);
2231 g_cond_clear(&cb_info->idle_event_cond);
2232 g_mutex_clear(&cb_info->mp_data_mutex);
2233 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2234 g_mutex_clear(&cb_info->evas_mutex);
2235 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2237 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2238 g_mutex_clear(&cb_info->api_mutex[i]);
2239 g_cond_clear(&cb_info->api_cond[i]);
2249 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2253 g_return_if_fail(cb_info != NULL);
2255 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2257 g_thread_join(cb_info->msg_recv_thread);
2258 g_thread_unref(cb_info->msg_recv_thread);
2259 cb_info->msg_recv_thread = NULL;
2261 LOGD("msg_recv thread removed");
2263 /* destroy msg handler threads */
2264 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2265 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2266 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2268 g_mutex_clear(&cb_info->fd_lock);
2269 g_mutex_clear(&cb_info->idle_event_mutex);
2270 g_cond_clear(&cb_info->idle_event_cond);
2271 g_mutex_clear(&cb_info->mp_data_mutex);
2272 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2273 g_mutex_clear(&cb_info->evas_mutex);
2274 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2276 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2277 g_mutex_clear(&cb_info->api_mutex[i]);
2278 g_cond_clear(&cb_info->api_cond[i]);
2281 if (cb_info->fd > -1) {
2282 muse_core_connection_close(cb_info->fd);
2286 if (cb_info->bufmgr) {
2287 tbm_bufmgr_deinit(cb_info->bufmgr);
2288 cb_info->bufmgr = NULL;
2290 if (cb_info->pkt_fmt) {
2291 media_format_unref(cb_info->pkt_fmt);
2292 cb_info->pkt_fmt = NULL;
2295 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2296 if (cb_info->evas_info)
2297 mm_evas_renderer_destroy(&cb_info->evas_info);
2298 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2300 cb_info->preview_cb_flag = 0;
2309 int _camera_start_evas_rendering(camera_h camera)
2311 int ret = CAMERA_ERROR_NONE;
2312 camera_cli_s *pc = (camera_cli_s *)camera;
2314 if (!pc || !pc->cb_info) {
2315 LOGE("NULL handle");
2316 return CAMERA_ERROR_INVALID_PARAMETER;
2321 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2322 LOGE("EVAS surface is not set");
2323 return CAMERA_ERROR_NONE;
2326 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2327 g_mutex_lock(&pc->cb_info->evas_mutex);
2329 /* set evas render flag as RUN */
2330 pc->cb_info->run_evas_render = true;
2331 ret = CAMERA_ERROR_NONE;
2333 g_mutex_unlock(&pc->cb_info->evas_mutex);
2334 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2335 LOGW("evas renderer is not supported");
2336 ret = CAMERA_ERROR_NOT_SUPPORTED;
2337 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2343 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2345 int ret = CAMERA_ERROR_NONE;
2346 camera_cli_s *pc = (camera_cli_s *)camera;
2348 if (!pc || !pc->cb_info) {
2349 LOGE("NULL handle");
2350 return CAMERA_ERROR_INVALID_PARAMETER;
2353 LOGD("stop - keep screen %d", keep_screen);
2355 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2356 LOGE("EVAS surface is not set");
2357 return CAMERA_ERROR_NONE;
2360 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2361 g_mutex_lock(&pc->cb_info->evas_mutex);
2363 /* set evas render flag as STOP and release buffers */
2364 pc->cb_info->run_evas_render = false;
2366 ret = mm_evas_renderer_retrieve_all_packets(pc->cb_info->evas_info, keep_screen);
2367 if (ret != MM_ERROR_NONE) {
2368 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2369 ret = CAMERA_ERROR_INVALID_OPERATION;
2372 g_mutex_unlock(&pc->cb_info->evas_mutex);
2373 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2374 LOGW("evas renderer is not supported");
2375 ret = CAMERA_ERROR_NOT_SUPPORTED;
2376 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2382 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2384 int ret = CAMERA_ERROR_NONE;
2387 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2389 /* create muse connection */
2390 if (!key || !value) {
2391 LOGE("NULL pointer");
2392 return CAMERA_ERROR_INVALID_PARAMETER;
2395 sock_fd = muse_core_client_new();
2397 LOGE("muse_core_client_new failed");
2398 return CAMERA_ERROR_INVALID_OPERATION;
2401 msg = muse_core_msg_json_factory_new(api,
2402 MUSE_TYPE_INT, "module", MUSE_CAMERA,
2403 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2407 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2411 ret = muse_core_ipc_send_msg(sock_fd, msg);
2413 muse_core_msg_json_factory_free(msg);
2417 LOGE("send msg failed");
2418 ret = CAMERA_ERROR_INVALID_OPERATION;
2422 ret = muse_core_ipc_recv_msg(sock_fd, recv_msg);
2424 LOGE("recv msg failed %d", errno);
2425 ret = CAMERA_ERROR_INVALID_OPERATION;
2429 if (!muse_camera_msg_get(ret, recv_msg)) {
2430 LOGE("failed to get return value from msg [%s]", recv_msg);
2431 ret = CAMERA_ERROR_INVALID_OPERATION;
2435 if (ret == CAMERA_ERROR_NONE)
2436 muse_core_msg_json_deserialize(key, recv_msg, NULL, value, NULL, MUSE_TYPE_ANY);
2438 LOGD("api %d - value %d", api, *value);
2442 muse_core_connection_close(sock_fd);
2450 int camera_create(camera_device_e device, camera_h *camera)
2453 char *send_msg = NULL;
2455 int ret = CAMERA_ERROR_NONE;
2457 camera_cli_s *pc = NULL;
2458 tbm_bufmgr bufmgr = NULL;
2460 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2461 muse_core_api_module_e muse_module = MUSE_CAMERA;
2462 int device_type = (int)device;
2465 LOGE("NULL pointer");
2466 return CAMERA_ERROR_INVALID_PARAMETER;
2469 sock_fd = muse_core_client_new();
2471 LOGE("muse_core_client_new failed - returned fd %d", sock_fd);
2472 ret = CAMERA_ERROR_INVALID_OPERATION;
2478 send_msg = muse_core_msg_json_factory_new(api,
2479 MUSE_TYPE_INT, "module", muse_module,
2480 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2481 MUSE_TYPE_INT, "pid", pid,
2486 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2490 send_ret = muse_core_ipc_send_msg(sock_fd, send_msg);
2492 muse_core_msg_json_factory_free(send_msg);
2496 LOGE("send msg failed %d", errno);
2497 ret = CAMERA_ERROR_INVALID_OPERATION;
2501 pc = g_new0(camera_cli_s, 1);
2503 LOGE("camera_cli_s alloc failed");
2504 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2508 bufmgr = tbm_bufmgr_init(-1);
2509 if (bufmgr == NULL) {
2510 LOGE("get tbm bufmgr failed");
2511 ret = CAMERA_ERROR_INVALID_OPERATION;
2515 pc->cb_info = _camera_client_callback_new(sock_fd);
2516 if (pc->cb_info == NULL) {
2517 LOGE("cb_info alloc failed");
2518 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2524 LOGD("cb info : %d", pc->cb_info->fd);
2526 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2527 if (ret == CAMERA_ERROR_NONE) {
2528 intptr_t handle = 0;
2529 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2531 LOGE("Receiving Handle Failed!!");
2532 ret = CAMERA_ERROR_INVALID_OPERATION;
2536 pc->remote_handle = handle;
2537 pc->cb_info->bufmgr = bufmgr;
2539 ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL);
2540 if (ret != CAMERA_ERROR_NONE) {
2541 LOGE("init display failed 0x%x", ret);
2545 LOGD("camera create 0x%x", pc->remote_handle);
2546 *camera = (camera_h)pc;
2555 tbm_bufmgr_deinit(bufmgr);
2560 muse_core_connection_close(sock_fd);
2566 _camera_client_callback_destroy(pc->cb_info);
2573 LOGE("camera create error : 0x%x", ret);
2579 int camera_change_device(camera_h camera, camera_device_e device)
2581 int ret = CAMERA_ERROR_NONE;
2582 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2583 camera_cli_s *pc = (camera_cli_s *)camera;
2584 camera_msg_param param;
2586 if (!pc || !pc->cb_info) {
2587 LOGE("NULL handle");
2588 return CAMERA_ERROR_INVALID_PARAMETER;
2591 CAMERA_MSG_PARAM_SET(param, INT, device);
2593 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2599 int camera_destroy(camera_h camera)
2601 int ret = CAMERA_ERROR_NONE;
2602 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2603 camera_cli_s *pc = (camera_cli_s *)camera;
2605 if (!pc || !pc->cb_info) {
2606 LOGE("NULL handle");
2607 return CAMERA_ERROR_INVALID_PARAMETER;
2612 if (pc->cb_info->is_server_connected)
2613 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2615 LOGW("server disconnected. release resource without send message.");
2617 if (ret == CAMERA_ERROR_NONE) {
2618 _camera_remove_idle_event_all(pc->cb_info);
2619 _camera_client_callback_destroy(pc->cb_info);
2629 int camera_start_preview(camera_h camera)
2631 int ret = CAMERA_ERROR_NONE;
2632 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2633 camera_cli_s *pc = (camera_cli_s *)camera;
2635 if (!pc || !pc->cb_info) {
2636 LOGE("NULL handle");
2637 return CAMERA_ERROR_INVALID_PARAMETER;
2642 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2643 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2644 ret = _camera_start_evas_rendering(camera);
2645 if (ret != CAMERA_ERROR_NONE) {
2646 LOGE("stop preview because of error");
2647 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, pc->cb_info, NULL, 0);
2651 LOGD("ret : 0x%x", ret);
2657 int camera_stop_preview(camera_h camera)
2659 int ret = CAMERA_ERROR_NONE;
2660 camera_cli_s *pc = (camera_cli_s *)camera;
2661 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2662 camera_state_e current_state = CAMERA_STATE_NONE;
2664 if (!pc || !pc->cb_info) {
2665 LOGE("NULL handle");
2666 return CAMERA_ERROR_INVALID_PARAMETER;
2671 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2672 ret = camera_get_state(camera, ¤t_state);
2673 if (ret != CAMERA_ERROR_NONE) {
2674 LOGE("failed to get current state 0x%x", ret);
2678 if (current_state == CAMERA_STATE_PREVIEW) {
2679 ret = _camera_stop_evas_rendering(camera, false);
2680 if (ret != CAMERA_ERROR_NONE)
2685 /* send stop preview message */
2686 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2688 if (ret != CAMERA_ERROR_NONE &&
2689 current_state == CAMERA_STATE_PREVIEW) {
2690 LOGW("restart evas rendering");
2691 _camera_start_evas_rendering(camera);
2694 LOGD("ret : 0x%x", ret);
2700 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2702 int ret = CAMERA_ERROR_NONE;
2703 camera_cli_s *pc = (camera_cli_s *)camera;
2704 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2706 if (!pc || !pc->cb_info) {
2707 LOGE("NULL handle");
2708 return CAMERA_ERROR_INVALID_PARAMETER;
2713 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2714 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2716 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2717 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2719 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2721 LOGD("ret : 0x%x", ret);
2727 bool camera_is_supported_continuous_capture(camera_h camera)
2729 int ret = CAMERA_ERROR_NONE;
2730 camera_cli_s *pc = (camera_cli_s *)camera;
2731 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2733 if (!pc || !pc->cb_info) {
2734 LOGE("NULL handle");
2735 return CAMERA_ERROR_INVALID_PARAMETER;
2740 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2743 LOGE("error is occurred 0x%x", ret);
2747 LOGD("ret : %d", ret);
2753 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)
2755 int ret = CAMERA_ERROR_NONE;
2756 camera_cli_s *pc = (camera_cli_s *)camera;
2757 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2758 camera_msg_param param;
2761 if (!pc || !pc->cb_info) {
2762 LOGE("NULL handle");
2763 return CAMERA_ERROR_INVALID_PARAMETER;
2768 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2769 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2771 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2772 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2774 value = (count << 16) | interval;
2775 CAMERA_MSG_PARAM_SET(param, INT, value);
2777 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2779 LOGD("ret : 0x%x", ret);
2785 int camera_stop_continuous_capture(camera_h camera)
2787 int ret = CAMERA_ERROR_NONE;
2788 camera_cli_s *pc = (camera_cli_s *)camera;
2789 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2791 if (!pc || !pc->cb_info) {
2792 LOGE("NULL handle");
2793 return CAMERA_ERROR_INVALID_PARAMETER;
2798 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2800 LOGD("ret : 0x%x", ret);
2806 bool camera_is_supported_face_detection(camera_h camera)
2808 int ret = CAMERA_ERROR_NONE;
2809 camera_cli_s *pc = (camera_cli_s *)camera;
2810 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2812 if (!pc || !pc->cb_info) {
2813 LOGE("NULL handle");
2814 return CAMERA_ERROR_INVALID_PARAMETER;
2819 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2822 LOGE("error is occurred 0x%x", ret);
2826 LOGD("ret : %d", ret);
2832 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2834 int ret = CAMERA_ERROR_NONE;
2835 camera_cli_s *pc = (camera_cli_s *)camera;
2836 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2838 if (!pc || !pc->cb_info) {
2839 LOGE("NULL handle");
2840 return CAMERA_ERROR_INVALID_PARAMETER;
2845 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2848 LOGE("error is occurred 0x%x", ret);
2852 LOGD("ret : %d", ret);
2858 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2860 int ret = CAMERA_ERROR_NONE;
2861 camera_cli_s *pc = (camera_cli_s *)camera;
2862 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2864 if (!pc || !pc->cb_info) {
2865 LOGE("NULL handle");
2866 return CAMERA_ERROR_INVALID_PARAMETER;
2871 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2874 LOGE("error is occurred 0x%x", ret);
2878 LOGD("ret : %d", ret);
2883 int camera_get_device_count(camera_h camera, int *device_count)
2885 int ret = CAMERA_ERROR_NONE;
2886 camera_cli_s *pc = (camera_cli_s *)camera;
2887 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2889 if (!pc || !pc->cb_info) {
2890 LOGE("NULL handle");
2891 return CAMERA_ERROR_INVALID_PARAMETER;
2896 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2898 if (ret == CAMERA_ERROR_NONE)
2899 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2901 LOGD("ret : 0x%x", ret);
2906 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2908 int ret = CAMERA_ERROR_NONE;
2909 camera_cli_s *pc = (camera_cli_s *)camera;
2910 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2912 if (!pc || !pc->cb_info) {
2913 LOGE("NULL handle");
2914 return CAMERA_ERROR_INVALID_PARAMETER;
2919 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2920 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2922 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2924 LOGD("ret : 0x%x", ret);
2929 int camera_stop_face_detection(camera_h camera)
2931 int ret = CAMERA_ERROR_NONE;
2932 camera_cli_s *pc = (camera_cli_s *)camera;
2933 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
2935 if (!pc || !pc->cb_info) {
2936 LOGE("NULL handle");
2937 return CAMERA_ERROR_INVALID_PARAMETER;
2942 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2944 LOGD("ret : 0x%x", ret);
2949 int camera_get_state(camera_h camera, camera_state_e *state)
2951 int ret = CAMERA_ERROR_NONE;
2952 camera_cli_s *pc = (camera_cli_s *)camera;
2953 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
2955 if (!pc || !pc->cb_info || !state) {
2956 LOGE("NULL pointer %p %p", pc, state);
2957 return CAMERA_ERROR_INVALID_PARAMETER;
2962 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2964 if (ret == CAMERA_ERROR_NONE)
2965 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
2967 LOGD("ret : 0x%x", ret);
2972 int camera_start_focusing(camera_h camera, bool continuous)
2974 int ret = CAMERA_ERROR_NONE;
2975 camera_cli_s *pc = (camera_cli_s *)camera;
2976 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
2977 camera_msg_param param;
2978 int is_continuous = (int)continuous;
2980 if (!pc || !pc->cb_info) {
2981 LOGE("NULL handle");
2982 return CAMERA_ERROR_INVALID_PARAMETER;
2987 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
2989 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2991 LOGD("ret : 0x%x", ret);
2996 int camera_cancel_focusing(camera_h camera)
2998 int ret = CAMERA_ERROR_NONE;
2999 camera_cli_s *pc = (camera_cli_s *)camera;
3000 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3002 if (!pc || !pc->cb_info) {
3003 LOGE("NULL handle");
3004 return CAMERA_ERROR_INVALID_PARAMETER;
3007 LOGD("Enter, remote_handle : %x", pc->remote_handle);
3009 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3011 LOGD("ret : 0x%x", ret);
3016 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3018 int ret = CAMERA_ERROR_NONE;
3019 void *set_display_handle = NULL;
3020 Evas_Object *obj = NULL;
3021 const char *object_type = NULL;
3022 camera_cli_s *pc = (camera_cli_s *)camera;
3023 camera_cb_info_s *cb_info = NULL;
3024 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3025 camera_state_e current_state = CAMERA_STATE_NONE;
3026 camera_msg_param param;
3030 if (!pc || !pc->cb_info) {
3031 LOGE("NULL handle");
3032 return CAMERA_ERROR_INVALID_PARAMETER;
3035 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
3036 LOGE("invalid type %d", type);
3037 return CAMERA_ERROR_INVALID_PARAMETER;
3040 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
3041 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
3042 return CAMERA_ERROR_INVALID_PARAMETER;
3045 cb_info = (camera_cb_info_s *)pc->cb_info;
3047 ret = camera_get_state(camera, ¤t_state);
3048 if (ret != CAMERA_ERROR_NONE) {
3049 LOGE("failed to get current state 0x%x", ret);
3053 if (current_state != CAMERA_STATE_CREATED) {
3054 LOGE("INVALID_STATE : current %d", current_state);
3055 return CAMERA_ERROR_INVALID_STATE;
3058 LOGD("Enter - display : %p", display);
3060 if (type == CAMERA_DISPLAY_TYPE_NONE) {
3061 set_display_handle = 0;
3062 LOGD("display type NONE");
3064 obj = (Evas_Object *)display;
3065 object_type = evas_object_type_get(obj);
3067 if (type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
3068 /* get wayland parent id */
3069 if (_camera_get_wl_info(obj, &pc->wl_info) != CAMERA_ERROR_NONE) {
3070 LOGE("failed to get wayland info");
3071 return CAMERA_ERROR_INVALID_OPERATION;
3074 set_display_handle = (void *)&pc->wl_info;
3075 LOGD("display type OVERLAY : handle %p", set_display_handle);
3076 } else if (type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
3077 /* evas object surface */
3078 set_display_handle = (void *)display;
3079 LOGD("display type EVAS : handle %p", set_display_handle);
3081 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3082 g_mutex_lock(&cb_info->evas_mutex);
3084 if (cb_info->evas_info) {
3085 LOGW("destroy existed evas renderer %p", cb_info->evas_info);
3086 ret = mm_evas_renderer_destroy(&cb_info->evas_info);
3087 if (ret != MM_ERROR_NONE) {
3088 LOGE("failed to destroy evas renderer %p", cb_info->evas_info);
3089 g_mutex_unlock(&cb_info->evas_mutex);
3090 return CAMERA_ERROR_INVALID_OPERATION;
3094 /* create evas renderer */
3095 ret = mm_evas_renderer_create(&cb_info->evas_info, (Evas_Object *)set_display_handle);
3096 if (ret == MM_ERROR_NONE) {
3097 camera_flip_e flip = CAMERA_FLIP_NONE;
3098 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3099 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3106 camera_get_display_flip(camera, &flip);
3107 camera_get_display_mode(camera, &mode);
3108 camera_get_display_rotation(camera, &rotation);
3109 camera_is_display_visible(camera, &visible);
3110 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3112 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
3113 flip, mode, rotation, visible, x, y, width, height);
3115 ret = mm_evas_renderer_set_flip(cb_info->evas_info, flip);
3116 ret |= mm_evas_renderer_set_geometry(cb_info->evas_info, mode);
3117 ret |= mm_evas_renderer_set_rotation(cb_info->evas_info, rotation);
3118 ret |= mm_evas_renderer_set_visible(cb_info->evas_info, visible);
3120 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
3121 ret |= mm_evas_renderer_set_roi_area(cb_info->evas_info, x, y, width, height);
3124 g_mutex_unlock(&cb_info->evas_mutex);
3126 if (ret != MM_ERROR_NONE) {
3127 LOGE("mm_evas_renderer error 0x%x", ret);
3128 return CAMERA_ERROR_INVALID_OPERATION;
3130 #else /* TIZEN_FEATURE_EVAS_RENDERER */
3131 LOGE("EVAS surface is not supported");
3132 return CAMERA_ERROR_NOT_SUPPORTED;
3133 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3135 LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type);
3136 return CAMERA_ERROR_INVALID_PARAMETER;
3139 LOGE("failed to get evas object type from %p", obj);
3140 return CAMERA_ERROR_INVALID_PARAMETER;
3144 pc->display_handle = (intptr_t)set_display_handle;
3146 if (type == CAMERA_DISPLAY_TYPE_OVERLAY) {
3149 length = sizeof(camera_wl_info_s) / sizeof(int) + \
3150 (sizeof(camera_wl_info_s) % sizeof(int) ? 1 : 0);
3152 msg = muse_core_msg_json_factory_new(api,
3153 MUSE_TYPE_INT, "type", type,
3154 MUSE_TYPE_ARRAY, "wl_info", length, (int *)&pc->wl_info,
3157 LOGE("msg creation failed: api %d", api);
3158 return CAMERA_ERROR_OUT_OF_MEMORY;
3161 if (pc->cb_info->is_server_connected) {
3162 g_mutex_lock(&pc->cb_info->fd_lock);
3163 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
3164 g_mutex_unlock(&pc->cb_info->fd_lock);
3168 LOGE("message send failed");
3169 ret = CAMERA_ERROR_INVALID_OPERATION;
3171 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
3174 muse_core_msg_json_factory_free(msg);
3176 LOGD("wayland parent id : %d, window %d,%d,%dx%d",
3177 pc->wl_info.parent_id, pc->wl_info.window_x, pc->wl_info.window_y,
3178 pc->wl_info.window_width, pc->wl_info.window_height);
3180 CAMERA_MSG_PARAM_SET(param, INT, type);
3182 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3185 if (ret != CAMERA_ERROR_NONE)
3186 LOGE("set display error 0x%x", ret);
3187 else if (type == CAMERA_DISPLAY_TYPE_EVAS)
3188 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3194 int camera_set_preview_resolution(camera_h camera, int width, int height)
3196 int ret = CAMERA_ERROR_NONE;
3197 camera_state_e current_state = CAMERA_STATE_NONE;
3198 camera_cli_s *pc = (camera_cli_s *)camera;
3199 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3200 camera_msg_param param;
3203 if (!pc || !pc->cb_info) {
3204 LOGE("NULL handle");
3205 return CAMERA_ERROR_INVALID_PARAMETER;
3208 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3209 ret = camera_get_state(camera, ¤t_state);
3210 if (ret != CAMERA_ERROR_NONE) {
3211 LOGE("failed to get current state 0x%x", ret);
3215 if (current_state == CAMERA_STATE_PREVIEW) {
3216 ret = _camera_stop_evas_rendering(camera, true);
3217 if (ret != CAMERA_ERROR_NONE)
3222 value = (width << 16) | height;
3223 CAMERA_MSG_PARAM_SET(param, INT, value);
3225 LOGD("%dx%d -> 0x%x", width, height, value);
3227 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3229 LOGD("ret : 0x%x", ret);
3231 if (current_state == CAMERA_STATE_PREVIEW) {
3232 LOGW("restart evas rendering");
3233 _camera_start_evas_rendering(camera);
3240 int camera_set_capture_resolution(camera_h camera, int width, int height)
3242 int ret = CAMERA_ERROR_NONE;
3243 camera_cli_s *pc = (camera_cli_s *)camera;
3244 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3245 camera_msg_param param;
3248 if (!pc || !pc->cb_info) {
3249 LOGE("NULL handle");
3250 return CAMERA_ERROR_INVALID_PARAMETER;
3255 value = (width << 16) | height;
3256 CAMERA_MSG_PARAM_SET(param, INT, value);
3258 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3260 LOGD("ret : 0x%x", ret);
3266 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3268 int ret = CAMERA_ERROR_NONE;
3269 int set_format = (int)format;
3270 camera_cli_s *pc = (camera_cli_s *)camera;
3271 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3272 camera_msg_param param;
3274 if (!pc || !pc->cb_info) {
3275 LOGE("NULL handle");
3276 return CAMERA_ERROR_INVALID_PARAMETER;
3279 LOGD("Enter - format %d", set_format);
3281 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3283 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3285 LOGD("ret : 0x%x", ret);
3291 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3293 int ret = CAMERA_ERROR_NONE;
3294 int set_format = (int)format;
3295 camera_msg_param param;
3296 camera_cli_s *pc = (camera_cli_s *)camera;
3297 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3299 if (!pc || !pc->cb_info) {
3300 LOGE("NULL handle");
3301 return CAMERA_ERROR_INVALID_PARAMETER;
3304 LOGD("Enter - capture_format %d", set_format);
3306 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3308 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3310 LOGD("ret : 0x%x", ret);
3316 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3318 int ret = CAMERA_ERROR_NONE;
3319 camera_cli_s *pc = (camera_cli_s *)camera;
3320 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3322 if (!pc || !pc->cb_info || !width || !height) {
3323 LOGE("NULL pointer %p %p %p", pc, width, height);
3324 return CAMERA_ERROR_INVALID_PARAMETER;
3329 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3331 if (ret == CAMERA_ERROR_NONE) {
3332 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3333 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3336 LOGD("ret : 0x%x", ret);
3342 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3344 int ret = CAMERA_ERROR_NONE;
3345 int set_rotation = (int)rotation;
3346 camera_cli_s *pc = (camera_cli_s *)camera;
3347 camera_msg_param param;
3349 if (!pc || !pc->cb_info) {
3350 LOGE("NULL handle");
3351 return CAMERA_ERROR_INVALID_PARAMETER;
3354 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3355 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3356 g_mutex_lock(&pc->cb_info->evas_mutex);
3358 ret = mm_evas_renderer_set_rotation(pc->cb_info->evas_info, rotation);
3360 g_mutex_unlock(&pc->cb_info->evas_mutex);
3362 if (ret != MM_ERROR_NONE) {
3363 LOGE("failed to set rotation for evas surface 0x%x", ret);
3364 return CAMERA_ERROR_INVALID_OPERATION;
3367 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3369 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3371 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3377 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3379 int ret = CAMERA_ERROR_NONE;
3380 camera_cli_s *pc = (camera_cli_s *)camera;
3382 if (!pc || !pc->cb_info || !rotation) {
3383 LOGE("NULL pointer %p %p", pc, rotation);
3384 return CAMERA_ERROR_INVALID_PARAMETER;
3387 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3389 if (ret == CAMERA_ERROR_NONE)
3390 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3396 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3398 int ret = CAMERA_ERROR_NONE;
3399 int set_flip = (int)flip;
3400 camera_cli_s *pc = (camera_cli_s *)camera;
3401 camera_msg_param param;
3403 if (!pc || !pc->cb_info) {
3404 LOGE("NULL handle");
3405 return CAMERA_ERROR_INVALID_PARAMETER;
3408 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3409 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3410 g_mutex_lock(&pc->cb_info->evas_mutex);
3412 ret = mm_evas_renderer_set_flip(pc->cb_info->evas_info, flip);
3414 g_mutex_unlock(&pc->cb_info->evas_mutex);
3416 if (ret != MM_ERROR_NONE) {
3417 LOGE("failed to set flip for evas surface 0x%x", ret);
3418 return CAMERA_ERROR_INVALID_OPERATION;
3421 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3423 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3425 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3431 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3433 int ret = CAMERA_ERROR_NONE;
3434 camera_cli_s *pc = (camera_cli_s *)camera;
3436 if (!pc || !pc->cb_info || !flip) {
3437 LOGE("NULL pointer %p %p", pc, flip);
3438 return CAMERA_ERROR_INVALID_PARAMETER;
3441 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3443 if (ret == CAMERA_ERROR_NONE)
3444 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3450 int camera_set_display_visible(camera_h camera, bool visible)
3452 int ret = CAMERA_ERROR_NONE;
3453 int set_visible = (int)visible;
3454 camera_cli_s *pc = (camera_cli_s *)camera;
3455 camera_msg_param param;
3457 if (!pc || !pc->cb_info) {
3458 LOGE("NULL handle");
3459 return CAMERA_ERROR_INVALID_PARAMETER;
3462 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3463 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3464 g_mutex_lock(&pc->cb_info->evas_mutex);
3466 ret = mm_evas_renderer_set_visible(pc->cb_info->evas_info, visible);
3468 g_mutex_unlock(&pc->cb_info->evas_mutex);
3470 if (ret != MM_ERROR_NONE) {
3471 LOGE("failed to set visible for evas surface 0x%x", ret);
3472 return CAMERA_ERROR_INVALID_OPERATION;
3475 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3477 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3479 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3485 int camera_is_display_visible(camera_h camera, bool *visible)
3487 int ret = CAMERA_ERROR_NONE;
3488 camera_cli_s *pc = (camera_cli_s *)camera;
3490 if (!pc || !pc->cb_info || !visible) {
3491 LOGE("NULL pointer %p %p", pc, visible);
3492 return CAMERA_ERROR_INVALID_PARAMETER;
3495 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3497 if (ret == CAMERA_ERROR_NONE)
3498 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3504 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3506 int ret = CAMERA_ERROR_NONE;
3507 int set_mode = (int)mode;
3508 camera_cli_s *pc = (camera_cli_s *)camera;
3509 camera_msg_param param;
3511 if (!pc || !pc->cb_info) {
3512 LOGE("NULL handle");
3513 return CAMERA_ERROR_INVALID_PARAMETER;
3516 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3517 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3518 g_mutex_lock(&pc->cb_info->evas_mutex);
3520 ret = mm_evas_renderer_set_geometry(pc->cb_info->evas_info, mode);
3522 g_mutex_unlock(&pc->cb_info->evas_mutex);
3524 if (ret != MM_ERROR_NONE) {
3525 LOGE("failed to set geometry for evas surface 0x%x", ret);
3526 return CAMERA_ERROR_INVALID_OPERATION;
3529 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3531 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3533 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3539 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3541 int ret = CAMERA_ERROR_NONE;
3542 camera_cli_s *pc = (camera_cli_s *)camera;
3544 if (!pc || !pc->cb_info || !mode) {
3545 LOGE("NULL pointer %p %p", pc, mode);
3546 return CAMERA_ERROR_INVALID_PARAMETER;
3549 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3551 if (ret == CAMERA_ERROR_NONE)
3552 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3558 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3560 int ret = CAMERA_ERROR_NONE;
3561 int set_hint = (int)hint;
3562 camera_cli_s *pc = (camera_cli_s *)camera;
3563 camera_msg_param param;
3565 if (!pc || !pc->cb_info) {
3566 LOGE("NULL handle");
3567 return CAMERA_ERROR_INVALID_PARAMETER;
3570 LOGD("Enter - hint %d", set_hint);
3572 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3574 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3580 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3582 int ret = CAMERA_ERROR_NONE;
3583 camera_cli_s *pc = (camera_cli_s *)camera;
3584 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3586 if (!pc || !pc->cb_info || !hint) {
3587 LOGE("NULL pointer %p %p", pc, hint);
3588 return CAMERA_ERROR_INVALID_PARAMETER;
3591 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3593 if (ret == CAMERA_ERROR_NONE) {
3594 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3595 LOGD("display reuse hint %d", *hint);
3602 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3604 int ret = CAMERA_ERROR_NONE;
3605 camera_cli_s *pc = (camera_cli_s *)camera;
3606 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3608 if (!pc || !pc->cb_info || !width || !height) {
3609 LOGE("NULL pointer %p %p %p", pc, width, height);
3610 return CAMERA_ERROR_INVALID_PARAMETER;
3615 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3617 if (ret == CAMERA_ERROR_NONE) {
3618 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3619 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3622 LOGD("ret : 0x%x", ret);
3628 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3630 int ret = CAMERA_ERROR_NONE;
3631 camera_cli_s *pc = (camera_cli_s *)camera;
3632 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3634 if (!pc || !pc->cb_info || !format) {
3635 LOGE("NULL pointer %p %p", pc, format);
3636 return CAMERA_ERROR_INVALID_PARAMETER;
3641 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3643 if (ret == CAMERA_ERROR_NONE)
3644 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3646 LOGD("ret : 0x%x", ret);
3652 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3654 int ret = CAMERA_ERROR_NONE;
3655 camera_cli_s *pc = (camera_cli_s *)camera;
3656 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3658 if (!pc || !pc->cb_info || !format) {
3659 LOGE("NULL pointer %p %p", pc, format);
3660 return CAMERA_ERROR_INVALID_PARAMETER;
3665 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3667 if (ret == CAMERA_ERROR_NONE)
3668 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3670 LOGD("ret : 0x%x", ret);
3676 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3678 int ret = CAMERA_ERROR_NONE;
3679 camera_cli_s *pc = (camera_cli_s *)camera;
3680 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3682 if (!pc || !pc->cb_info || !facing_direction) {
3683 LOGE("NULL pointer %p %p", pc, facing_direction);
3684 return CAMERA_ERROR_INVALID_PARAMETER;
3689 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3691 if (ret == CAMERA_ERROR_NONE)
3692 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3694 LOGD("ret : 0x%x", ret);
3700 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3702 int ret = CAMERA_ERROR_NONE;
3703 camera_cli_s *pc = (camera_cli_s *)camera;
3704 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3706 if (!pc || !pc->cb_info || !callback) {
3707 LOGE("NULL pointer %p %p", pc, callback);
3708 return CAMERA_ERROR_INVALID_PARAMETER;
3713 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3715 if (ret == CAMERA_ERROR_NONE) {
3716 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3717 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3718 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3721 LOGD("ret : 0x%x", ret);
3727 int camera_unset_preview_cb(camera_h camera)
3729 int ret = CAMERA_ERROR_NONE;
3730 camera_cli_s *pc = (camera_cli_s *)camera;
3731 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3733 if (!pc || !pc->cb_info) {
3734 LOGE("NULL handle");
3735 return CAMERA_ERROR_INVALID_PARAMETER;
3740 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3741 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3743 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3745 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3747 LOGD("ret : 0x%x", ret);
3753 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3755 int ret = CAMERA_ERROR_NONE;
3756 camera_cli_s *pc = (camera_cli_s *)camera;
3757 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3759 if (!pc || !pc->cb_info) {
3760 LOGE("NULL handle");
3761 return CAMERA_ERROR_INVALID_PARAMETER;
3764 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3765 LOGE("NOT SUPPORTED");
3766 return CAMERA_ERROR_NOT_SUPPORTED;
3769 if (callback == NULL) {
3770 LOGE("NULL callback");
3771 return CAMERA_ERROR_INVALID_PARAMETER;
3776 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3778 if (ret == CAMERA_ERROR_NONE) {
3779 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3780 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3783 LOGD("ret : 0x%x", ret);
3789 int camera_unset_media_packet_preview_cb(camera_h camera)
3791 int ret = CAMERA_ERROR_NONE;
3792 camera_cli_s *pc = (camera_cli_s *)camera;
3793 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3795 if (!pc || !pc->cb_info) {
3796 LOGE("NULL handle");
3797 return CAMERA_ERROR_INVALID_PARAMETER;
3802 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3803 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3805 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3807 LOGD("ret : 0x%x", ret);
3813 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3815 int ret = CAMERA_ERROR_NONE;
3816 camera_cli_s *pc = (camera_cli_s *)camera;
3817 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3819 if (!pc || !pc->cb_info || !callback) {
3820 LOGE("NULL pointer %p %p", pc, callback);
3821 return CAMERA_ERROR_INVALID_PARAMETER;
3826 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3828 if (ret == CAMERA_ERROR_NONE) {
3829 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3830 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3833 LOGD("ret : 0x%x", ret);
3839 int camera_unset_state_changed_cb(camera_h camera)
3841 int ret = CAMERA_ERROR_NONE;
3842 camera_cli_s *pc = (camera_cli_s *)camera;
3843 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3845 if (!pc || !pc->cb_info) {
3846 LOGE("NULL handle");
3847 return CAMERA_ERROR_INVALID_PARAMETER;
3852 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3853 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3855 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3857 LOGD("ret : 0x%x", ret);
3863 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3865 int ret = CAMERA_ERROR_NONE;
3866 camera_cli_s *pc = (camera_cli_s *)camera;
3867 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3869 if (!pc || !pc->cb_info || !callback) {
3870 LOGE("NULL pointer %p %p", pc, callback);
3871 return CAMERA_ERROR_INVALID_PARAMETER;
3876 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3878 if (ret == CAMERA_ERROR_NONE) {
3879 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3880 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3883 LOGD("ret : 0x%x", ret);
3889 int camera_unset_interrupted_cb(camera_h camera)
3891 int ret = CAMERA_ERROR_NONE;
3892 camera_cli_s *pc = (camera_cli_s *)camera;
3893 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3895 if (!pc || !pc->cb_info) {
3896 LOGE("NULL handle");
3897 return CAMERA_ERROR_INVALID_PARAMETER;
3902 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3903 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3905 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3907 LOGD("ret : 0x%x", ret);
3913 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
3915 int ret = CAMERA_ERROR_NONE;
3916 camera_cli_s *pc = (camera_cli_s *)camera;
3917 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3919 if (!pc || !pc->cb_info || !callback) {
3920 LOGE("NULL pointer %p %p", pc, callback);
3921 return CAMERA_ERROR_INVALID_PARAMETER;
3926 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3928 if (ret == CAMERA_ERROR_NONE) {
3929 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3930 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3933 LOGD("ret : 0x%x", ret);
3939 int camera_unset_focus_changed_cb(camera_h camera)
3941 int ret = CAMERA_ERROR_NONE;
3942 camera_cli_s *pc = (camera_cli_s *)camera;
3943 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
3945 if (!pc || !pc->cb_info) {
3946 LOGE("NULL handle");
3947 return CAMERA_ERROR_INVALID_PARAMETER;
3952 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3953 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3955 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3957 LOGD("ret : 0x%x", ret);
3963 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
3965 int ret = CAMERA_ERROR_NONE;
3966 camera_cli_s *pc = (camera_cli_s *)camera;
3967 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
3969 if (!pc || !pc->cb_info || !callback) {
3970 LOGE("NULL pointer %p %p", pc, callback);
3971 return CAMERA_ERROR_INVALID_PARAMETER;
3976 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3978 if (ret == CAMERA_ERROR_NONE) {
3979 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
3980 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
3983 LOGD("ret : 0x%x", ret);
3989 int camera_unset_error_cb(camera_h camera)
3991 int ret = CAMERA_ERROR_NONE;
3992 camera_cli_s *pc = (camera_cli_s *)camera;
3993 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
3995 if (!pc || !pc->cb_info) {
3996 LOGE("NULL handle");
3997 return CAMERA_ERROR_INVALID_PARAMETER;
4002 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4003 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4005 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4007 LOGD("ret : 0x%x", ret);
4013 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4015 int ret = CAMERA_ERROR_NONE;
4016 camera_cli_s *pc = (camera_cli_s *)camera;
4017 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4019 if (!pc || !pc->cb_info || !foreach_cb) {
4020 LOGE("NULL pointer %p %p", pc, foreach_cb);
4021 return CAMERA_ERROR_INVALID_PARAMETER;
4026 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4027 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4029 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4031 LOGD("ret : 0x%x", ret);
4037 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4039 int ret = CAMERA_ERROR_NONE;
4040 camera_cli_s *pc = (camera_cli_s *)camera;
4041 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4043 if (!pc || !pc->cb_info || !foreach_cb) {
4044 LOGE("NULL pointer %p %p", pc, foreach_cb);
4045 return CAMERA_ERROR_INVALID_PARAMETER;
4050 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4051 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4053 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4055 LOGD("ret : 0x%x", ret);
4061 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4063 int ret = CAMERA_ERROR_NONE;
4064 camera_cli_s *pc = (camera_cli_s *)camera;
4065 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4067 if (!pc || !pc->cb_info || !foreach_cb) {
4068 LOGE("NULL pointer %p %p", pc, foreach_cb);
4069 return CAMERA_ERROR_INVALID_PARAMETER;
4074 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4075 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4077 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4079 LOGD("ret : 0x%x", ret);
4085 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4087 int ret = CAMERA_ERROR_NONE;
4088 camera_cli_s *pc = (camera_cli_s *)camera;
4089 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4091 if (!pc || !pc->cb_info || !foreach_cb) {
4092 LOGE("NULL pointer %p %p", pc, foreach_cb);
4093 return CAMERA_ERROR_INVALID_PARAMETER;
4098 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4099 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4101 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4103 LOGD("ret : 0x%x", ret);
4109 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4111 int ret = CAMERA_ERROR_NONE;
4112 camera_cli_s *pc = (camera_cli_s *)camera;
4113 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4115 if (!pc || !pc->cb_info || !width || !height) {
4116 LOGE("NULL pointer %p %p %p", pc, width, height);
4117 return CAMERA_ERROR_INVALID_PARAMETER;
4121 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4123 if (ret == CAMERA_ERROR_NONE) {
4124 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4125 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4128 LOGD("ret : 0x%x", ret);
4134 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4136 int ret = CAMERA_ERROR_NONE;
4137 camera_cli_s *pc = (camera_cli_s *)camera;
4138 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4140 if (!pc || !pc->cb_info || !angle) {
4141 LOGE("NULL pointer %p %p", pc, angle);
4142 return CAMERA_ERROR_INVALID_PARAMETER;
4147 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4149 if (ret == CAMERA_ERROR_NONE)
4150 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4152 LOGD("ret : 0x%x", ret);
4158 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4160 int ret = CAMERA_ERROR_NONE;
4161 camera_cli_s *pc = (camera_cli_s *)camera;
4162 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4163 camera_msg_param param;
4164 int set_mode = (int)mode;
4166 if (!pc || !pc->cb_info) {
4167 LOGE("NULL handle");
4168 return CAMERA_ERROR_INVALID_PARAMETER;
4173 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4175 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4177 LOGD("ret : 0x%x", ret);
4183 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4185 int ret = CAMERA_ERROR_NONE;
4186 camera_cli_s *pc = (camera_cli_s *)camera;
4187 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4189 if (!pc || !pc->cb_info || !mode) {
4190 LOGE("NULL pointer %p %p", pc, mode);
4191 return CAMERA_ERROR_INVALID_PARAMETER;
4196 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4198 if (ret == CAMERA_ERROR_NONE)
4199 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4201 LOGD("ret : 0x%x", ret);
4207 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4209 int ret = CAMERA_ERROR_NONE;
4210 camera_cli_s *pc = (camera_cli_s *)camera;
4211 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4213 if (!pc || !pc->cb_info || !foreach_cb) {
4214 LOGE("NULL pointer %p %p", pc, foreach_cb);
4215 return CAMERA_ERROR_INVALID_PARAMETER;
4220 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4221 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4223 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4225 LOGD("Finish, return :%x", ret);
4231 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4233 int ret = CAMERA_ERROR_NONE;
4234 camera_cli_s *pc = (camera_cli_s *)camera;
4235 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4236 camera_msg_param param;
4237 int set_fps = (int)fps;
4239 if (!pc || !pc->cb_info) {
4240 LOGE("NULL handle");
4241 return CAMERA_ERROR_INVALID_PARAMETER;
4246 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4248 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4250 LOGD("ret : 0x%x", ret);
4256 int camera_attr_set_image_quality(camera_h camera, int quality)
4258 int ret = CAMERA_ERROR_NONE;
4259 camera_cli_s *pc = (camera_cli_s *)camera;
4260 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4261 camera_msg_param param;
4263 if (!pc || !pc->cb_info) {
4264 LOGE("NULL handle");
4265 return CAMERA_ERROR_INVALID_PARAMETER;
4270 CAMERA_MSG_PARAM_SET(param, INT, quality);
4272 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4274 LOGD("ret : 0x%x", ret);
4280 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4282 int ret = CAMERA_ERROR_NONE;
4283 camera_cli_s *pc = (camera_cli_s *)camera;
4284 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4286 if (!pc || !pc->cb_info || !fps) {
4287 LOGE("NULL pointer %p %p", pc, fps);
4288 return CAMERA_ERROR_INVALID_PARAMETER;
4293 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4295 if (ret == CAMERA_ERROR_NONE)
4296 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4298 LOGD("ret : 0x%x", ret);
4304 int camera_attr_get_image_quality(camera_h camera, int *quality)
4306 int ret = CAMERA_ERROR_NONE;
4307 camera_cli_s *pc = (camera_cli_s *)camera;
4308 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4310 if (!pc || !pc->cb_info || !quality) {
4311 LOGE("NULL pointer %p %p", pc, quality);
4312 return CAMERA_ERROR_INVALID_PARAMETER;
4317 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4319 if (ret == CAMERA_ERROR_NONE)
4320 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4322 LOGD("ret : 0x%x", ret);
4328 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4330 int ret = CAMERA_ERROR_NONE;
4331 camera_cli_s *pc = (camera_cli_s *)camera;
4332 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4334 if (!pc || !pc->cb_info || !bitrate) {
4335 LOGE("NULL pointer %p %p", pc, bitrate);
4336 return CAMERA_ERROR_INVALID_PARAMETER;
4341 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4343 if (ret == CAMERA_ERROR_NONE)
4344 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4346 LOGD("ret : 0x%x", ret);
4352 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4354 int ret = CAMERA_ERROR_NONE;
4355 camera_cli_s *pc = (camera_cli_s *)camera;
4356 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4357 camera_msg_param param;
4358 int set_bitrate = bitrate;
4360 if (!pc || !pc->cb_info) {
4361 LOGE("NULL handle");
4362 return CAMERA_ERROR_INVALID_PARAMETER;
4367 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4369 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4371 LOGD("ret : 0x%x", ret);
4377 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4379 int ret = CAMERA_ERROR_NONE;
4380 camera_cli_s *pc = (camera_cli_s *)camera;
4381 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4383 if (!pc || !pc->cb_info || !interval) {
4384 LOGE("NULL pointer %p %p", pc, interval);
4385 return CAMERA_ERROR_INVALID_PARAMETER;
4390 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4392 if (ret == CAMERA_ERROR_NONE)
4393 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4395 LOGD("ret : 0x%x", ret);
4401 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4403 int ret = CAMERA_ERROR_NONE;
4404 camera_cli_s *pc = (camera_cli_s *)camera;
4405 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4406 camera_msg_param param;
4407 int set_gop_interval = interval;
4409 if (!pc || !pc->cb_info) {
4410 LOGE("NULL handle");
4411 return CAMERA_ERROR_INVALID_PARAMETER;
4416 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4418 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4420 LOGD("ret : 0x%x", ret);
4426 int camera_attr_set_zoom(camera_h camera, int zoom)
4428 int ret = CAMERA_ERROR_NONE;
4429 camera_cli_s *pc = (camera_cli_s *)camera;
4430 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4431 camera_msg_param param;
4433 if (!pc || !pc->cb_info) {
4434 LOGE("NULL handle");
4435 return CAMERA_ERROR_INVALID_PARAMETER;
4438 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4440 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4442 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4444 LOGD("ret : 0x%x", ret);
4450 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4452 int ret = CAMERA_ERROR_NONE;
4453 camera_cli_s *pc = (camera_cli_s *)camera;
4454 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4455 camera_msg_param param;
4456 int set_mode = (int)mode;
4458 if (!pc || !pc->cb_info) {
4459 LOGE("NULL handle");
4460 return CAMERA_ERROR_INVALID_PARAMETER;
4463 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4465 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4467 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4473 int camera_attr_set_af_area(camera_h camera, int x, int y)
4475 int ret = CAMERA_ERROR_NONE;
4476 camera_cli_s *pc = (camera_cli_s *)camera;
4477 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4478 camera_msg_param param;
4481 if (!pc || !pc->cb_info) {
4482 LOGE("NULL handle");
4483 return CAMERA_ERROR_INVALID_PARAMETER;
4486 LOGD("Enter - %d,%d", x, y);
4488 value = (x << 16) | y;
4489 CAMERA_MSG_PARAM_SET(param, INT, value);
4491 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4493 LOGD("ret : 0x%x", ret);
4499 int camera_attr_clear_af_area(camera_h camera)
4501 int ret = CAMERA_ERROR_NONE;
4502 camera_cli_s *pc = (camera_cli_s *)camera;
4503 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4505 if (!pc || !pc->cb_info) {
4506 LOGE("NULL handle");
4507 return CAMERA_ERROR_INVALID_PARAMETER;
4512 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4514 LOGD("ret : 0x%x", ret);
4520 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4522 int ret = CAMERA_ERROR_NONE;
4523 camera_cli_s *pc = (camera_cli_s *)camera;
4524 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4525 camera_msg_param param;
4526 int set_mode = (int)mode;
4528 if (!pc || !pc->cb_info) {
4529 LOGE("NULL handle");
4530 return CAMERA_ERROR_INVALID_PARAMETER;
4535 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4537 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4539 LOGD("ret : 0x%x", ret);
4545 int camera_attr_set_exposure(camera_h camera, int value)
4547 int ret = CAMERA_ERROR_NONE;
4548 camera_cli_s *pc = (camera_cli_s *)camera;
4549 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4550 camera_msg_param param;
4552 if (!pc || !pc->cb_info) {
4553 LOGE("NULL handle");
4554 return CAMERA_ERROR_INVALID_PARAMETER;
4559 CAMERA_MSG_PARAM_SET(param, INT, value);
4561 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4563 LOGD("ret : 0x%x", ret);
4569 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4571 int ret = CAMERA_ERROR_NONE;
4572 camera_cli_s *pc = (camera_cli_s *)camera;
4573 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4574 camera_msg_param param;
4575 int set_iso = (int)iso;
4577 if (!pc || !pc->cb_info) {
4578 LOGE("NULL handle");
4579 return CAMERA_ERROR_INVALID_PARAMETER;
4584 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4586 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4588 LOGD("ret : 0x%x", ret);
4594 int camera_attr_set_brightness(camera_h camera, int level)
4596 int ret = CAMERA_ERROR_NONE;
4597 camera_cli_s *pc = (camera_cli_s *)camera;
4598 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4599 camera_msg_param param;
4601 if (!pc || !pc->cb_info) {
4602 LOGE("NULL handle");
4603 return CAMERA_ERROR_INVALID_PARAMETER;
4608 CAMERA_MSG_PARAM_SET(param, INT, level);
4610 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4612 LOGD("ret : 0x%x", ret);
4618 int camera_attr_set_contrast(camera_h camera, int level)
4620 int ret = CAMERA_ERROR_NONE;
4621 camera_cli_s *pc = (camera_cli_s *)camera;
4622 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4623 camera_msg_param param;
4625 if (!pc || !pc->cb_info) {
4626 LOGE("NULL handle");
4627 return CAMERA_ERROR_INVALID_PARAMETER;
4632 CAMERA_MSG_PARAM_SET(param, INT, level);
4634 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4636 LOGD("ret : 0x%x", ret);
4642 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4644 int ret = CAMERA_ERROR_NONE;
4645 camera_cli_s *pc = (camera_cli_s *)camera;
4646 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4647 camera_msg_param param;
4648 int set_whitebalance = (int)wb;
4650 if (!pc || !pc->cb_info) {
4651 LOGE("NULL handle");
4652 return CAMERA_ERROR_INVALID_PARAMETER;
4657 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4659 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4661 LOGD("ret : 0x%x", ret);
4667 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4669 int ret = CAMERA_ERROR_NONE;
4670 camera_cli_s *pc = (camera_cli_s *)camera;
4671 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4672 camera_msg_param param;
4673 int set_effect = (int)effect;
4675 if (!pc || !pc->cb_info) {
4676 LOGE("NULL handle");
4677 return CAMERA_ERROR_INVALID_PARAMETER;
4682 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4684 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4686 LOGD("ret : 0x%x", ret);
4692 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4694 int ret = CAMERA_ERROR_NONE;
4695 camera_cli_s *pc = (camera_cli_s *)camera;
4696 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4697 camera_msg_param param;
4698 int set_mode = (int)mode;
4700 if (!pc || !pc->cb_info) {
4701 LOGE("NULL handle");
4702 return CAMERA_ERROR_INVALID_PARAMETER;
4707 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4709 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4711 LOGD("ret : 0x%x", ret);
4717 int camera_attr_enable_tag(camera_h camera, bool enable)
4719 int ret = CAMERA_ERROR_NONE;
4720 camera_cli_s *pc = (camera_cli_s *)camera;
4721 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4722 camera_msg_param param;
4723 int set_enable = (int)enable;
4725 if (!pc || !pc->cb_info) {
4726 LOGE("NULL handle");
4727 return CAMERA_ERROR_INVALID_PARAMETER;
4732 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4734 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4736 LOGD("ret : 0x%x", ret);
4742 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4744 int ret = CAMERA_ERROR_NONE;
4745 camera_cli_s *pc = (camera_cli_s *)camera;
4746 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4747 camera_msg_param param;
4749 if (!pc || !pc->cb_info || !description) {
4750 LOGE("NULL pointer %p %p", pc, description);
4751 return CAMERA_ERROR_INVALID_PARAMETER;
4756 CAMERA_MSG_PARAM_SET(param, STRING, description);
4758 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4760 LOGD("ret : 0x%x", ret);
4766 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4768 int ret = CAMERA_ERROR_NONE;
4769 camera_cli_s *pc = (camera_cli_s *)camera;
4770 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4771 camera_msg_param param;
4772 int set_orientation = (int)orientation;
4774 if (!pc || !pc->cb_info) {
4775 LOGE("NULL handle");
4776 return CAMERA_ERROR_INVALID_PARAMETER;
4781 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4783 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4785 LOGD("ret : 0x%x", ret);
4791 int camera_attr_set_tag_software(camera_h camera, const char *software)
4793 int ret = CAMERA_ERROR_NONE;
4794 camera_cli_s *pc = (camera_cli_s *)camera;
4795 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4796 camera_msg_param param;
4798 if (!pc || !pc->cb_info || !software) {
4799 LOGE("NULL pointer %p %p", pc, software);
4800 return CAMERA_ERROR_INVALID_PARAMETER;
4803 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4805 CAMERA_MSG_PARAM_SET(param, STRING, software);
4807 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4809 LOGD("ret : 0x%x", ret);
4815 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4817 int ret = CAMERA_ERROR_NONE;
4818 camera_cli_s *pc = (camera_cli_s *)camera;
4819 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4820 double set_geotag[3] = {latitude, longitude, altitude};
4825 if (!pc || !pc->cb_info) {
4826 LOGE("NULL handle");
4827 return CAMERA_ERROR_INVALID_PARAMETER;
4832 length = sizeof(set_geotag) / sizeof(int) + \
4833 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4835 msg = muse_core_msg_json_factory_new(api,
4836 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4839 LOGE("msg creation failed: api %d", api);
4840 return CAMERA_ERROR_OUT_OF_MEMORY;
4843 if (pc->cb_info->is_server_connected) {
4844 g_mutex_lock(&pc->cb_info->fd_lock);
4845 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
4846 g_mutex_unlock(&pc->cb_info->fd_lock);
4850 LOGE("message send failed");
4851 ret = CAMERA_ERROR_INVALID_OPERATION;
4853 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
4856 muse_core_msg_json_factory_free(msg);
4858 LOGD("ret : 0x%x", ret);
4864 int camera_attr_remove_geotag(camera_h camera)
4866 int ret = CAMERA_ERROR_NONE;
4867 camera_cli_s *pc = (camera_cli_s *)camera;
4868 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4870 if (!pc || !pc->cb_info) {
4871 LOGE("NULL handle");
4872 return CAMERA_ERROR_INVALID_PARAMETER;
4877 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4879 LOGD("ret : 0x%x", ret);
4885 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4887 int ret = CAMERA_ERROR_NONE;
4888 camera_cli_s *pc = (camera_cli_s *)camera;
4889 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
4890 camera_msg_param param;
4891 int set_mode = (int)mode;
4893 if (!pc || !pc->cb_info) {
4894 LOGE("NULL handle");
4895 return CAMERA_ERROR_INVALID_PARAMETER;
4900 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4902 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4904 LOGD("ret : 0x%x", ret);
4910 int camera_attr_get_zoom(camera_h camera, int *zoom)
4912 int ret = CAMERA_ERROR_NONE;
4913 camera_cli_s *pc = (camera_cli_s *)camera;
4914 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4916 if (!pc || !pc->cb_info || !zoom) {
4917 LOGE("NULL pointer %p %p", pc, zoom);
4918 return CAMERA_ERROR_INVALID_PARAMETER;
4923 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4925 if (ret == CAMERA_ERROR_NONE)
4926 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
4928 LOGD("ret : 0x%x", ret);
4934 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
4936 int ret = CAMERA_ERROR_NONE;
4937 camera_cli_s *pc = (camera_cli_s *)camera;
4938 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
4940 if (!pc || !pc->cb_info || !min || !max) {
4941 LOGE("NULL pointer %p %p %p", pc, min, max);
4942 return CAMERA_ERROR_INVALID_PARAMETER;
4947 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4949 if (ret == CAMERA_ERROR_NONE) {
4950 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
4951 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
4954 LOGD("ret : 0x%x", ret);
4960 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
4962 int ret = CAMERA_ERROR_NONE;
4963 camera_cli_s *pc = (camera_cli_s *)camera;
4964 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
4966 if (!pc || !pc->cb_info || !mode) {
4967 LOGE("NULL pointer %p %p", pc, mode);
4968 return CAMERA_ERROR_INVALID_PARAMETER;
4973 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4975 if (ret == CAMERA_ERROR_NONE)
4976 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
4978 LOGD("ret : 0x%x", ret);
4984 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
4986 int ret = CAMERA_ERROR_NONE;
4987 camera_cli_s *pc = (camera_cli_s *)camera;
4988 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
4990 if (!pc || !pc->cb_info || !mode) {
4991 LOGE("NULL pointer %p %p", pc, mode);
4992 return CAMERA_ERROR_INVALID_PARAMETER;
4997 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4999 if (ret == CAMERA_ERROR_NONE)
5000 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5002 LOGD("ret : 0x%x", ret);
5008 int camera_attr_get_exposure(camera_h camera, int *value)
5010 int ret = CAMERA_ERROR_NONE;
5011 camera_cli_s *pc = (camera_cli_s *)camera;
5012 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5014 if (!pc || !pc->cb_info || !value) {
5015 LOGE("NULL pointer %p %p", pc, value);
5016 return CAMERA_ERROR_INVALID_PARAMETER;
5021 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5023 if (ret == CAMERA_ERROR_NONE)
5024 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5026 LOGD("ret : 0x%x", ret);
5032 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5034 int ret = CAMERA_ERROR_NONE;
5035 camera_cli_s *pc = (camera_cli_s *)camera;
5036 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5038 if (!pc || !pc->cb_info || !min || !max) {
5039 LOGE("NULL pointer %p %p %p", pc, min, max);
5040 return CAMERA_ERROR_INVALID_PARAMETER;
5045 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5047 if (ret == CAMERA_ERROR_NONE) {
5048 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5049 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5052 LOGD("ret : 0x%x", ret);
5058 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5060 int ret = CAMERA_ERROR_NONE;
5061 camera_cli_s *pc = (camera_cli_s *)camera;
5062 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5064 if (!pc || !pc->cb_info || !iso) {
5065 LOGE("NULL pointer %p %p", pc, iso);
5066 return CAMERA_ERROR_INVALID_PARAMETER;
5071 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5073 if (ret == CAMERA_ERROR_NONE)
5074 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5076 LOGD("ret : 0x%x", ret);
5082 int camera_attr_get_brightness(camera_h camera, int *level)
5084 int ret = CAMERA_ERROR_NONE;
5085 camera_cli_s *pc = (camera_cli_s *)camera;
5086 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5088 if (!pc || !pc->cb_info || !level) {
5089 LOGE("NULL pointer %p %p", pc, level);
5090 return CAMERA_ERROR_INVALID_PARAMETER;
5095 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5097 if (ret == CAMERA_ERROR_NONE)
5098 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5100 LOGD("ret : 0x%x", ret);
5106 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5108 int ret = CAMERA_ERROR_NONE;
5109 camera_cli_s *pc = (camera_cli_s *)camera;
5110 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5112 if (!pc || !pc->cb_info || !min || !max) {
5113 LOGE("NULL pointer %p %p %p", pc, min, max);
5114 return CAMERA_ERROR_INVALID_PARAMETER;
5119 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5121 if (ret == CAMERA_ERROR_NONE) {
5122 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5123 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5126 LOGD("ret : 0x%x", ret);
5132 int camera_attr_get_contrast(camera_h camera, int *level)
5134 int ret = CAMERA_ERROR_NONE;
5135 camera_cli_s *pc = (camera_cli_s *)camera;
5136 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5138 if (!pc || !pc->cb_info || !level) {
5139 LOGE("NULL pointer %p %p", pc, level);
5140 return CAMERA_ERROR_INVALID_PARAMETER;
5145 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5147 if (ret == CAMERA_ERROR_NONE)
5148 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5150 LOGD("ret : 0x%x", ret);
5156 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5158 int ret = CAMERA_ERROR_NONE;
5159 camera_cli_s *pc = (camera_cli_s *)camera;
5160 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5162 if (!pc || !pc->cb_info || !min || !max) {
5163 LOGE("NULL pointer %p %p %p", pc, min, max);
5164 return CAMERA_ERROR_INVALID_PARAMETER;
5169 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5171 if (ret == CAMERA_ERROR_NONE) {
5172 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5173 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5174 LOGD("min %d, max %d", *min, *max);
5177 LOGD("ret : 0x%x", ret);
5183 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5185 int ret = CAMERA_ERROR_NONE;
5186 camera_cli_s *pc = (camera_cli_s *)camera;
5187 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5189 if (!pc || !pc->cb_info || !wb) {
5190 LOGE("NULL pointer %p %p", pc, wb);
5191 return CAMERA_ERROR_INVALID_PARAMETER;
5196 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5198 if (ret == CAMERA_ERROR_NONE)
5199 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5201 LOGD("ret : 0x%x", ret);
5207 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5209 int ret = CAMERA_ERROR_NONE;
5210 camera_cli_s *pc = (camera_cli_s *)camera;
5211 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5213 if (!pc || !pc->cb_info || !effect) {
5214 LOGE("NULL pointer %p %p", pc, effect);
5215 return CAMERA_ERROR_INVALID_PARAMETER;
5220 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5222 if (ret == CAMERA_ERROR_NONE)
5223 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5225 LOGD("ret : 0x%x", ret);
5231 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5233 int ret = CAMERA_ERROR_NONE;
5234 camera_cli_s *pc = (camera_cli_s *)camera;
5235 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5237 if (!pc || !pc->cb_info || !mode) {
5238 LOGE("NULL pointer %p %p", pc, mode);
5239 return CAMERA_ERROR_INVALID_PARAMETER;
5244 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5246 if (ret == CAMERA_ERROR_NONE)
5247 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5249 LOGD("ret : 0x%x", ret);
5255 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5257 int ret = CAMERA_ERROR_NONE;
5258 camera_cli_s *pc = (camera_cli_s *)camera;
5259 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5261 if (!pc || !pc->cb_info || !enable) {
5262 LOGE("NULL pointer %p %p", pc, enable);
5263 return CAMERA_ERROR_INVALID_PARAMETER;
5268 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5270 if (ret == CAMERA_ERROR_NONE)
5271 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5273 LOGD("ret : 0x%x", ret);
5279 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5281 int ret = CAMERA_ERROR_NONE;
5282 camera_cli_s *pc = (camera_cli_s *)camera;
5283 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5285 if (!pc || !pc->cb_info || !description) {
5286 LOGE("NULL pointer %p %p", pc, description);
5287 return CAMERA_ERROR_INVALID_PARAMETER;
5292 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5294 if (ret == CAMERA_ERROR_NONE)
5295 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5297 LOGD("ret : 0x%x", ret);
5303 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5305 int ret = CAMERA_ERROR_NONE;
5306 camera_cli_s *pc = (camera_cli_s *)camera;
5307 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5309 if (!pc || !pc->cb_info || !orientation) {
5310 LOGE("NULL pointer %p %p", pc, orientation);
5311 return CAMERA_ERROR_INVALID_PARAMETER;
5316 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5318 if (ret == CAMERA_ERROR_NONE)
5319 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5321 LOGD("ret : 0x%x", ret);
5327 int camera_attr_get_tag_software(camera_h camera, char **software)
5329 int ret = CAMERA_ERROR_NONE;
5330 camera_cli_s *pc = (camera_cli_s *)camera;
5331 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5333 if (!pc || !pc->cb_info || !software) {
5334 LOGE("NULL pointer %p %p", pc, software);
5335 return CAMERA_ERROR_INVALID_PARAMETER;
5340 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5342 if (ret == CAMERA_ERROR_NONE)
5343 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5345 LOGD("ret : 0x%x", ret);
5351 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5353 int ret = CAMERA_ERROR_NONE;
5354 camera_cli_s *pc = (camera_cli_s *)camera;
5355 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5357 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5358 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5359 return CAMERA_ERROR_INVALID_PARAMETER;
5364 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5366 if (ret == CAMERA_ERROR_NONE) {
5367 *latitude = pc->cb_info->get_geotag[0];
5368 *longitude = pc->cb_info->get_geotag[1];
5369 *altitude = pc->cb_info->get_geotag[2];
5372 LOGD("ret : 0x%x", ret);
5378 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5380 int ret = CAMERA_ERROR_NONE;
5381 camera_cli_s *pc = (camera_cli_s *)camera;
5382 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5384 if (!pc || !pc->cb_info || !mode) {
5385 LOGE("NULL pointer %p %p", pc, mode);
5386 return CAMERA_ERROR_INVALID_PARAMETER;
5391 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5393 if (ret == CAMERA_ERROR_NONE)
5394 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5396 LOGD("ret : 0x%x", ret);
5402 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5404 int ret = CAMERA_ERROR_NONE;
5405 int get_flash_state = 0;
5408 LOGE("NULL pointer");
5409 return CAMERA_ERROR_INVALID_PARAMETER;
5412 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5413 (int)device, "get_flash_state", &get_flash_state);
5415 if (ret == CAMERA_ERROR_NONE) {
5416 *state = (camera_flash_state_e)get_flash_state;
5417 LOGD("flash state %d", *state);
5419 LOGE("failed 0x%x", ret);
5426 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5428 int ret = CAMERA_ERROR_NONE;
5429 camera_cli_s *pc = (camera_cli_s *)camera;
5430 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5432 if (!pc || !pc->cb_info || !foreach_cb) {
5433 LOGE("NULL pointer %p %p", pc, foreach_cb);
5434 return CAMERA_ERROR_INVALID_PARAMETER;
5439 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5440 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5442 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5444 LOGD("ret : 0x%x", ret);
5450 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5452 int ret = CAMERA_ERROR_NONE;
5453 camera_cli_s *pc = (camera_cli_s *)camera;
5454 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5456 if (!pc || !pc->cb_info || !foreach_cb) {
5457 LOGE("NULL pointer %p %p", pc, foreach_cb);
5458 return CAMERA_ERROR_INVALID_PARAMETER;
5463 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5464 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5466 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5468 LOGD("ret : 0x%x", ret);
5474 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5476 int ret = CAMERA_ERROR_NONE;
5477 camera_cli_s *pc = (camera_cli_s *)camera;
5478 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5480 if (!pc || !pc->cb_info || !foreach_cb) {
5481 LOGE("NULL pointer %p %p", pc, foreach_cb);
5482 return CAMERA_ERROR_INVALID_PARAMETER;
5487 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5488 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5490 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5492 LOGD("ret : 0x%x", ret);
5498 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5500 int ret = CAMERA_ERROR_NONE;
5501 camera_cli_s *pc = (camera_cli_s *)camera;
5502 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5504 if (!pc || !pc->cb_info || !foreach_cb) {
5505 LOGE("NULL pointer %p %p", pc, foreach_cb);
5506 return CAMERA_ERROR_INVALID_PARAMETER;
5511 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5512 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5514 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5516 LOGD("ret : 0x%x", ret);
5522 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5524 int ret = CAMERA_ERROR_NONE;
5525 camera_cli_s *pc = (camera_cli_s *)camera;
5526 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5528 if (!pc || !pc->cb_info || !foreach_cb) {
5529 LOGE("NULL pointer %p %p", pc, foreach_cb);
5530 return CAMERA_ERROR_INVALID_PARAMETER;
5535 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5536 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5538 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5540 LOGD("ret : 0x%x", ret);
5546 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5548 int ret = CAMERA_ERROR_NONE;
5549 camera_cli_s *pc = (camera_cli_s *)camera;
5550 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5552 if (!pc || !pc->cb_info || !foreach_cb) {
5553 LOGE("NULL pointer %p %p", pc, foreach_cb);
5554 return CAMERA_ERROR_INVALID_PARAMETER;
5559 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5560 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5562 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5564 LOGD("ret : 0x%x", ret);
5570 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5572 int ret = CAMERA_ERROR_NONE;
5573 camera_cli_s *pc = (camera_cli_s *)camera;
5574 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5576 if (!pc || !pc->cb_info || !foreach_cb) {
5577 LOGE("NULL pointer %p %p", pc, foreach_cb);
5578 return CAMERA_ERROR_INVALID_PARAMETER;
5583 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5584 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5586 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5588 LOGD("ret : 0x%x", ret);
5594 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5596 int ret = CAMERA_ERROR_NONE;
5597 camera_cli_s *pc = (camera_cli_s *)camera;
5598 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5600 if (!pc || !pc->cb_info || !foreach_cb) {
5601 LOGE("NULL pointer %p %p", pc, foreach_cb);
5602 return CAMERA_ERROR_INVALID_PARAMETER;
5607 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5608 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5610 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5612 LOGD("Enter, handle :%x", pc->remote_handle);
5618 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)
5620 int ret = CAMERA_ERROR_NONE;
5621 camera_cli_s *pc = (camera_cli_s *)camera;
5622 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5623 camera_msg_param param;
5626 if (!pc || !pc->cb_info || !foreach_cb) {
5627 LOGE("NULL pointer %p %p", pc, foreach_cb);
5628 return CAMERA_ERROR_INVALID_PARAMETER;
5633 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5634 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5636 value = (width << 16) | height;
5637 CAMERA_MSG_PARAM_SET(param, INT, value);
5639 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5641 LOGD("ret : 0x%x", ret);
5647 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5649 int ret = CAMERA_ERROR_NONE;
5650 camera_cli_s *pc = (camera_cli_s *)camera;
5651 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5653 if (!pc || !pc->cb_info || !foreach_cb) {
5654 LOGE("NULL pointer %p %p", pc, foreach_cb);
5655 return CAMERA_ERROR_INVALID_PARAMETER;
5660 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5661 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5663 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5665 LOGD("ret : 0x%x", ret);
5671 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5673 int ret = CAMERA_ERROR_NONE;
5674 camera_cli_s *pc = (camera_cli_s *)camera;
5675 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5677 if (!pc || !pc->cb_info || !foreach_cb) {
5678 LOGE("NULL pointer %p %p", pc, foreach_cb);
5679 return CAMERA_ERROR_INVALID_PARAMETER;
5684 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5685 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5687 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5689 LOGD("ret : 0x%x", ret);
5695 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5697 int ret = CAMERA_ERROR_NONE;
5698 camera_cli_s *pc = (camera_cli_s *)camera;
5699 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5700 camera_msg_param param;
5701 int set_rotation = (int)rotation;
5703 if (!pc || !pc->cb_info) {
5704 LOGE("NULL handle");
5705 return CAMERA_ERROR_INVALID_PARAMETER;
5710 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5712 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5714 LOGD("ret : 0x%x", ret);
5720 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5722 int ret = CAMERA_ERROR_NONE;
5723 camera_cli_s *pc = (camera_cli_s *)camera;
5724 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5726 if (!pc || !pc->cb_info || !rotation) {
5727 LOGE("NULL pointer %p %p", pc, rotation);
5728 return CAMERA_ERROR_INVALID_PARAMETER;
5733 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5735 if (ret == CAMERA_ERROR_NONE)
5736 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5738 LOGD("ret : 0x%x", ret);
5744 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5746 int ret = CAMERA_ERROR_NONE;
5747 camera_cli_s *pc = (camera_cli_s *)camera;
5748 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5749 camera_msg_param param;
5750 int set_flip = (int)flip;
5752 if (!pc || !pc->cb_info) {
5753 LOGE("NULL handle");
5754 return CAMERA_ERROR_INVALID_PARAMETER;
5759 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5761 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5763 LOGD("ret : 0x%x", ret);
5769 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5771 int ret = CAMERA_ERROR_NONE;
5772 camera_cli_s *pc = (camera_cli_s *)camera;
5773 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5775 if (!pc || !pc->cb_info || !flip) {
5776 LOGE("NULL pointer %p %p", pc, flip);
5777 return CAMERA_ERROR_INVALID_PARAMETER;
5782 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5784 if (ret == CAMERA_ERROR_NONE)
5785 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5787 LOGD("ret : 0x%x", ret);
5792 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5794 int ret = CAMERA_ERROR_NONE;
5795 camera_cli_s *pc = (camera_cli_s *)camera;
5796 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5797 camera_msg_param param;
5798 int set_mode = (int)mode;
5800 if (!pc || !pc->cb_info) {
5801 LOGE("NULL handle");
5802 return CAMERA_ERROR_INVALID_PARAMETER;
5807 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5809 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5811 LOGD("ret : 0x%x", ret);
5817 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5819 int ret = CAMERA_ERROR_NONE;
5820 camera_cli_s *pc = (camera_cli_s *)camera;
5821 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5823 if (!pc || !pc->cb_info || !mode) {
5824 LOGE("NULL pointer %p %p", pc, mode);
5825 return CAMERA_ERROR_INVALID_PARAMETER;
5830 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5832 if (ret == CAMERA_ERROR_NONE)
5833 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
5835 LOGD("ret : 0x%x", ret);
5841 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5843 int ret = CAMERA_ERROR_NONE;
5844 camera_cli_s *pc = (camera_cli_s *)camera;
5845 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
5847 if (!pc || !pc->cb_info) {
5848 LOGE("NULL handle");
5849 return CAMERA_ERROR_INVALID_PARAMETER;
5854 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5857 LOGE("error is occurred 0x%x", ret);
5861 LOGD("ret : %d", ret);
5867 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5869 int ret = CAMERA_ERROR_NONE;
5870 camera_cli_s *pc = (camera_cli_s *)camera;
5871 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5873 if (!pc || !pc->cb_info) {
5874 LOGE("NULL handle");
5875 return CAMERA_ERROR_INVALID_PARAMETER;
5880 if (!camera_attr_is_supported_hdr_capture(camera)) {
5881 LOGE("HDR not supported");
5882 return CAMERA_ERROR_NOT_SUPPORTED;
5886 LOGE("NULL callback");
5887 return CAMERA_ERROR_INVALID_PARAMETER;
5890 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5891 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5893 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5895 LOGD("ret : 0x%x", ret);
5901 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5903 int ret = CAMERA_ERROR_NONE;
5904 camera_cli_s *pc = (camera_cli_s *)camera;
5905 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5907 if (!pc || !pc->cb_info) {
5908 LOGE("NULL handle");
5909 return CAMERA_ERROR_INVALID_PARAMETER;
5914 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5915 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5917 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5919 LOGD("ret : 0x%x", ret);
5925 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
5927 int ret = CAMERA_ERROR_NONE;
5928 camera_cli_s *pc = (camera_cli_s *)camera;
5929 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
5930 camera_msg_param param;
5931 int set_enable = (int)enable;
5933 if (!pc || !pc->cb_info) {
5934 LOGE("NULL handle");
5935 return CAMERA_ERROR_INVALID_PARAMETER;
5940 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
5942 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5944 LOGD("ret : 0x%x", ret);
5950 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
5952 int ret = CAMERA_ERROR_NONE;
5953 camera_cli_s *pc = (camera_cli_s *)camera;
5954 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
5956 if (!pc || !pc->cb_info || !enabled) {
5957 LOGE("NULL pointer %p %p", pc, enabled);
5958 return CAMERA_ERROR_INVALID_PARAMETER;
5963 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5965 if (ret == CAMERA_ERROR_NONE)
5966 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
5968 LOGD("ret : 0x%x", ret);
5974 bool camera_attr_is_supported_anti_shake(camera_h camera)
5976 int ret = CAMERA_ERROR_NONE;
5977 camera_cli_s *pc = (camera_cli_s *)camera;
5978 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
5980 if (!pc || !pc->cb_info) {
5981 LOGE("NULL handle");
5982 return CAMERA_ERROR_INVALID_PARAMETER;
5987 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5990 LOGE("error is occurred 0x%x", ret);
5994 LOGD("ret : %d", ret);
6000 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6002 int ret = CAMERA_ERROR_NONE;
6003 camera_cli_s *pc = (camera_cli_s *)camera;
6004 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6005 camera_msg_param param;
6006 int set_enable = (int)enable;
6008 if (!pc || !pc->cb_info) {
6009 LOGE("NULL handle");
6010 return CAMERA_ERROR_INVALID_PARAMETER;
6015 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6017 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6019 LOGD("ret : 0x%x", ret);
6025 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6027 int ret = CAMERA_ERROR_NONE;
6028 camera_cli_s *pc = (camera_cli_s *)camera;
6029 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6031 if (!pc || !pc->cb_info || !enabled) {
6032 LOGE("NULL pointer %p %p", pc, enabled);
6033 return CAMERA_ERROR_INVALID_PARAMETER;
6038 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6040 if (ret == CAMERA_ERROR_NONE)
6041 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6043 LOGD("ret : 0x%x", ret);
6049 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6051 int ret = CAMERA_ERROR_NONE;
6052 camera_cli_s *pc = (camera_cli_s *)camera;
6053 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6055 if (!pc || !pc->cb_info) {
6056 LOGE("NULL handle");
6057 return CAMERA_ERROR_INVALID_PARAMETER;
6062 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6065 LOGE("error is occurred 0x%x", ret);
6069 LOGD("ret : %d", ret);
6075 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6077 int ret = CAMERA_ERROR_NONE;
6078 camera_cli_s *pc = (camera_cli_s *)camera;
6079 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6080 camera_msg_param param;
6081 int set_enable = (int)enable;
6083 if (!pc || !pc->cb_info) {
6084 LOGE("NULL handle");
6085 return CAMERA_ERROR_INVALID_PARAMETER;
6090 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6092 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6094 LOGD("ret : 0x%x", ret);
6100 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6102 int ret = CAMERA_ERROR_NONE;
6103 camera_cli_s *pc = (camera_cli_s *)camera;
6104 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6106 if (!pc || !pc->cb_info || !enabled) {
6107 LOGE("NULL pointer %p %p", pc, enabled);
6108 return CAMERA_ERROR_INVALID_PARAMETER;
6113 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6115 if (ret == CAMERA_ERROR_NONE)
6116 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6118 LOGD("ret : 0x%x", ret);
6124 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6126 int ret = CAMERA_ERROR_NONE;
6127 camera_cli_s *pc = (camera_cli_s *)camera;
6128 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6130 if (!pc || !pc->cb_info) {
6131 LOGE("NULL handle");
6132 return CAMERA_ERROR_INVALID_PARAMETER;
6137 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6140 LOGE("error is occurred 0x%x", ret);
6144 LOGD("ret : %d", ret);
6150 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6152 int ret = CAMERA_ERROR_NONE;
6153 camera_cli_s *pc = (camera_cli_s *)camera;
6154 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6155 camera_msg_param param;
6156 int set_disable = (int)disable;
6158 if (!pc || !pc->cb_info) {
6159 LOGE("NULL handle");
6160 return CAMERA_ERROR_INVALID_PARAMETER;
6165 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6167 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6169 LOGD("ret : 0x%x", ret);
6175 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6177 int ret = CAMERA_ERROR_NONE;
6178 camera_cli_s *pc = (camera_cli_s *)camera;
6179 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6180 camera_msg_param param;
6181 int set_move_type = (int)move_type;
6184 if (!pc || !pc->cb_info) {
6185 LOGE("NULL handle");
6186 return CAMERA_ERROR_INVALID_PARAMETER;
6191 value = (set_move_type << 16) | pan_step;
6192 CAMERA_MSG_PARAM_SET(param, INT, value);
6194 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6196 LOGD("ret : 0x%x", ret);
6202 int camera_attr_get_pan(camera_h camera, int *pan_step)
6204 int ret = CAMERA_ERROR_NONE;
6205 camera_cli_s *pc = (camera_cli_s *)camera;
6206 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6208 if (!pc || !pc->cb_info || !pan_step) {
6209 LOGE("NULL pointer %p %p", pc, pan_step);
6210 return CAMERA_ERROR_INVALID_PARAMETER;
6215 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6217 if (ret == CAMERA_ERROR_NONE)
6218 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6220 LOGD("ret : 0x%x", ret);
6226 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6228 int ret = CAMERA_ERROR_NONE;
6229 camera_cli_s *pc = (camera_cli_s *)camera;
6230 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6232 if (!pc || !pc->cb_info || !min || !max) {
6233 LOGE("NULL pointer %p %p", pc, min, max);
6234 return CAMERA_ERROR_INVALID_PARAMETER;
6239 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6241 if (ret == CAMERA_ERROR_NONE) {
6242 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6243 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6246 LOGD("ret : 0x%x", ret);
6252 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6254 int ret = CAMERA_ERROR_NONE;
6255 camera_cli_s *pc = (camera_cli_s *)camera;
6256 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6257 camera_msg_param param;
6258 int set_move_type = (int)move_type;
6261 if (!pc || !pc->cb_info) {
6262 LOGE("NULL handle");
6263 return CAMERA_ERROR_INVALID_PARAMETER;
6268 value = (set_move_type << 16) | tilt_step;
6269 CAMERA_MSG_PARAM_SET(param, INT, value);
6271 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6273 LOGD("ret : 0x%x", ret);
6279 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6281 int ret = CAMERA_ERROR_NONE;
6282 camera_cli_s *pc = (camera_cli_s *)camera;
6283 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6285 if (!pc || !pc->cb_info || !tilt_step) {
6286 LOGE("NULL pointer %p %p", pc, tilt_step);
6287 return CAMERA_ERROR_INVALID_PARAMETER;
6292 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6294 if (ret == CAMERA_ERROR_NONE)
6295 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6297 LOGD("ret : 0x%x", ret);
6303 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6305 int ret = CAMERA_ERROR_NONE;
6306 camera_cli_s *pc = (camera_cli_s *)camera;
6307 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6309 if (!pc || !pc->cb_info || !min || !max) {
6310 LOGE("NULL pointer %p %p %p", pc, min, max);
6311 return CAMERA_ERROR_INVALID_PARAMETER;
6316 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6318 if (ret == CAMERA_ERROR_NONE) {
6319 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6320 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6323 LOGD("ret : 0x%x", ret);
6329 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6331 int ret = CAMERA_ERROR_NONE;
6332 camera_cli_s *pc = (camera_cli_s *)camera;
6333 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6334 camera_msg_param param;
6335 int set_ptz_type = (int)ptz_type;
6337 if (!pc || !pc->cb_info) {
6338 LOGE("NULL handle");
6339 return CAMERA_ERROR_INVALID_PARAMETER;
6344 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6346 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6348 LOGD("ret : 0x%x", ret);
6354 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6356 int ret = CAMERA_ERROR_NONE;
6357 camera_cli_s *pc = (camera_cli_s *)camera;
6358 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6360 if (!pc || !pc->cb_info || !foreach_cb) {
6361 LOGE("NULL pointer %p %p", pc, foreach_cb);
6362 return CAMERA_ERROR_INVALID_PARAMETER;
6367 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6368 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6370 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6372 LOGD("ret : 0x%x", ret);
6378 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6380 int ret = CAMERA_ERROR_NONE;
6381 camera_cli_s *pc = (camera_cli_s *)camera;
6382 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6383 int set_display_roi_area[4] = {x, y, width, height};
6388 if (!pc || !pc->cb_info) {
6389 LOGE("NULL handle");
6390 return CAMERA_ERROR_INVALID_PARAMETER;
6395 #ifdef TIZEN_FEATURE_EVAS_RENDERER
6396 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6397 g_mutex_lock(&pc->cb_info->evas_mutex);
6399 ret = mm_evas_renderer_set_roi_area(pc->cb_info->evas_info, x, y, width, height);
6401 g_mutex_unlock(&pc->cb_info->evas_mutex);
6403 if (ret != MM_ERROR_NONE) {
6404 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6405 return CAMERA_ERROR_INVALID_OPERATION;
6408 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
6410 length = sizeof(set_display_roi_area) / sizeof(int) + \
6411 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6413 msg = muse_core_msg_json_factory_new(api,
6414 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6417 LOGE("msg creation failed: api %d", api);
6418 return CAMERA_ERROR_OUT_OF_MEMORY;
6421 if (pc->cb_info->is_server_connected) {
6422 g_mutex_lock(&pc->cb_info->fd_lock);
6423 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
6424 g_mutex_unlock(&pc->cb_info->fd_lock);
6428 LOGE("message send failed");
6429 ret = CAMERA_ERROR_INVALID_OPERATION;
6431 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6434 muse_core_msg_json_factory_free(msg);
6436 LOGD("ret : 0x%x", ret);
6442 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6444 camera_cli_s *pc = (camera_cli_s *)camera;
6445 int ret = CAMERA_ERROR_NONE;
6446 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6448 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6449 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6450 return CAMERA_ERROR_INVALID_PARAMETER;
6455 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6457 if (ret == CAMERA_ERROR_NONE) {
6458 *x = pc->cb_info->get_display_roi_area[0];
6459 *y = pc->cb_info->get_display_roi_area[1];
6460 *width = pc->cb_info->get_display_roi_area[2];
6461 *height = pc->cb_info->get_display_roi_area[3];
6464 LOGD("ret : 0x%x", ret);
6470 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6472 int ret = CAMERA_ERROR_NONE;
6473 int get_device_state = 0;
6476 LOGE("NULL pointer");
6477 return CAMERA_ERROR_INVALID_PARAMETER;
6480 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6481 (int)device, "get_device_state", &get_device_state);
6483 if (ret == CAMERA_ERROR_NONE) {
6484 *state = (camera_device_state_e)get_device_state;
6485 LOGD("device state %d", *state);
6487 LOGE("failed 0x%x", ret);
6494 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6496 int ret = CAMERA_ERROR_NONE;
6497 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6498 camera_cb_info *info = NULL;
6500 if (!callback || !cb_id) {
6501 LOGE("invalid pointer %p %p", callback, cb_id);
6502 return CAMERA_ERROR_INVALID_PARAMETER;
6505 /* check camera support */
6506 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6507 if (ret != CAMERA_ERROR_NONE) {
6508 LOGE("get device state failed");
6512 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6514 info = g_new0(camera_cb_info, 1);
6516 LOGE("info failed");
6517 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6521 info->id = ++g_cam_dev_state_changed_cb_id;
6522 info->callback = (void *)callback;
6523 info->user_data = user_data;
6527 /* subscribe dbus signal for camera state change */
6528 if (!g_cam_dev_state_changed_cb_conn) {
6529 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6530 if (!g_cam_dev_state_changed_cb_conn) {
6531 LOGE("failed to get gdbus connection");
6532 ret = CAMERA_ERROR_INVALID_OPERATION;
6536 LOGD("subscribe signal %s - %s - %s",
6537 MM_CAMCORDER_DBUS_OBJECT,
6538 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6539 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6541 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6542 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6543 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6544 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6545 LOGE("failed to get gdbus connection");
6546 ret = CAMERA_ERROR_INVALID_OPERATION;
6550 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6553 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6555 LOGD("callback id %d", info->id);
6558 if (ret != CAMERA_ERROR_NONE) {
6564 if (g_cam_dev_state_changed_cb_conn) {
6565 g_object_unref(g_cam_dev_state_changed_cb_conn);
6566 g_cam_dev_state_changed_cb_conn = NULL;
6570 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6576 int camera_remove_device_state_changed_cb(int cb_id)
6578 int ret = CAMERA_ERROR_NONE;
6579 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6580 GList *tmp_list = NULL;
6581 camera_cb_info *info = NULL;
6583 /* check camera support */
6584 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6585 if (ret != CAMERA_ERROR_NONE) {
6586 LOGE("get device state failed");
6590 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6592 if (!g_cam_dev_state_changed_cb_list) {
6593 LOGE("there is no callback info");
6594 ret = CAMERA_ERROR_INVALID_OPERATION;
6598 tmp_list = g_cam_dev_state_changed_cb_list;
6601 info = tmp_list->data;
6602 tmp_list = tmp_list->next;
6609 if (info->id == cb_id) {
6610 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6615 if (!g_cam_dev_state_changed_cb_list) {
6616 /* no remained callback */
6617 if (g_cam_dev_state_changed_cb_conn) {
6618 /* unsubscribe signal */
6619 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6620 g_cam_dev_state_changed_cb_subscribe_id = 0;
6622 /* unref connection */
6623 g_object_unref(g_cam_dev_state_changed_cb_conn);
6624 g_cam_dev_state_changed_cb_conn = NULL;
6628 LOGD("id %d callback removed", cb_id);
6629 ret = CAMERA_ERROR_NONE;
6635 LOGE("id %d callback not found", cb_id);
6636 ret = CAMERA_ERROR_INVALID_PARAMETER;
6639 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);