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 case MUSE_CAMERA_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR:
1519 LOGW("Unknown event : %d", event);
1526 static bool _camera_idle_event_callback(void *data)
1528 camera_cb_info_s *cb_info = NULL;
1529 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1531 if (cam_idle_event == NULL) {
1532 LOGE("cam_idle_event is NULL");
1537 g_mutex_lock(&cam_idle_event->event_mutex);
1539 cb_info = cam_idle_event->cb_info;
1540 if (cb_info == NULL) {
1541 LOGW("camera cb_info is NULL. event %d", cam_idle_event->event);
1542 goto IDLE_EVENT_CALLBACK_DONE;
1545 /* remove event from list */
1546 g_mutex_lock(&cb_info->idle_event_mutex);
1548 if (cb_info->idle_event_list)
1549 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1551 /*LOGD("remove camera idle event %p, %p", cam_idle_event, cb_info->idle_event_list);*/
1552 g_mutex_unlock(&cb_info->idle_event_mutex);
1555 _camera_client_user_callback(cam_idle_event->cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
1557 /* send signal for waiting thread */
1558 g_cond_signal(&cb_info->idle_event_cond);
1560 IDLE_EVENT_CALLBACK_DONE:
1561 /* unlock and release event */
1562 g_mutex_unlock(&cam_idle_event->event_mutex);
1563 g_mutex_clear(&cam_idle_event->event_mutex);
1565 g_free(cam_idle_event);
1566 cam_idle_event = NULL;
1571 static void *_camera_msg_handler_func(gpointer data)
1575 camera_message_s *cam_msg = NULL;
1576 camera_idle_event_s *cam_idle_event = NULL;
1577 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1578 camera_cb_info_s *cb_info = NULL;
1580 if (!handler_info || !handler_info->cb_info) {
1581 LOGE("NULL handler %p", handler_info);
1585 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1586 type = handler_info->type;
1588 LOGD("t:%d start", type);
1590 g_mutex_lock(&handler_info->mutex);
1592 while (g_atomic_int_get(&handler_info->running)) {
1593 if (g_queue_is_empty(handler_info->queue)) {
1594 /*LOGD("t:%d signal wait...", type);*/
1595 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1596 /*LOGD("t:%d signal received", type);*/
1598 if (g_atomic_int_get(&handler_info->running) == 0) {
1599 LOGD("t:%d stop event thread", type);
1604 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1606 g_mutex_unlock(&handler_info->mutex);
1608 if (cam_msg == NULL) {
1609 LOGE("t:%d NULL message", type);
1610 g_mutex_lock(&handler_info->mutex);
1616 if (api < MUSE_CAMERA_API_MAX) {
1619 g_mutex_lock(&cb_info->api_mutex[api]);
1621 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1622 cb_info->api_ret[api] = ret;
1623 cb_info->api_activating[api] = 1;
1625 /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
1627 g_cond_signal(&cb_info->api_cond[api]);
1629 LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1632 g_mutex_unlock(&cb_info->api_mutex[api]);
1633 } else if (api == MUSE_CAMERA_CB_EVENT) {
1634 switch (cam_msg->event_class) {
1635 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1636 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event);
1638 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1639 cam_idle_event = g_new0(camera_idle_event_s, 1);
1640 if (cam_idle_event == NULL) {
1641 LOGE("t:%d cam_idle_event alloc failed", type);
1645 cam_idle_event->event = cam_msg->event;
1646 cam_idle_event->cb_info = cb_info;
1647 g_mutex_init(&cam_idle_event->event_mutex);
1648 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg) - 1);
1650 /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, cam_msg->event, cam_idle_event);*/
1652 g_mutex_lock(&cb_info->idle_event_mutex);
1653 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1654 g_mutex_unlock(&cb_info->idle_event_mutex);
1656 g_idle_add_full(G_PRIORITY_DEFAULT,
1657 (GSourceFunc)_camera_idle_event_callback,
1658 (gpointer)cam_idle_event,
1662 LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
1666 LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1672 g_mutex_lock(&handler_info->mutex);
1675 /* remove remained event */
1676 while (!g_queue_is_empty(handler_info->queue)) {
1677 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1679 LOGD("t:%d remove camera message %p", type, cam_msg);
1683 LOGW("t:%d NULL camera message", type);
1687 g_mutex_unlock(&handler_info->mutex);
1689 LOGD("t:%d return", type);
1695 static void _camera_remove_idle_event_all(camera_cb_info_s *cb_info)
1697 camera_idle_event_s *cam_idle_event = NULL;
1698 gboolean ret = TRUE;
1700 gint64 end_time = 0;
1702 if (cb_info == NULL) {
1703 LOGE("cb_info is NULL");
1707 g_mutex_lock(&cb_info->idle_event_mutex);
1709 if (cb_info->idle_event_list == NULL) {
1710 LOGD("No remained idle event");
1711 g_mutex_unlock(&cb_info->idle_event_mutex);
1715 list = cb_info->idle_event_list;
1718 cam_idle_event = list->data;
1719 list = g_list_next(list);
1721 if (!cam_idle_event) {
1722 LOGW("Fail to remove idle event. The event is NULL");
1726 if (g_mutex_trylock(&cam_idle_event->event_mutex)) {
1727 ret = g_idle_remove_by_data(cam_idle_event);
1729 LOGD("remove idle event [%p], ret[%d]", cam_idle_event, ret);
1732 cam_idle_event->cb_info = NULL;
1733 LOGW("idle event %p will be called later", cam_idle_event);
1736 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1738 g_mutex_unlock(&cam_idle_event->event_mutex);
1741 g_mutex_clear(&cam_idle_event->event_mutex);
1743 g_free(cam_idle_event);
1744 cam_idle_event = NULL;
1746 LOGD("remove idle event done");
1752 LOGW("event lock failed. it's being called...");
1754 end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
1756 if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
1757 LOGW("signal received");
1762 g_list_free(cb_info->idle_event_list);
1763 cb_info->idle_event_list = NULL;
1765 g_mutex_unlock(&cb_info->idle_event_mutex);
1771 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg)
1773 camera_message_s *cam_msg = NULL;
1775 if (!cb_info || !msg) {
1776 LOGE("NULL pointer %p %p", cb_info, msg);
1780 cam_msg = g_new0(camera_message_s, 1);
1782 LOGE("failed to alloc cam_msg for [%s]", msg);
1787 cam_msg->event = event;
1788 cam_msg->event_class = event_class;
1790 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1792 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1794 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1795 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1796 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1797 g_cond_signal(&cb_info->preview_cb_info.cond);
1798 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1799 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1800 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1801 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1802 g_cond_signal(&cb_info->capture_cb_info.cond);
1803 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1805 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1806 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1807 g_cond_signal(&cb_info->msg_handler_info.cond);
1808 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1817 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg)
1819 int ret = CAMERA_ERROR_NONE;
1823 int event_class = -1;
1827 if (!cb_info || !msg) {
1828 LOGE("invalid ptr %p %p", cb_info, msg);
1832 /*LOGD("msg [%s]", msg);*/
1834 if (!muse_camera_msg_get(api, msg)) {
1835 LOGE("failed to get camera api");
1839 if (api == MUSE_CAMERA_CB_EVENT) {
1840 if (!muse_camera_msg_get(event, msg) ||
1841 !muse_camera_msg_get(event_class, msg)) {
1842 LOGE("failed to get camera event or event_class [%s]", msg);
1846 if (!muse_camera_msg_get(api_class, msg)) {
1847 LOGE("failed to get camera api_class [%s]", msg);
1852 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1853 if (api >= MUSE_CAMERA_API_MAX) {
1854 LOGE("invalid api %d", api);
1858 if (!muse_camera_msg_get(ret, msg)) {
1859 LOGE("failed to get camera ret");
1863 g_mutex_lock(&cb_info->api_mutex[api]);
1865 cb_info->api_ret[api] = ret;
1866 cb_info->api_activating[api] = 1;
1869 case MUSE_CAMERA_API_CREATE:
1870 if (ret != CAMERA_ERROR_NONE) {
1871 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1872 LOGE("camera create error 0x%x. close client cb handler", ret);
1875 case MUSE_CAMERA_API_DESTROY:
1876 if (ret == CAMERA_ERROR_NONE) {
1877 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1878 LOGD("camera destroy done. close client cb handler");
1882 muse_camera_msg_get(get_type, msg);
1883 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1884 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1885 muse_camera_msg_get(get_index, msg);
1888 case MUSE_CAMERA_GET_TYPE_INT:
1889 muse_core_msg_json_deserialize("get_value", msg, NULL, &cb_info->get_int[get_index], NULL, MUSE_TYPE_INT);
1891 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1892 muse_core_msg_json_deserialize("get_value0", msg, NULL, &cb_info->get_int_pair[get_index][0], NULL, MUSE_TYPE_INT);
1893 muse_core_msg_json_deserialize("get_value1", msg, NULL, &cb_info->get_int_pair[get_index][1], NULL, MUSE_TYPE_INT);
1895 case MUSE_CAMERA_GET_TYPE_ARRAY:
1896 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
1897 muse_core_msg_json_deserialize("get_value",
1898 msg, NULL, cb_info->get_display_roi_area, NULL, MUSE_TYPE_ARRAY);
1899 LOGD("get display roi %d,%d,%dx%d",
1900 cb_info->get_display_roi_area[0],
1901 cb_info->get_display_roi_area[1],
1902 cb_info->get_display_roi_area[2],
1903 cb_info->get_display_roi_area[3]);
1905 muse_core_msg_json_deserialize("get_value",
1906 msg, NULL, cb_info->get_geotag, NULL, MUSE_TYPE_ARRAY);
1907 LOGD("get geotag %lf, %lf, %lf",
1908 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
1911 case MUSE_CAMERA_GET_TYPE_STRING:
1912 muse_core_msg_json_deserialize("get_value", msg, NULL, cb_info->get_string[get_index], NULL, MUSE_TYPE_STRING);
1915 LOGW("unknown type %d", get_type);
1922 g_cond_signal(&cb_info->api_cond[api]);
1923 g_mutex_unlock(&cb_info->api_mutex[api]);
1924 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
1925 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg);
1927 LOGW("unknown camera api %d, class %d", api, api_class);
1934 static void *_camera_msg_recv_func(gpointer data)
1936 int recv_length = 0;
1937 int single_length = 0;
1938 int remained_length = 0;
1939 char *recv_msg = NULL;
1940 char *single_msg = NULL;
1941 char *remained_msg = NULL;
1945 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
1948 LOGE("cb_info NULL");
1954 single_msg = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
1956 LOGE("single_msg malloc failed");
1960 recv_msg = cb_info->recv_msg;
1962 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
1963 recv_length = muse_core_ipc_recv_msg(cb_info->fd, recv_msg);
1964 if (recv_length <= 0) {
1965 cb_info->is_server_connected = FALSE;
1966 LOGE("receive msg failed - server disconnected");
1974 /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
1976 /* Need to split the combined entering msgs */
1977 for (cur_pos = 0 ; cur_pos < recv_length ; cur_pos++) {
1978 if (recv_msg[cur_pos] == '}') {
1979 single_length = cur_pos - prev_pos + 1;
1981 if (single_length < MUSE_CAMERA_MSG_MAX_LENGTH) {
1982 /* check remained msg */
1983 if (remained_length > 0) {
1985 strncpy(single_msg, remained_msg, remained_length);
1986 strncpy(single_msg + remained_length, recv_msg + prev_pos, single_length);
1987 single_msg[remained_length + single_length] = '\0';
1990 remained_msg = NULL;
1992 strncpy(single_msg, recv_msg + prev_pos, single_length);
1993 single_msg[single_length] = '\0';
1994 LOGE("lost msg [%s], skip...", single_msg);
1997 remained_length = 0;
1999 strncpy(single_msg, recv_msg + prev_pos, single_length);
2000 single_msg[single_length] = '\0';
2003 if (single_msg[0] == '{') {
2005 /*LOGD("splitted msg : [%s], Index : %d", single_msg, num_msg);*/
2006 /* process each message */
2007 __camera_process_msg(cb_info, single_msg);
2009 LOGE("invalid msg [%s]", single_msg);
2012 LOGE("too long message [len %d] skip...", single_length);
2015 prev_pos = cur_pos + 1;
2019 /* check incompleted message */
2020 if (recv_msg[recv_length - 1] != '}') {
2021 remained_length = recv_length - prev_pos;
2023 LOGW("incompleted message [len %d]", remained_length);
2025 remained_msg = (char *)malloc(remained_length + 1);
2027 strncpy(remained_msg, recv_msg + prev_pos, remained_length);
2028 remained_msg[remained_length] = '\0';
2030 LOGE("failed to alloc for remained msg");
2033 remained_length = 0;
2037 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
2039 if (!cb_info->is_server_connected) {
2040 /* send error msg for server disconnection */
2041 char *error_msg = muse_core_msg_json_factory_new(MUSE_CAMERA_CB_EVENT,
2042 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
2043 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
2047 LOGE("error_msg failed");
2048 goto CB_HANDLER_EXIT;
2051 __camera_add_msg_to_queue(cb_info,
2052 MUSE_CAMERA_CB_EVENT,
2053 MUSE_CAMERA_EVENT_TYPE_ERROR,
2054 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
2057 muse_core_msg_json_factory_free(error_msg);
2060 LOGE("add error msg for service disconnection done");
2071 remained_msg = NULL;
2078 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2079 int type, const char *thread_name, camera_cb_info_s *cb_info)
2081 if (!handler_info || !thread_name || !cb_info) {
2082 LOGE("t:%d NULL %p %p %p",
2083 type, handler_info, thread_name, cb_info);
2089 handler_info->type = type;
2090 handler_info->queue = g_queue_new();
2091 if (handler_info->queue == NULL) {
2092 LOGE("t:%d queue failed", type);
2096 g_mutex_init(&handler_info->mutex);
2097 g_cond_init(&handler_info->cond);
2099 handler_info->cb_info = (void *)cb_info;
2100 g_atomic_int_set(&handler_info->running, 1);
2102 handler_info->thread = g_thread_try_new(thread_name,
2103 _camera_msg_handler_func, (gpointer)handler_info, NULL);
2104 if (handler_info->thread == NULL) {
2105 LOGE("t:%d thread failed", type);
2107 g_mutex_clear(&handler_info->mutex);
2108 g_cond_clear(&handler_info->cond);
2109 g_queue_free(handler_info->queue);
2110 handler_info->queue = NULL;
2115 LOGD("t:%d done", type);
2121 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2125 if (!handler_info) {
2126 LOGE("NULL handler");
2130 if (!handler_info->thread) {
2131 LOGW("thread is not created");
2135 type = handler_info->type;
2137 LOGD("t:%d thread %p", type, handler_info->thread);
2139 g_mutex_lock(&handler_info->mutex);
2140 g_atomic_int_set(&handler_info->running, 0);
2141 g_cond_signal(&handler_info->cond);
2142 g_mutex_unlock(&handler_info->mutex);
2144 g_thread_join(handler_info->thread);
2145 g_thread_unref(handler_info->thread);
2146 handler_info->thread = NULL;
2148 g_mutex_clear(&handler_info->mutex);
2149 g_cond_clear(&handler_info->cond);
2150 g_queue_free(handler_info->queue);
2151 handler_info->queue = NULL;
2153 LOGD("t:%d done", type);
2159 static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
2161 camera_cb_info_s *cb_info = NULL;
2164 g_return_val_if_fail(sockfd > 0, NULL);
2166 cb_info = g_new0(camera_cb_info_s, 1);
2167 if (cb_info == NULL) {
2168 LOGE("cb_info failed");
2172 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2173 g_mutex_init(&cb_info->api_mutex[i]);
2174 g_cond_init(&cb_info->api_cond[i]);
2177 g_mutex_init(&cb_info->fd_lock);
2178 g_mutex_init(&cb_info->idle_event_mutex);
2179 g_cond_init(&cb_info->idle_event_cond);
2180 g_mutex_init(&cb_info->mp_data_mutex);
2181 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2182 g_mutex_init(&cb_info->evas_mutex);
2183 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2185 /* message handler thread */
2186 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2187 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2188 LOGE("msg_handler_info failed");
2192 /* message handler thread for preview callback */
2193 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2194 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2195 LOGE("preview_cb_info failed");
2199 /* message handler thread for capture callback */
2200 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2201 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2202 LOGE("capture_cb_info failed");
2206 cb_info->fd = sockfd;
2207 cb_info->preview_cb_flag = 0;
2208 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2209 cb_info->evas_info = NULL;
2210 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2212 /* message receive thread */
2213 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2214 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2215 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2216 if (cb_info->msg_recv_thread == NULL) {
2217 LOGE("message receive thread creation failed");
2221 cb_info->is_server_connected = TRUE;
2227 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2228 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2229 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2231 g_mutex_clear(&cb_info->fd_lock);
2232 g_mutex_clear(&cb_info->idle_event_mutex);
2233 g_cond_clear(&cb_info->idle_event_cond);
2234 g_mutex_clear(&cb_info->mp_data_mutex);
2235 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2236 g_mutex_clear(&cb_info->evas_mutex);
2237 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2239 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2240 g_mutex_clear(&cb_info->api_mutex[i]);
2241 g_cond_clear(&cb_info->api_cond[i]);
2251 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2255 g_return_if_fail(cb_info != NULL);
2257 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2259 g_thread_join(cb_info->msg_recv_thread);
2260 g_thread_unref(cb_info->msg_recv_thread);
2261 cb_info->msg_recv_thread = NULL;
2263 LOGD("msg_recv thread removed");
2265 /* destroy msg handler threads */
2266 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2267 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2268 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2270 g_mutex_clear(&cb_info->fd_lock);
2271 g_mutex_clear(&cb_info->idle_event_mutex);
2272 g_cond_clear(&cb_info->idle_event_cond);
2273 g_mutex_clear(&cb_info->mp_data_mutex);
2274 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2275 g_mutex_clear(&cb_info->evas_mutex);
2276 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2278 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2279 g_mutex_clear(&cb_info->api_mutex[i]);
2280 g_cond_clear(&cb_info->api_cond[i]);
2283 if (cb_info->fd > -1) {
2284 muse_core_connection_close(cb_info->fd);
2288 if (cb_info->bufmgr) {
2289 tbm_bufmgr_deinit(cb_info->bufmgr);
2290 cb_info->bufmgr = NULL;
2292 if (cb_info->pkt_fmt) {
2293 media_format_unref(cb_info->pkt_fmt);
2294 cb_info->pkt_fmt = NULL;
2297 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2298 if (cb_info->evas_info)
2299 mm_evas_renderer_destroy(&cb_info->evas_info);
2300 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2302 cb_info->preview_cb_flag = 0;
2311 int _camera_start_evas_rendering(camera_h camera)
2313 int ret = CAMERA_ERROR_NONE;
2314 camera_cli_s *pc = (camera_cli_s *)camera;
2316 if (!pc || !pc->cb_info) {
2317 LOGE("NULL handle");
2318 return CAMERA_ERROR_INVALID_PARAMETER;
2323 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2324 LOGE("EVAS surface is not set");
2325 return CAMERA_ERROR_NONE;
2328 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2329 g_mutex_lock(&pc->cb_info->evas_mutex);
2331 /* set evas render flag as RUN */
2332 pc->cb_info->run_evas_render = true;
2333 ret = CAMERA_ERROR_NONE;
2335 g_mutex_unlock(&pc->cb_info->evas_mutex);
2336 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2337 LOGW("evas renderer is not supported");
2338 ret = CAMERA_ERROR_NOT_SUPPORTED;
2339 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2345 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2347 int ret = CAMERA_ERROR_NONE;
2348 camera_cli_s *pc = (camera_cli_s *)camera;
2350 if (!pc || !pc->cb_info) {
2351 LOGE("NULL handle");
2352 return CAMERA_ERROR_INVALID_PARAMETER;
2355 LOGD("stop - keep screen %d", keep_screen);
2357 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2358 LOGE("EVAS surface is not set");
2359 return CAMERA_ERROR_NONE;
2362 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2363 g_mutex_lock(&pc->cb_info->evas_mutex);
2365 /* set evas render flag as STOP and release buffers */
2366 pc->cb_info->run_evas_render = false;
2368 ret = mm_evas_renderer_retrieve_all_packets(pc->cb_info->evas_info, keep_screen);
2369 if (ret != MM_ERROR_NONE) {
2370 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2371 ret = CAMERA_ERROR_INVALID_OPERATION;
2374 g_mutex_unlock(&pc->cb_info->evas_mutex);
2375 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2376 LOGW("evas renderer is not supported");
2377 ret = CAMERA_ERROR_NOT_SUPPORTED;
2378 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2384 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2386 int ret = CAMERA_ERROR_NONE;
2389 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2391 /* create muse connection */
2392 if (!key || !value) {
2393 LOGE("NULL pointer");
2394 return CAMERA_ERROR_INVALID_PARAMETER;
2397 sock_fd = muse_core_client_new();
2399 LOGE("muse_core_client_new failed");
2400 return CAMERA_ERROR_INVALID_OPERATION;
2403 msg = muse_core_msg_json_factory_new(api,
2404 MUSE_TYPE_INT, "module", MUSE_CAMERA,
2405 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2409 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2413 ret = muse_core_ipc_send_msg(sock_fd, msg);
2415 muse_core_msg_json_factory_free(msg);
2419 LOGE("send msg failed");
2420 ret = CAMERA_ERROR_INVALID_OPERATION;
2424 ret = muse_core_ipc_recv_msg(sock_fd, recv_msg);
2426 LOGE("recv msg failed %d", errno);
2427 ret = CAMERA_ERROR_INVALID_OPERATION;
2431 if (!muse_camera_msg_get(ret, recv_msg)) {
2432 LOGE("failed to get return value from msg [%s]", recv_msg);
2433 ret = CAMERA_ERROR_INVALID_OPERATION;
2437 if (ret == CAMERA_ERROR_NONE)
2438 muse_core_msg_json_deserialize(key, recv_msg, NULL, value, NULL, MUSE_TYPE_ANY);
2440 LOGD("api %d - value %d", api, *value);
2444 muse_core_connection_close(sock_fd);
2452 int camera_create(camera_device_e device, camera_h *camera)
2455 char *send_msg = NULL;
2457 int ret = CAMERA_ERROR_NONE;
2459 camera_cli_s *pc = NULL;
2460 tbm_bufmgr bufmgr = NULL;
2462 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2463 muse_core_api_module_e muse_module = MUSE_CAMERA;
2464 int device_type = (int)device;
2467 LOGE("NULL pointer");
2468 return CAMERA_ERROR_INVALID_PARAMETER;
2471 sock_fd = muse_core_client_new();
2473 LOGE("muse_core_client_new failed - returned fd %d", sock_fd);
2474 ret = CAMERA_ERROR_INVALID_OPERATION;
2480 send_msg = muse_core_msg_json_factory_new(api,
2481 MUSE_TYPE_INT, "module", muse_module,
2482 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2483 MUSE_TYPE_INT, "pid", pid,
2488 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2492 send_ret = muse_core_ipc_send_msg(sock_fd, send_msg);
2494 muse_core_msg_json_factory_free(send_msg);
2498 LOGE("send msg failed %d", errno);
2499 ret = CAMERA_ERROR_INVALID_OPERATION;
2503 pc = g_new0(camera_cli_s, 1);
2505 LOGE("camera_cli_s alloc failed");
2506 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2510 bufmgr = tbm_bufmgr_init(-1);
2511 if (bufmgr == NULL) {
2512 LOGE("get tbm bufmgr failed");
2513 ret = CAMERA_ERROR_INVALID_OPERATION;
2517 pc->cb_info = _camera_client_callback_new(sock_fd);
2518 if (pc->cb_info == NULL) {
2519 LOGE("cb_info alloc failed");
2520 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2526 LOGD("cb info : %d", pc->cb_info->fd);
2528 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2529 if (ret == CAMERA_ERROR_NONE) {
2530 intptr_t handle = 0;
2531 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2533 LOGE("Receiving Handle Failed!!");
2534 ret = CAMERA_ERROR_INVALID_OPERATION;
2538 pc->remote_handle = handle;
2539 pc->cb_info->bufmgr = bufmgr;
2541 ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL);
2542 if (ret != CAMERA_ERROR_NONE) {
2543 LOGE("init display failed 0x%x", ret);
2547 LOGD("camera create 0x%x", pc->remote_handle);
2548 *camera = (camera_h)pc;
2557 tbm_bufmgr_deinit(bufmgr);
2562 muse_core_connection_close(sock_fd);
2568 _camera_client_callback_destroy(pc->cb_info);
2575 LOGE("camera create error : 0x%x", ret);
2581 int camera_change_device(camera_h camera, camera_device_e device)
2583 int ret = CAMERA_ERROR_NONE;
2584 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2585 camera_cli_s *pc = (camera_cli_s *)camera;
2586 camera_msg_param param;
2588 if (!pc || !pc->cb_info) {
2589 LOGE("NULL handle");
2590 return CAMERA_ERROR_INVALID_PARAMETER;
2593 CAMERA_MSG_PARAM_SET(param, INT, device);
2595 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2601 int camera_destroy(camera_h camera)
2603 int ret = CAMERA_ERROR_NONE;
2604 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2605 camera_cli_s *pc = (camera_cli_s *)camera;
2607 if (!pc || !pc->cb_info) {
2608 LOGE("NULL handle");
2609 return CAMERA_ERROR_INVALID_PARAMETER;
2614 if (pc->cb_info->is_server_connected)
2615 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2617 LOGW("server disconnected. release resource without send message.");
2619 if (ret == CAMERA_ERROR_NONE) {
2620 _camera_remove_idle_event_all(pc->cb_info);
2621 _camera_client_callback_destroy(pc->cb_info);
2631 int camera_start_preview(camera_h camera)
2633 int ret = CAMERA_ERROR_NONE;
2634 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2635 camera_cli_s *pc = (camera_cli_s *)camera;
2637 if (!pc || !pc->cb_info) {
2638 LOGE("NULL handle");
2639 return CAMERA_ERROR_INVALID_PARAMETER;
2644 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT_LONG);
2645 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2646 ret = _camera_start_evas_rendering(camera);
2647 if (ret != CAMERA_ERROR_NONE) {
2648 LOGE("stop preview because of error");
2649 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, pc->cb_info, NULL, 0);
2653 LOGD("ret : 0x%x", ret);
2659 int camera_stop_preview(camera_h camera)
2661 int ret = CAMERA_ERROR_NONE;
2662 camera_cli_s *pc = (camera_cli_s *)camera;
2663 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2664 camera_state_e current_state = CAMERA_STATE_NONE;
2666 if (!pc || !pc->cb_info) {
2667 LOGE("NULL handle");
2668 return CAMERA_ERROR_INVALID_PARAMETER;
2673 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2674 ret = camera_get_state(camera, ¤t_state);
2675 if (ret != CAMERA_ERROR_NONE) {
2676 LOGE("failed to get current state 0x%x", ret);
2680 if (current_state == CAMERA_STATE_PREVIEW) {
2681 ret = _camera_stop_evas_rendering(camera, false);
2682 if (ret != CAMERA_ERROR_NONE)
2687 /* send stop preview message */
2688 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2690 if (ret != CAMERA_ERROR_NONE &&
2691 current_state == CAMERA_STATE_PREVIEW) {
2692 LOGW("restart evas rendering");
2693 _camera_start_evas_rendering(camera);
2696 LOGD("ret : 0x%x", ret);
2702 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2704 int ret = CAMERA_ERROR_NONE;
2705 camera_cli_s *pc = (camera_cli_s *)camera;
2706 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2708 if (!pc || !pc->cb_info) {
2709 LOGE("NULL handle");
2710 return CAMERA_ERROR_INVALID_PARAMETER;
2715 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2716 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2718 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2719 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2721 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2723 LOGD("ret : 0x%x", ret);
2729 bool camera_is_supported_continuous_capture(camera_h camera)
2731 int ret = CAMERA_ERROR_NONE;
2732 camera_cli_s *pc = (camera_cli_s *)camera;
2733 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2735 if (!pc || !pc->cb_info) {
2736 LOGE("NULL handle");
2737 return CAMERA_ERROR_INVALID_PARAMETER;
2742 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2745 LOGE("error is occurred 0x%x", ret);
2749 LOGD("ret : %d", ret);
2755 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)
2757 int ret = CAMERA_ERROR_NONE;
2758 camera_cli_s *pc = (camera_cli_s *)camera;
2759 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2760 camera_msg_param param;
2763 if (!pc || !pc->cb_info) {
2764 LOGE("NULL handle");
2765 return CAMERA_ERROR_INVALID_PARAMETER;
2770 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2771 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2773 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2774 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2776 value = (count << 16) | interval;
2777 CAMERA_MSG_PARAM_SET(param, INT, value);
2779 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2781 LOGD("ret : 0x%x", ret);
2787 int camera_stop_continuous_capture(camera_h camera)
2789 int ret = CAMERA_ERROR_NONE;
2790 camera_cli_s *pc = (camera_cli_s *)camera;
2791 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2793 if (!pc || !pc->cb_info) {
2794 LOGE("NULL handle");
2795 return CAMERA_ERROR_INVALID_PARAMETER;
2800 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2802 LOGD("ret : 0x%x", ret);
2808 bool camera_is_supported_face_detection(camera_h camera)
2810 int ret = CAMERA_ERROR_NONE;
2811 camera_cli_s *pc = (camera_cli_s *)camera;
2812 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2814 if (!pc || !pc->cb_info) {
2815 LOGE("NULL handle");
2816 return CAMERA_ERROR_INVALID_PARAMETER;
2821 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2824 LOGE("error is occurred 0x%x", ret);
2828 LOGD("ret : %d", ret);
2834 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2836 int ret = CAMERA_ERROR_NONE;
2837 camera_cli_s *pc = (camera_cli_s *)camera;
2838 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2840 if (!pc || !pc->cb_info) {
2841 LOGE("NULL handle");
2842 return CAMERA_ERROR_INVALID_PARAMETER;
2847 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2850 LOGE("error is occurred 0x%x", ret);
2854 LOGD("ret : %d", ret);
2860 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2862 int ret = CAMERA_ERROR_NONE;
2863 camera_cli_s *pc = (camera_cli_s *)camera;
2864 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2866 if (!pc || !pc->cb_info) {
2867 LOGE("NULL handle");
2868 return CAMERA_ERROR_INVALID_PARAMETER;
2873 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2876 LOGE("error is occurred 0x%x", ret);
2880 LOGD("ret : %d", ret);
2885 int camera_get_device_count(camera_h camera, int *device_count)
2887 int ret = CAMERA_ERROR_NONE;
2888 camera_cli_s *pc = (camera_cli_s *)camera;
2889 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2891 if (!pc || !pc->cb_info) {
2892 LOGE("NULL handle");
2893 return CAMERA_ERROR_INVALID_PARAMETER;
2898 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2900 if (ret == CAMERA_ERROR_NONE)
2901 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2903 LOGD("ret : 0x%x", ret);
2908 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2910 int ret = CAMERA_ERROR_NONE;
2911 camera_cli_s *pc = (camera_cli_s *)camera;
2912 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2914 if (!pc || !pc->cb_info) {
2915 LOGE("NULL handle");
2916 return CAMERA_ERROR_INVALID_PARAMETER;
2921 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2922 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2924 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2926 LOGD("ret : 0x%x", ret);
2931 int camera_stop_face_detection(camera_h camera)
2933 int ret = CAMERA_ERROR_NONE;
2934 camera_cli_s *pc = (camera_cli_s *)camera;
2935 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
2937 if (!pc || !pc->cb_info) {
2938 LOGE("NULL handle");
2939 return CAMERA_ERROR_INVALID_PARAMETER;
2944 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2946 LOGD("ret : 0x%x", ret);
2951 int camera_get_state(camera_h camera, camera_state_e *state)
2953 int ret = CAMERA_ERROR_NONE;
2954 camera_cli_s *pc = (camera_cli_s *)camera;
2955 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
2957 if (!pc || !pc->cb_info || !state) {
2958 LOGE("NULL pointer %p %p", pc, state);
2959 return CAMERA_ERROR_INVALID_PARAMETER;
2964 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2966 if (ret == CAMERA_ERROR_NONE)
2967 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
2969 LOGD("ret : 0x%x", ret);
2974 int camera_start_focusing(camera_h camera, bool continuous)
2976 int ret = CAMERA_ERROR_NONE;
2977 camera_cli_s *pc = (camera_cli_s *)camera;
2978 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
2979 camera_msg_param param;
2980 int is_continuous = (int)continuous;
2982 if (!pc || !pc->cb_info) {
2983 LOGE("NULL handle");
2984 return CAMERA_ERROR_INVALID_PARAMETER;
2989 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
2991 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2993 LOGD("ret : 0x%x", ret);
2998 int camera_cancel_focusing(camera_h camera)
3000 int ret = CAMERA_ERROR_NONE;
3001 camera_cli_s *pc = (camera_cli_s *)camera;
3002 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3004 if (!pc || !pc->cb_info) {
3005 LOGE("NULL handle");
3006 return CAMERA_ERROR_INVALID_PARAMETER;
3009 LOGD("Enter, remote_handle : %x", pc->remote_handle);
3011 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3013 LOGD("ret : 0x%x", ret);
3018 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3020 int ret = CAMERA_ERROR_NONE;
3021 void *set_display_handle = NULL;
3022 Evas_Object *obj = NULL;
3023 const char *object_type = NULL;
3024 camera_cli_s *pc = (camera_cli_s *)camera;
3025 camera_cb_info_s *cb_info = NULL;
3026 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3027 camera_state_e current_state = CAMERA_STATE_NONE;
3028 camera_msg_param param;
3032 if (!pc || !pc->cb_info) {
3033 LOGE("NULL handle");
3034 return CAMERA_ERROR_INVALID_PARAMETER;
3037 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
3038 LOGE("invalid type %d", type);
3039 return CAMERA_ERROR_INVALID_PARAMETER;
3042 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
3043 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
3044 return CAMERA_ERROR_INVALID_PARAMETER;
3047 cb_info = (camera_cb_info_s *)pc->cb_info;
3049 ret = camera_get_state(camera, ¤t_state);
3050 if (ret != CAMERA_ERROR_NONE) {
3051 LOGE("failed to get current state 0x%x", ret);
3055 if (current_state != CAMERA_STATE_CREATED) {
3056 LOGE("INVALID_STATE : current %d", current_state);
3057 return CAMERA_ERROR_INVALID_STATE;
3060 LOGD("Enter - display : %p", display);
3062 if (type == CAMERA_DISPLAY_TYPE_NONE) {
3063 set_display_handle = 0;
3064 LOGD("display type NONE");
3066 obj = (Evas_Object *)display;
3067 object_type = evas_object_type_get(obj);
3069 if (type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
3070 /* get wayland parent id */
3071 if (_camera_get_wl_info(obj, &pc->wl_info) != CAMERA_ERROR_NONE) {
3072 LOGE("failed to get wayland info");
3073 return CAMERA_ERROR_INVALID_OPERATION;
3076 set_display_handle = (void *)&pc->wl_info;
3077 LOGD("display type OVERLAY : handle %p", set_display_handle);
3078 } else if (type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
3079 /* evas object surface */
3080 set_display_handle = (void *)display;
3081 LOGD("display type EVAS : handle %p", set_display_handle);
3083 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3084 g_mutex_lock(&cb_info->evas_mutex);
3086 if (cb_info->evas_info) {
3087 LOGW("destroy existed evas renderer %p", cb_info->evas_info);
3088 ret = mm_evas_renderer_destroy(&cb_info->evas_info);
3089 if (ret != MM_ERROR_NONE) {
3090 LOGE("failed to destroy evas renderer %p", cb_info->evas_info);
3091 g_mutex_unlock(&cb_info->evas_mutex);
3092 return CAMERA_ERROR_INVALID_OPERATION;
3096 /* create evas renderer */
3097 ret = mm_evas_renderer_create(&cb_info->evas_info, (Evas_Object *)set_display_handle);
3098 if (ret == MM_ERROR_NONE) {
3099 camera_flip_e flip = CAMERA_FLIP_NONE;
3100 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3101 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3108 camera_get_display_flip(camera, &flip);
3109 camera_get_display_mode(camera, &mode);
3110 camera_get_display_rotation(camera, &rotation);
3111 camera_is_display_visible(camera, &visible);
3112 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3114 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
3115 flip, mode, rotation, visible, x, y, width, height);
3117 ret = mm_evas_renderer_set_flip(cb_info->evas_info, flip);
3118 ret |= mm_evas_renderer_set_geometry(cb_info->evas_info, mode);
3119 ret |= mm_evas_renderer_set_rotation(cb_info->evas_info, rotation);
3120 ret |= mm_evas_renderer_set_visible(cb_info->evas_info, visible);
3122 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
3123 ret |= mm_evas_renderer_set_roi_area(cb_info->evas_info, x, y, width, height);
3126 g_mutex_unlock(&cb_info->evas_mutex);
3128 if (ret != MM_ERROR_NONE) {
3129 LOGE("mm_evas_renderer error 0x%x", ret);
3130 return CAMERA_ERROR_INVALID_OPERATION;
3132 #else /* TIZEN_FEATURE_EVAS_RENDERER */
3133 LOGE("EVAS surface is not supported");
3134 return CAMERA_ERROR_NOT_SUPPORTED;
3135 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3137 LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type);
3138 return CAMERA_ERROR_INVALID_PARAMETER;
3141 LOGE("failed to get evas object type from %p", obj);
3142 return CAMERA_ERROR_INVALID_PARAMETER;
3146 pc->display_handle = (intptr_t)set_display_handle;
3148 if (type == CAMERA_DISPLAY_TYPE_OVERLAY) {
3151 length = sizeof(camera_wl_info_s) / sizeof(int) + \
3152 (sizeof(camera_wl_info_s) % sizeof(int) ? 1 : 0);
3154 msg = muse_core_msg_json_factory_new(api,
3155 MUSE_TYPE_INT, "type", type,
3156 MUSE_TYPE_ARRAY, "wl_info", length, (int *)&pc->wl_info,
3159 LOGE("msg creation failed: api %d", api);
3160 return CAMERA_ERROR_OUT_OF_MEMORY;
3163 if (pc->cb_info->is_server_connected) {
3164 g_mutex_lock(&pc->cb_info->fd_lock);
3165 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
3166 g_mutex_unlock(&pc->cb_info->fd_lock);
3170 LOGE("message send failed");
3171 ret = CAMERA_ERROR_INVALID_OPERATION;
3173 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
3176 muse_core_msg_json_factory_free(msg);
3178 LOGD("wayland parent id : %d, window %d,%d,%dx%d",
3179 pc->wl_info.parent_id, pc->wl_info.window_x, pc->wl_info.window_y,
3180 pc->wl_info.window_width, pc->wl_info.window_height);
3182 CAMERA_MSG_PARAM_SET(param, INT, type);
3184 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3187 if (ret != CAMERA_ERROR_NONE)
3188 LOGE("set display error 0x%x", ret);
3189 else if (type == CAMERA_DISPLAY_TYPE_EVAS)
3190 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3196 int camera_set_preview_resolution(camera_h camera, int width, int height)
3198 int ret = CAMERA_ERROR_NONE;
3199 camera_state_e current_state = CAMERA_STATE_NONE;
3200 camera_cli_s *pc = (camera_cli_s *)camera;
3201 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3202 camera_msg_param param;
3205 if (!pc || !pc->cb_info) {
3206 LOGE("NULL handle");
3207 return CAMERA_ERROR_INVALID_PARAMETER;
3210 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3211 ret = camera_get_state(camera, ¤t_state);
3212 if (ret != CAMERA_ERROR_NONE) {
3213 LOGE("failed to get current state 0x%x", ret);
3217 if (current_state == CAMERA_STATE_PREVIEW) {
3218 ret = _camera_stop_evas_rendering(camera, false);
3219 if (ret != CAMERA_ERROR_NONE)
3224 value = (width << 16) | height;
3225 CAMERA_MSG_PARAM_SET(param, INT, value);
3227 LOGD("%dx%d -> 0x%x", width, height, value);
3229 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3231 LOGD("ret : 0x%x", ret);
3233 if (current_state == CAMERA_STATE_PREVIEW) {
3234 LOGW("restart evas rendering");
3235 _camera_start_evas_rendering(camera);
3242 int camera_set_capture_resolution(camera_h camera, int width, int height)
3244 int ret = CAMERA_ERROR_NONE;
3245 camera_cli_s *pc = (camera_cli_s *)camera;
3246 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3247 camera_msg_param param;
3250 if (!pc || !pc->cb_info) {
3251 LOGE("NULL handle");
3252 return CAMERA_ERROR_INVALID_PARAMETER;
3257 value = (width << 16) | height;
3258 CAMERA_MSG_PARAM_SET(param, INT, value);
3260 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3262 LOGD("ret : 0x%x", ret);
3268 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3270 int ret = CAMERA_ERROR_NONE;
3271 int set_format = (int)format;
3272 camera_cli_s *pc = (camera_cli_s *)camera;
3273 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3274 camera_msg_param param;
3276 if (!pc || !pc->cb_info) {
3277 LOGE("NULL handle");
3278 return CAMERA_ERROR_INVALID_PARAMETER;
3281 LOGD("Enter - format %d", set_format);
3283 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3285 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3287 LOGD("ret : 0x%x", ret);
3293 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3295 int ret = CAMERA_ERROR_NONE;
3296 int set_format = (int)format;
3297 camera_msg_param param;
3298 camera_cli_s *pc = (camera_cli_s *)camera;
3299 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3301 if (!pc || !pc->cb_info) {
3302 LOGE("NULL handle");
3303 return CAMERA_ERROR_INVALID_PARAMETER;
3306 LOGD("Enter - capture_format %d", set_format);
3308 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3310 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3312 LOGD("ret : 0x%x", ret);
3318 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3320 int ret = CAMERA_ERROR_NONE;
3321 camera_cli_s *pc = (camera_cli_s *)camera;
3322 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3324 if (!pc || !pc->cb_info || !width || !height) {
3325 LOGE("NULL pointer %p %p %p", pc, width, height);
3326 return CAMERA_ERROR_INVALID_PARAMETER;
3331 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3333 if (ret == CAMERA_ERROR_NONE) {
3334 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3335 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3338 LOGD("ret : 0x%x", ret);
3344 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3346 int ret = CAMERA_ERROR_NONE;
3347 int set_rotation = (int)rotation;
3348 camera_cli_s *pc = (camera_cli_s *)camera;
3349 camera_msg_param param;
3351 if (!pc || !pc->cb_info) {
3352 LOGE("NULL handle");
3353 return CAMERA_ERROR_INVALID_PARAMETER;
3356 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3357 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3358 g_mutex_lock(&pc->cb_info->evas_mutex);
3360 ret = mm_evas_renderer_set_rotation(pc->cb_info->evas_info, rotation);
3362 g_mutex_unlock(&pc->cb_info->evas_mutex);
3364 if (ret != MM_ERROR_NONE) {
3365 LOGE("failed to set rotation for evas surface 0x%x", ret);
3366 return CAMERA_ERROR_INVALID_OPERATION;
3369 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3371 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3373 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3379 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3381 int ret = CAMERA_ERROR_NONE;
3382 camera_cli_s *pc = (camera_cli_s *)camera;
3384 if (!pc || !pc->cb_info || !rotation) {
3385 LOGE("NULL pointer %p %p", pc, rotation);
3386 return CAMERA_ERROR_INVALID_PARAMETER;
3389 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3391 if (ret == CAMERA_ERROR_NONE)
3392 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3398 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3400 int ret = CAMERA_ERROR_NONE;
3401 int set_flip = (int)flip;
3402 camera_cli_s *pc = (camera_cli_s *)camera;
3403 camera_msg_param param;
3405 if (!pc || !pc->cb_info) {
3406 LOGE("NULL handle");
3407 return CAMERA_ERROR_INVALID_PARAMETER;
3410 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3411 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3412 g_mutex_lock(&pc->cb_info->evas_mutex);
3414 ret = mm_evas_renderer_set_flip(pc->cb_info->evas_info, flip);
3416 g_mutex_unlock(&pc->cb_info->evas_mutex);
3418 if (ret != MM_ERROR_NONE) {
3419 LOGE("failed to set flip for evas surface 0x%x", ret);
3420 return CAMERA_ERROR_INVALID_OPERATION;
3423 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3425 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3427 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3433 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3435 int ret = CAMERA_ERROR_NONE;
3436 camera_cli_s *pc = (camera_cli_s *)camera;
3438 if (!pc || !pc->cb_info || !flip) {
3439 LOGE("NULL pointer %p %p", pc, flip);
3440 return CAMERA_ERROR_INVALID_PARAMETER;
3443 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3445 if (ret == CAMERA_ERROR_NONE)
3446 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3452 int camera_set_display_visible(camera_h camera, bool visible)
3454 int ret = CAMERA_ERROR_NONE;
3455 int set_visible = (int)visible;
3456 camera_cli_s *pc = (camera_cli_s *)camera;
3457 camera_msg_param param;
3459 if (!pc || !pc->cb_info) {
3460 LOGE("NULL handle");
3461 return CAMERA_ERROR_INVALID_PARAMETER;
3464 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3465 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3466 g_mutex_lock(&pc->cb_info->evas_mutex);
3468 ret = mm_evas_renderer_set_visible(pc->cb_info->evas_info, visible);
3470 g_mutex_unlock(&pc->cb_info->evas_mutex);
3472 if (ret != MM_ERROR_NONE) {
3473 LOGE("failed to set visible for evas surface 0x%x", ret);
3474 return CAMERA_ERROR_INVALID_OPERATION;
3477 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3479 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3481 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3487 int camera_is_display_visible(camera_h camera, bool *visible)
3489 int ret = CAMERA_ERROR_NONE;
3490 camera_cli_s *pc = (camera_cli_s *)camera;
3492 if (!pc || !pc->cb_info || !visible) {
3493 LOGE("NULL pointer %p %p", pc, visible);
3494 return CAMERA_ERROR_INVALID_PARAMETER;
3497 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3499 if (ret == CAMERA_ERROR_NONE)
3500 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3506 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3508 int ret = CAMERA_ERROR_NONE;
3509 int set_mode = (int)mode;
3510 camera_cli_s *pc = (camera_cli_s *)camera;
3511 camera_msg_param param;
3513 if (!pc || !pc->cb_info) {
3514 LOGE("NULL handle");
3515 return CAMERA_ERROR_INVALID_PARAMETER;
3518 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3519 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3520 g_mutex_lock(&pc->cb_info->evas_mutex);
3522 ret = mm_evas_renderer_set_geometry(pc->cb_info->evas_info, mode);
3524 g_mutex_unlock(&pc->cb_info->evas_mutex);
3526 if (ret != MM_ERROR_NONE) {
3527 LOGE("failed to set geometry for evas surface 0x%x", ret);
3528 return CAMERA_ERROR_INVALID_OPERATION;
3531 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3533 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3535 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3541 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3543 int ret = CAMERA_ERROR_NONE;
3544 camera_cli_s *pc = (camera_cli_s *)camera;
3546 if (!pc || !pc->cb_info || !mode) {
3547 LOGE("NULL pointer %p %p", pc, mode);
3548 return CAMERA_ERROR_INVALID_PARAMETER;
3551 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3553 if (ret == CAMERA_ERROR_NONE)
3554 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3560 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3562 int ret = CAMERA_ERROR_NONE;
3563 int set_hint = (int)hint;
3564 camera_cli_s *pc = (camera_cli_s *)camera;
3565 camera_msg_param param;
3567 if (!pc || !pc->cb_info) {
3568 LOGE("NULL handle");
3569 return CAMERA_ERROR_INVALID_PARAMETER;
3572 LOGD("Enter - hint %d", set_hint);
3574 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3576 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3582 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3584 int ret = CAMERA_ERROR_NONE;
3585 camera_cli_s *pc = (camera_cli_s *)camera;
3586 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3588 if (!pc || !pc->cb_info || !hint) {
3589 LOGE("NULL pointer %p %p", pc, hint);
3590 return CAMERA_ERROR_INVALID_PARAMETER;
3593 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3595 if (ret == CAMERA_ERROR_NONE) {
3596 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3597 LOGD("display reuse hint %d", *hint);
3604 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3606 int ret = CAMERA_ERROR_NONE;
3607 camera_cli_s *pc = (camera_cli_s *)camera;
3608 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3610 if (!pc || !pc->cb_info || !width || !height) {
3611 LOGE("NULL pointer %p %p %p", pc, width, height);
3612 return CAMERA_ERROR_INVALID_PARAMETER;
3617 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3619 if (ret == CAMERA_ERROR_NONE) {
3620 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3621 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3624 LOGD("ret : 0x%x", ret);
3630 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3632 int ret = CAMERA_ERROR_NONE;
3633 camera_cli_s *pc = (camera_cli_s *)camera;
3634 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3636 if (!pc || !pc->cb_info || !format) {
3637 LOGE("NULL pointer %p %p", pc, format);
3638 return CAMERA_ERROR_INVALID_PARAMETER;
3643 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3645 if (ret == CAMERA_ERROR_NONE)
3646 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3648 LOGD("ret : 0x%x", ret);
3654 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3656 int ret = CAMERA_ERROR_NONE;
3657 camera_cli_s *pc = (camera_cli_s *)camera;
3658 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3660 if (!pc || !pc->cb_info || !format) {
3661 LOGE("NULL pointer %p %p", pc, format);
3662 return CAMERA_ERROR_INVALID_PARAMETER;
3667 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3669 if (ret == CAMERA_ERROR_NONE)
3670 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3672 LOGD("ret : 0x%x", ret);
3678 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3680 int ret = CAMERA_ERROR_NONE;
3681 camera_cli_s *pc = (camera_cli_s *)camera;
3682 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3684 if (!pc || !pc->cb_info || !facing_direction) {
3685 LOGE("NULL pointer %p %p", pc, facing_direction);
3686 return CAMERA_ERROR_INVALID_PARAMETER;
3691 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3693 if (ret == CAMERA_ERROR_NONE)
3694 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3696 LOGD("ret : 0x%x", ret);
3702 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3704 int ret = CAMERA_ERROR_NONE;
3705 camera_cli_s *pc = (camera_cli_s *)camera;
3706 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3708 if (!pc || !pc->cb_info || !callback) {
3709 LOGE("NULL pointer %p %p", pc, callback);
3710 return CAMERA_ERROR_INVALID_PARAMETER;
3715 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3717 if (ret == CAMERA_ERROR_NONE) {
3718 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3719 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3720 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3723 LOGD("ret : 0x%x", ret);
3729 int camera_unset_preview_cb(camera_h camera)
3731 int ret = CAMERA_ERROR_NONE;
3732 camera_cli_s *pc = (camera_cli_s *)camera;
3733 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3735 if (!pc || !pc->cb_info) {
3736 LOGE("NULL handle");
3737 return CAMERA_ERROR_INVALID_PARAMETER;
3742 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3743 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3745 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3747 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3749 LOGD("ret : 0x%x", ret);
3755 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3757 int ret = CAMERA_ERROR_NONE;
3758 camera_cli_s *pc = (camera_cli_s *)camera;
3759 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3761 if (!pc || !pc->cb_info) {
3762 LOGE("NULL handle");
3763 return CAMERA_ERROR_INVALID_PARAMETER;
3766 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3767 LOGE("NOT SUPPORTED");
3768 return CAMERA_ERROR_NOT_SUPPORTED;
3771 if (callback == NULL) {
3772 LOGE("NULL callback");
3773 return CAMERA_ERROR_INVALID_PARAMETER;
3778 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3780 if (ret == CAMERA_ERROR_NONE) {
3781 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3782 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3785 LOGD("ret : 0x%x", ret);
3791 int camera_unset_media_packet_preview_cb(camera_h camera)
3793 int ret = CAMERA_ERROR_NONE;
3794 camera_cli_s *pc = (camera_cli_s *)camera;
3795 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3797 if (!pc || !pc->cb_info) {
3798 LOGE("NULL handle");
3799 return CAMERA_ERROR_INVALID_PARAMETER;
3804 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3805 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3807 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3809 LOGD("ret : 0x%x", ret);
3815 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3817 int ret = CAMERA_ERROR_NONE;
3818 camera_cli_s *pc = (camera_cli_s *)camera;
3819 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3821 if (!pc || !pc->cb_info || !callback) {
3822 LOGE("NULL pointer %p %p", pc, callback);
3823 return CAMERA_ERROR_INVALID_PARAMETER;
3828 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3830 if (ret == CAMERA_ERROR_NONE) {
3831 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3832 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3835 LOGD("ret : 0x%x", ret);
3841 int camera_unset_state_changed_cb(camera_h camera)
3843 int ret = CAMERA_ERROR_NONE;
3844 camera_cli_s *pc = (camera_cli_s *)camera;
3845 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3847 if (!pc || !pc->cb_info) {
3848 LOGE("NULL handle");
3849 return CAMERA_ERROR_INVALID_PARAMETER;
3854 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3855 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3857 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3859 LOGD("ret : 0x%x", ret);
3865 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3867 int ret = CAMERA_ERROR_NONE;
3868 camera_cli_s *pc = (camera_cli_s *)camera;
3869 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3871 if (!pc || !pc->cb_info || !callback) {
3872 LOGE("NULL pointer %p %p", pc, callback);
3873 return CAMERA_ERROR_INVALID_PARAMETER;
3878 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3880 if (ret == CAMERA_ERROR_NONE) {
3881 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3882 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3885 LOGD("ret : 0x%x", ret);
3891 int camera_unset_interrupted_cb(camera_h camera)
3893 int ret = CAMERA_ERROR_NONE;
3894 camera_cli_s *pc = (camera_cli_s *)camera;
3895 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3897 if (!pc || !pc->cb_info) {
3898 LOGE("NULL handle");
3899 return CAMERA_ERROR_INVALID_PARAMETER;
3904 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3905 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3907 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3909 LOGD("ret : 0x%x", ret);
3915 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
3917 int ret = CAMERA_ERROR_NONE;
3918 camera_cli_s *pc = (camera_cli_s *)camera;
3919 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3921 if (!pc || !pc->cb_info || !callback) {
3922 LOGE("NULL pointer %p %p", pc, callback);
3923 return CAMERA_ERROR_INVALID_PARAMETER;
3928 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3930 if (ret == CAMERA_ERROR_NONE) {
3931 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3932 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3935 LOGD("ret : 0x%x", ret);
3941 int camera_unset_focus_changed_cb(camera_h camera)
3943 int ret = CAMERA_ERROR_NONE;
3944 camera_cli_s *pc = (camera_cli_s *)camera;
3945 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
3947 if (!pc || !pc->cb_info) {
3948 LOGE("NULL handle");
3949 return CAMERA_ERROR_INVALID_PARAMETER;
3954 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3955 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3957 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3959 LOGD("ret : 0x%x", ret);
3965 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
3967 int ret = CAMERA_ERROR_NONE;
3968 camera_cli_s *pc = (camera_cli_s *)camera;
3969 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
3971 if (!pc || !pc->cb_info || !callback) {
3972 LOGE("NULL pointer %p %p", pc, callback);
3973 return CAMERA_ERROR_INVALID_PARAMETER;
3978 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3980 if (ret == CAMERA_ERROR_NONE) {
3981 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
3982 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
3985 LOGD("ret : 0x%x", ret);
3991 int camera_unset_error_cb(camera_h camera)
3993 int ret = CAMERA_ERROR_NONE;
3994 camera_cli_s *pc = (camera_cli_s *)camera;
3995 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
3997 if (!pc || !pc->cb_info) {
3998 LOGE("NULL handle");
3999 return CAMERA_ERROR_INVALID_PARAMETER;
4004 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4005 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4007 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4009 LOGD("ret : 0x%x", ret);
4015 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4017 int ret = CAMERA_ERROR_NONE;
4018 camera_cli_s *pc = (camera_cli_s *)camera;
4019 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4021 if (!pc || !pc->cb_info || !foreach_cb) {
4022 LOGE("NULL pointer %p %p", pc, foreach_cb);
4023 return CAMERA_ERROR_INVALID_PARAMETER;
4028 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4029 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4031 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4033 LOGD("ret : 0x%x", ret);
4039 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4041 int ret = CAMERA_ERROR_NONE;
4042 camera_cli_s *pc = (camera_cli_s *)camera;
4043 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4045 if (!pc || !pc->cb_info || !foreach_cb) {
4046 LOGE("NULL pointer %p %p", pc, foreach_cb);
4047 return CAMERA_ERROR_INVALID_PARAMETER;
4052 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4053 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4055 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4057 LOGD("ret : 0x%x", ret);
4063 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4065 int ret = CAMERA_ERROR_NONE;
4066 camera_cli_s *pc = (camera_cli_s *)camera;
4067 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4069 if (!pc || !pc->cb_info || !foreach_cb) {
4070 LOGE("NULL pointer %p %p", pc, foreach_cb);
4071 return CAMERA_ERROR_INVALID_PARAMETER;
4076 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4077 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4079 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4081 LOGD("ret : 0x%x", ret);
4087 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4089 int ret = CAMERA_ERROR_NONE;
4090 camera_cli_s *pc = (camera_cli_s *)camera;
4091 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4093 if (!pc || !pc->cb_info || !foreach_cb) {
4094 LOGE("NULL pointer %p %p", pc, foreach_cb);
4095 return CAMERA_ERROR_INVALID_PARAMETER;
4100 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4101 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4103 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4105 LOGD("ret : 0x%x", ret);
4111 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4113 int ret = CAMERA_ERROR_NONE;
4114 camera_cli_s *pc = (camera_cli_s *)camera;
4115 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4117 if (!pc || !pc->cb_info || !width || !height) {
4118 LOGE("NULL pointer %p %p %p", pc, width, height);
4119 return CAMERA_ERROR_INVALID_PARAMETER;
4123 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4125 if (ret == CAMERA_ERROR_NONE) {
4126 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4127 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4130 LOGD("ret : 0x%x", ret);
4136 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4138 int ret = CAMERA_ERROR_NONE;
4139 camera_cli_s *pc = (camera_cli_s *)camera;
4140 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4142 if (!pc || !pc->cb_info || !angle) {
4143 LOGE("NULL pointer %p %p", pc, angle);
4144 return CAMERA_ERROR_INVALID_PARAMETER;
4149 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4151 if (ret == CAMERA_ERROR_NONE)
4152 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4154 LOGD("ret : 0x%x", ret);
4160 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4162 int ret = CAMERA_ERROR_NONE;
4163 camera_cli_s *pc = (camera_cli_s *)camera;
4164 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4165 camera_msg_param param;
4166 int set_mode = (int)mode;
4168 if (!pc || !pc->cb_info) {
4169 LOGE("NULL handle");
4170 return CAMERA_ERROR_INVALID_PARAMETER;
4175 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4177 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4179 LOGD("ret : 0x%x", ret);
4185 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4187 int ret = CAMERA_ERROR_NONE;
4188 camera_cli_s *pc = (camera_cli_s *)camera;
4189 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4191 if (!pc || !pc->cb_info || !mode) {
4192 LOGE("NULL pointer %p %p", pc, mode);
4193 return CAMERA_ERROR_INVALID_PARAMETER;
4198 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4200 if (ret == CAMERA_ERROR_NONE)
4201 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4203 LOGD("ret : 0x%x", ret);
4209 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4211 int ret = CAMERA_ERROR_NONE;
4212 camera_cli_s *pc = (camera_cli_s *)camera;
4213 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4215 if (!pc || !pc->cb_info || !foreach_cb) {
4216 LOGE("NULL pointer %p %p", pc, foreach_cb);
4217 return CAMERA_ERROR_INVALID_PARAMETER;
4222 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4223 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4225 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4227 LOGD("Finish, return :%x", ret);
4233 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4235 int ret = CAMERA_ERROR_NONE;
4236 camera_cli_s *pc = (camera_cli_s *)camera;
4237 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4238 camera_msg_param param;
4239 int set_fps = (int)fps;
4241 if (!pc || !pc->cb_info) {
4242 LOGE("NULL handle");
4243 return CAMERA_ERROR_INVALID_PARAMETER;
4248 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4250 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4252 LOGD("ret : 0x%x", ret);
4258 int camera_attr_set_image_quality(camera_h camera, int quality)
4260 int ret = CAMERA_ERROR_NONE;
4261 camera_cli_s *pc = (camera_cli_s *)camera;
4262 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4263 camera_msg_param param;
4265 if (!pc || !pc->cb_info) {
4266 LOGE("NULL handle");
4267 return CAMERA_ERROR_INVALID_PARAMETER;
4272 CAMERA_MSG_PARAM_SET(param, INT, quality);
4274 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4276 LOGD("ret : 0x%x", ret);
4282 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4284 int ret = CAMERA_ERROR_NONE;
4285 camera_cli_s *pc = (camera_cli_s *)camera;
4286 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4288 if (!pc || !pc->cb_info || !fps) {
4289 LOGE("NULL pointer %p %p", pc, fps);
4290 return CAMERA_ERROR_INVALID_PARAMETER;
4295 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4297 if (ret == CAMERA_ERROR_NONE)
4298 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4300 LOGD("ret : 0x%x", ret);
4306 int camera_attr_get_image_quality(camera_h camera, int *quality)
4308 int ret = CAMERA_ERROR_NONE;
4309 camera_cli_s *pc = (camera_cli_s *)camera;
4310 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4312 if (!pc || !pc->cb_info || !quality) {
4313 LOGE("NULL pointer %p %p", pc, quality);
4314 return CAMERA_ERROR_INVALID_PARAMETER;
4319 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4321 if (ret == CAMERA_ERROR_NONE)
4322 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4324 LOGD("ret : 0x%x", ret);
4330 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4332 int ret = CAMERA_ERROR_NONE;
4333 camera_cli_s *pc = (camera_cli_s *)camera;
4334 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4336 if (!pc || !pc->cb_info || !bitrate) {
4337 LOGE("NULL pointer %p %p", pc, bitrate);
4338 return CAMERA_ERROR_INVALID_PARAMETER;
4343 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4345 if (ret == CAMERA_ERROR_NONE)
4346 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4348 LOGD("ret : 0x%x", ret);
4354 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4356 int ret = CAMERA_ERROR_NONE;
4357 camera_cli_s *pc = (camera_cli_s *)camera;
4358 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4359 camera_msg_param param;
4360 int set_bitrate = bitrate;
4362 if (!pc || !pc->cb_info) {
4363 LOGE("NULL handle");
4364 return CAMERA_ERROR_INVALID_PARAMETER;
4369 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4371 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4373 LOGD("ret : 0x%x", ret);
4379 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4381 int ret = CAMERA_ERROR_NONE;
4382 camera_cli_s *pc = (camera_cli_s *)camera;
4383 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4385 if (!pc || !pc->cb_info || !interval) {
4386 LOGE("NULL pointer %p %p", pc, interval);
4387 return CAMERA_ERROR_INVALID_PARAMETER;
4392 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4394 if (ret == CAMERA_ERROR_NONE)
4395 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4397 LOGD("ret : 0x%x", ret);
4403 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4405 int ret = CAMERA_ERROR_NONE;
4406 camera_cli_s *pc = (camera_cli_s *)camera;
4407 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4408 camera_msg_param param;
4409 int set_gop_interval = interval;
4411 if (!pc || !pc->cb_info) {
4412 LOGE("NULL handle");
4413 return CAMERA_ERROR_INVALID_PARAMETER;
4418 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4420 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4422 LOGD("ret : 0x%x", ret);
4428 int camera_attr_set_zoom(camera_h camera, int zoom)
4430 int ret = CAMERA_ERROR_NONE;
4431 camera_cli_s *pc = (camera_cli_s *)camera;
4432 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4433 camera_msg_param param;
4435 if (!pc || !pc->cb_info) {
4436 LOGE("NULL handle");
4437 return CAMERA_ERROR_INVALID_PARAMETER;
4440 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4442 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4444 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4446 LOGD("ret : 0x%x", ret);
4452 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4454 int ret = CAMERA_ERROR_NONE;
4455 camera_cli_s *pc = (camera_cli_s *)camera;
4456 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4457 camera_msg_param param;
4458 int set_mode = (int)mode;
4460 if (!pc || !pc->cb_info) {
4461 LOGE("NULL handle");
4462 return CAMERA_ERROR_INVALID_PARAMETER;
4465 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4467 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4469 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4475 int camera_attr_set_af_area(camera_h camera, int x, int y)
4477 int ret = CAMERA_ERROR_NONE;
4478 camera_cli_s *pc = (camera_cli_s *)camera;
4479 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4480 camera_msg_param param;
4483 if (!pc || !pc->cb_info) {
4484 LOGE("NULL handle");
4485 return CAMERA_ERROR_INVALID_PARAMETER;
4488 LOGD("Enter - %d,%d", x, y);
4490 value = (x << 16) | y;
4491 CAMERA_MSG_PARAM_SET(param, INT, value);
4493 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4495 LOGD("ret : 0x%x", ret);
4501 int camera_attr_clear_af_area(camera_h camera)
4503 int ret = CAMERA_ERROR_NONE;
4504 camera_cli_s *pc = (camera_cli_s *)camera;
4505 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4507 if (!pc || !pc->cb_info) {
4508 LOGE("NULL handle");
4509 return CAMERA_ERROR_INVALID_PARAMETER;
4514 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4516 LOGD("ret : 0x%x", ret);
4522 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4524 int ret = CAMERA_ERROR_NONE;
4525 camera_cli_s *pc = (camera_cli_s *)camera;
4526 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4527 camera_msg_param param;
4528 int set_mode = (int)mode;
4530 if (!pc || !pc->cb_info) {
4531 LOGE("NULL handle");
4532 return CAMERA_ERROR_INVALID_PARAMETER;
4537 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4539 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4541 LOGD("ret : 0x%x", ret);
4547 int camera_attr_set_exposure(camera_h camera, int value)
4549 int ret = CAMERA_ERROR_NONE;
4550 camera_cli_s *pc = (camera_cli_s *)camera;
4551 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4552 camera_msg_param param;
4554 if (!pc || !pc->cb_info) {
4555 LOGE("NULL handle");
4556 return CAMERA_ERROR_INVALID_PARAMETER;
4561 CAMERA_MSG_PARAM_SET(param, INT, value);
4563 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4565 LOGD("ret : 0x%x", ret);
4571 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4573 int ret = CAMERA_ERROR_NONE;
4574 camera_cli_s *pc = (camera_cli_s *)camera;
4575 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4576 camera_msg_param param;
4577 int set_iso = (int)iso;
4579 if (!pc || !pc->cb_info) {
4580 LOGE("NULL handle");
4581 return CAMERA_ERROR_INVALID_PARAMETER;
4586 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4588 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4590 LOGD("ret : 0x%x", ret);
4596 int camera_attr_set_brightness(camera_h camera, int level)
4598 int ret = CAMERA_ERROR_NONE;
4599 camera_cli_s *pc = (camera_cli_s *)camera;
4600 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4601 camera_msg_param param;
4603 if (!pc || !pc->cb_info) {
4604 LOGE("NULL handle");
4605 return CAMERA_ERROR_INVALID_PARAMETER;
4610 CAMERA_MSG_PARAM_SET(param, INT, level);
4612 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4614 LOGD("ret : 0x%x", ret);
4620 int camera_attr_set_contrast(camera_h camera, int level)
4622 int ret = CAMERA_ERROR_NONE;
4623 camera_cli_s *pc = (camera_cli_s *)camera;
4624 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4625 camera_msg_param param;
4627 if (!pc || !pc->cb_info) {
4628 LOGE("NULL handle");
4629 return CAMERA_ERROR_INVALID_PARAMETER;
4634 CAMERA_MSG_PARAM_SET(param, INT, level);
4636 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4638 LOGD("ret : 0x%x", ret);
4644 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4646 int ret = CAMERA_ERROR_NONE;
4647 camera_cli_s *pc = (camera_cli_s *)camera;
4648 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4649 camera_msg_param param;
4650 int set_whitebalance = (int)wb;
4652 if (!pc || !pc->cb_info) {
4653 LOGE("NULL handle");
4654 return CAMERA_ERROR_INVALID_PARAMETER;
4659 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4661 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4663 LOGD("ret : 0x%x", ret);
4669 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4671 int ret = CAMERA_ERROR_NONE;
4672 camera_cli_s *pc = (camera_cli_s *)camera;
4673 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4674 camera_msg_param param;
4675 int set_effect = (int)effect;
4677 if (!pc || !pc->cb_info) {
4678 LOGE("NULL handle");
4679 return CAMERA_ERROR_INVALID_PARAMETER;
4684 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4686 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4688 LOGD("ret : 0x%x", ret);
4694 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4696 int ret = CAMERA_ERROR_NONE;
4697 camera_cli_s *pc = (camera_cli_s *)camera;
4698 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4699 camera_msg_param param;
4700 int set_mode = (int)mode;
4702 if (!pc || !pc->cb_info) {
4703 LOGE("NULL handle");
4704 return CAMERA_ERROR_INVALID_PARAMETER;
4709 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4711 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4713 LOGD("ret : 0x%x", ret);
4719 int camera_attr_enable_tag(camera_h camera, bool enable)
4721 int ret = CAMERA_ERROR_NONE;
4722 camera_cli_s *pc = (camera_cli_s *)camera;
4723 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4724 camera_msg_param param;
4725 int set_enable = (int)enable;
4727 if (!pc || !pc->cb_info) {
4728 LOGE("NULL handle");
4729 return CAMERA_ERROR_INVALID_PARAMETER;
4734 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4736 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4738 LOGD("ret : 0x%x", ret);
4744 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4746 int ret = CAMERA_ERROR_NONE;
4747 camera_cli_s *pc = (camera_cli_s *)camera;
4748 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4749 camera_msg_param param;
4751 if (!pc || !pc->cb_info || !description) {
4752 LOGE("NULL pointer %p %p", pc, description);
4753 return CAMERA_ERROR_INVALID_PARAMETER;
4758 CAMERA_MSG_PARAM_SET(param, STRING, description);
4760 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4762 LOGD("ret : 0x%x", ret);
4768 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4770 int ret = CAMERA_ERROR_NONE;
4771 camera_cli_s *pc = (camera_cli_s *)camera;
4772 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4773 camera_msg_param param;
4774 int set_orientation = (int)orientation;
4776 if (!pc || !pc->cb_info) {
4777 LOGE("NULL handle");
4778 return CAMERA_ERROR_INVALID_PARAMETER;
4783 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4785 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4787 LOGD("ret : 0x%x", ret);
4793 int camera_attr_set_tag_software(camera_h camera, const char *software)
4795 int ret = CAMERA_ERROR_NONE;
4796 camera_cli_s *pc = (camera_cli_s *)camera;
4797 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4798 camera_msg_param param;
4800 if (!pc || !pc->cb_info || !software) {
4801 LOGE("NULL pointer %p %p", pc, software);
4802 return CAMERA_ERROR_INVALID_PARAMETER;
4805 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4807 CAMERA_MSG_PARAM_SET(param, STRING, software);
4809 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4811 LOGD("ret : 0x%x", ret);
4817 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4819 int ret = CAMERA_ERROR_NONE;
4820 camera_cli_s *pc = (camera_cli_s *)camera;
4821 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4822 double set_geotag[3] = {latitude, longitude, altitude};
4827 if (!pc || !pc->cb_info) {
4828 LOGE("NULL handle");
4829 return CAMERA_ERROR_INVALID_PARAMETER;
4834 length = sizeof(set_geotag) / sizeof(int) + \
4835 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4837 msg = muse_core_msg_json_factory_new(api,
4838 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4841 LOGE("msg creation failed: api %d", api);
4842 return CAMERA_ERROR_OUT_OF_MEMORY;
4845 if (pc->cb_info->is_server_connected) {
4846 g_mutex_lock(&pc->cb_info->fd_lock);
4847 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
4848 g_mutex_unlock(&pc->cb_info->fd_lock);
4852 LOGE("message send failed");
4853 ret = CAMERA_ERROR_INVALID_OPERATION;
4855 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
4858 muse_core_msg_json_factory_free(msg);
4860 LOGD("ret : 0x%x", ret);
4866 int camera_attr_remove_geotag(camera_h camera)
4868 int ret = CAMERA_ERROR_NONE;
4869 camera_cli_s *pc = (camera_cli_s *)camera;
4870 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4872 if (!pc || !pc->cb_info) {
4873 LOGE("NULL handle");
4874 return CAMERA_ERROR_INVALID_PARAMETER;
4879 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4881 LOGD("ret : 0x%x", ret);
4887 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4889 int ret = CAMERA_ERROR_NONE;
4890 camera_cli_s *pc = (camera_cli_s *)camera;
4891 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
4892 camera_msg_param param;
4893 int set_mode = (int)mode;
4895 if (!pc || !pc->cb_info) {
4896 LOGE("NULL handle");
4897 return CAMERA_ERROR_INVALID_PARAMETER;
4902 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4904 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4906 LOGD("ret : 0x%x", ret);
4912 int camera_attr_get_zoom(camera_h camera, int *zoom)
4914 int ret = CAMERA_ERROR_NONE;
4915 camera_cli_s *pc = (camera_cli_s *)camera;
4916 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4918 if (!pc || !pc->cb_info || !zoom) {
4919 LOGE("NULL pointer %p %p", pc, zoom);
4920 return CAMERA_ERROR_INVALID_PARAMETER;
4925 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4927 if (ret == CAMERA_ERROR_NONE)
4928 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
4930 LOGD("ret : 0x%x", ret);
4936 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
4938 int ret = CAMERA_ERROR_NONE;
4939 camera_cli_s *pc = (camera_cli_s *)camera;
4940 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
4942 if (!pc || !pc->cb_info || !min || !max) {
4943 LOGE("NULL pointer %p %p %p", pc, min, max);
4944 return CAMERA_ERROR_INVALID_PARAMETER;
4949 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4951 if (ret == CAMERA_ERROR_NONE) {
4952 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
4953 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
4956 LOGD("ret : 0x%x", ret);
4962 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
4964 int ret = CAMERA_ERROR_NONE;
4965 camera_cli_s *pc = (camera_cli_s *)camera;
4966 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
4968 if (!pc || !pc->cb_info || !mode) {
4969 LOGE("NULL pointer %p %p", pc, mode);
4970 return CAMERA_ERROR_INVALID_PARAMETER;
4975 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4977 if (ret == CAMERA_ERROR_NONE)
4978 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
4980 LOGD("ret : 0x%x", ret);
4986 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
4988 int ret = CAMERA_ERROR_NONE;
4989 camera_cli_s *pc = (camera_cli_s *)camera;
4990 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
4992 if (!pc || !pc->cb_info || !mode) {
4993 LOGE("NULL pointer %p %p", pc, mode);
4994 return CAMERA_ERROR_INVALID_PARAMETER;
4999 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5001 if (ret == CAMERA_ERROR_NONE)
5002 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5004 LOGD("ret : 0x%x", ret);
5010 int camera_attr_get_exposure(camera_h camera, int *value)
5012 int ret = CAMERA_ERROR_NONE;
5013 camera_cli_s *pc = (camera_cli_s *)camera;
5014 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5016 if (!pc || !pc->cb_info || !value) {
5017 LOGE("NULL pointer %p %p", pc, value);
5018 return CAMERA_ERROR_INVALID_PARAMETER;
5023 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5025 if (ret == CAMERA_ERROR_NONE)
5026 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5028 LOGD("ret : 0x%x", ret);
5034 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5036 int ret = CAMERA_ERROR_NONE;
5037 camera_cli_s *pc = (camera_cli_s *)camera;
5038 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5040 if (!pc || !pc->cb_info || !min || !max) {
5041 LOGE("NULL pointer %p %p %p", pc, min, max);
5042 return CAMERA_ERROR_INVALID_PARAMETER;
5047 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5049 if (ret == CAMERA_ERROR_NONE) {
5050 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5051 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5054 LOGD("ret : 0x%x", ret);
5060 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5062 int ret = CAMERA_ERROR_NONE;
5063 camera_cli_s *pc = (camera_cli_s *)camera;
5064 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5066 if (!pc || !pc->cb_info || !iso) {
5067 LOGE("NULL pointer %p %p", pc, iso);
5068 return CAMERA_ERROR_INVALID_PARAMETER;
5073 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5075 if (ret == CAMERA_ERROR_NONE)
5076 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5078 LOGD("ret : 0x%x", ret);
5084 int camera_attr_get_brightness(camera_h camera, int *level)
5086 int ret = CAMERA_ERROR_NONE;
5087 camera_cli_s *pc = (camera_cli_s *)camera;
5088 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5090 if (!pc || !pc->cb_info || !level) {
5091 LOGE("NULL pointer %p %p", pc, level);
5092 return CAMERA_ERROR_INVALID_PARAMETER;
5097 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5099 if (ret == CAMERA_ERROR_NONE)
5100 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5102 LOGD("ret : 0x%x", ret);
5108 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5110 int ret = CAMERA_ERROR_NONE;
5111 camera_cli_s *pc = (camera_cli_s *)camera;
5112 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5114 if (!pc || !pc->cb_info || !min || !max) {
5115 LOGE("NULL pointer %p %p %p", pc, min, max);
5116 return CAMERA_ERROR_INVALID_PARAMETER;
5121 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5123 if (ret == CAMERA_ERROR_NONE) {
5124 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5125 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5128 LOGD("ret : 0x%x", ret);
5134 int camera_attr_get_contrast(camera_h camera, int *level)
5136 int ret = CAMERA_ERROR_NONE;
5137 camera_cli_s *pc = (camera_cli_s *)camera;
5138 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5140 if (!pc || !pc->cb_info || !level) {
5141 LOGE("NULL pointer %p %p", pc, level);
5142 return CAMERA_ERROR_INVALID_PARAMETER;
5147 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5149 if (ret == CAMERA_ERROR_NONE)
5150 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5152 LOGD("ret : 0x%x", ret);
5158 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5160 int ret = CAMERA_ERROR_NONE;
5161 camera_cli_s *pc = (camera_cli_s *)camera;
5162 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5164 if (!pc || !pc->cb_info || !min || !max) {
5165 LOGE("NULL pointer %p %p %p", pc, min, max);
5166 return CAMERA_ERROR_INVALID_PARAMETER;
5171 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5173 if (ret == CAMERA_ERROR_NONE) {
5174 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5175 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5176 LOGD("min %d, max %d", *min, *max);
5179 LOGD("ret : 0x%x", ret);
5185 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5187 int ret = CAMERA_ERROR_NONE;
5188 camera_cli_s *pc = (camera_cli_s *)camera;
5189 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5191 if (!pc || !pc->cb_info || !wb) {
5192 LOGE("NULL pointer %p %p", pc, wb);
5193 return CAMERA_ERROR_INVALID_PARAMETER;
5198 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5200 if (ret == CAMERA_ERROR_NONE)
5201 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5203 LOGD("ret : 0x%x", ret);
5209 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5211 int ret = CAMERA_ERROR_NONE;
5212 camera_cli_s *pc = (camera_cli_s *)camera;
5213 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5215 if (!pc || !pc->cb_info || !effect) {
5216 LOGE("NULL pointer %p %p", pc, effect);
5217 return CAMERA_ERROR_INVALID_PARAMETER;
5222 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5224 if (ret == CAMERA_ERROR_NONE)
5225 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5227 LOGD("ret : 0x%x", ret);
5233 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5235 int ret = CAMERA_ERROR_NONE;
5236 camera_cli_s *pc = (camera_cli_s *)camera;
5237 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5239 if (!pc || !pc->cb_info || !mode) {
5240 LOGE("NULL pointer %p %p", pc, mode);
5241 return CAMERA_ERROR_INVALID_PARAMETER;
5246 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5248 if (ret == CAMERA_ERROR_NONE)
5249 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5251 LOGD("ret : 0x%x", ret);
5257 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5259 int ret = CAMERA_ERROR_NONE;
5260 camera_cli_s *pc = (camera_cli_s *)camera;
5261 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5263 if (!pc || !pc->cb_info || !enable) {
5264 LOGE("NULL pointer %p %p", pc, enable);
5265 return CAMERA_ERROR_INVALID_PARAMETER;
5270 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5272 if (ret == CAMERA_ERROR_NONE)
5273 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5275 LOGD("ret : 0x%x", ret);
5281 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5283 int ret = CAMERA_ERROR_NONE;
5284 camera_cli_s *pc = (camera_cli_s *)camera;
5285 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5287 if (!pc || !pc->cb_info || !description) {
5288 LOGE("NULL pointer %p %p", pc, description);
5289 return CAMERA_ERROR_INVALID_PARAMETER;
5294 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5296 if (ret == CAMERA_ERROR_NONE)
5297 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5299 LOGD("ret : 0x%x", ret);
5305 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5307 int ret = CAMERA_ERROR_NONE;
5308 camera_cli_s *pc = (camera_cli_s *)camera;
5309 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5311 if (!pc || !pc->cb_info || !orientation) {
5312 LOGE("NULL pointer %p %p", pc, orientation);
5313 return CAMERA_ERROR_INVALID_PARAMETER;
5318 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5320 if (ret == CAMERA_ERROR_NONE)
5321 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5323 LOGD("ret : 0x%x", ret);
5329 int camera_attr_get_tag_software(camera_h camera, char **software)
5331 int ret = CAMERA_ERROR_NONE;
5332 camera_cli_s *pc = (camera_cli_s *)camera;
5333 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5335 if (!pc || !pc->cb_info || !software) {
5336 LOGE("NULL pointer %p %p", pc, software);
5337 return CAMERA_ERROR_INVALID_PARAMETER;
5342 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5344 if (ret == CAMERA_ERROR_NONE)
5345 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5347 LOGD("ret : 0x%x", ret);
5353 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5355 int ret = CAMERA_ERROR_NONE;
5356 camera_cli_s *pc = (camera_cli_s *)camera;
5357 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5359 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5360 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5361 return CAMERA_ERROR_INVALID_PARAMETER;
5366 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5368 if (ret == CAMERA_ERROR_NONE) {
5369 *latitude = pc->cb_info->get_geotag[0];
5370 *longitude = pc->cb_info->get_geotag[1];
5371 *altitude = pc->cb_info->get_geotag[2];
5374 LOGD("ret : 0x%x", ret);
5380 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5382 int ret = CAMERA_ERROR_NONE;
5383 camera_cli_s *pc = (camera_cli_s *)camera;
5384 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5386 if (!pc || !pc->cb_info || !mode) {
5387 LOGE("NULL pointer %p %p", pc, mode);
5388 return CAMERA_ERROR_INVALID_PARAMETER;
5393 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5395 if (ret == CAMERA_ERROR_NONE)
5396 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5398 LOGD("ret : 0x%x", ret);
5404 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5406 int ret = CAMERA_ERROR_NONE;
5407 int get_flash_state = 0;
5410 LOGE("NULL pointer");
5411 return CAMERA_ERROR_INVALID_PARAMETER;
5414 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5415 (int)device, "get_flash_state", &get_flash_state);
5417 if (ret == CAMERA_ERROR_NONE) {
5418 *state = (camera_flash_state_e)get_flash_state;
5419 LOGD("flash state %d", *state);
5421 LOGE("failed 0x%x", ret);
5428 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5430 int ret = CAMERA_ERROR_NONE;
5431 camera_cli_s *pc = (camera_cli_s *)camera;
5432 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5434 if (!pc || !pc->cb_info || !foreach_cb) {
5435 LOGE("NULL pointer %p %p", pc, foreach_cb);
5436 return CAMERA_ERROR_INVALID_PARAMETER;
5441 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5442 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5444 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5446 LOGD("ret : 0x%x", ret);
5452 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5454 int ret = CAMERA_ERROR_NONE;
5455 camera_cli_s *pc = (camera_cli_s *)camera;
5456 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5458 if (!pc || !pc->cb_info || !foreach_cb) {
5459 LOGE("NULL pointer %p %p", pc, foreach_cb);
5460 return CAMERA_ERROR_INVALID_PARAMETER;
5465 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5466 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5468 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5470 LOGD("ret : 0x%x", ret);
5476 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5478 int ret = CAMERA_ERROR_NONE;
5479 camera_cli_s *pc = (camera_cli_s *)camera;
5480 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5482 if (!pc || !pc->cb_info || !foreach_cb) {
5483 LOGE("NULL pointer %p %p", pc, foreach_cb);
5484 return CAMERA_ERROR_INVALID_PARAMETER;
5489 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5490 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5492 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5494 LOGD("ret : 0x%x", ret);
5500 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5502 int ret = CAMERA_ERROR_NONE;
5503 camera_cli_s *pc = (camera_cli_s *)camera;
5504 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5506 if (!pc || !pc->cb_info || !foreach_cb) {
5507 LOGE("NULL pointer %p %p", pc, foreach_cb);
5508 return CAMERA_ERROR_INVALID_PARAMETER;
5513 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5514 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5516 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5518 LOGD("ret : 0x%x", ret);
5524 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5526 int ret = CAMERA_ERROR_NONE;
5527 camera_cli_s *pc = (camera_cli_s *)camera;
5528 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5530 if (!pc || !pc->cb_info || !foreach_cb) {
5531 LOGE("NULL pointer %p %p", pc, foreach_cb);
5532 return CAMERA_ERROR_INVALID_PARAMETER;
5537 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5538 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5540 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5542 LOGD("ret : 0x%x", ret);
5548 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5550 int ret = CAMERA_ERROR_NONE;
5551 camera_cli_s *pc = (camera_cli_s *)camera;
5552 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5554 if (!pc || !pc->cb_info || !foreach_cb) {
5555 LOGE("NULL pointer %p %p", pc, foreach_cb);
5556 return CAMERA_ERROR_INVALID_PARAMETER;
5561 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5562 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5564 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5566 LOGD("ret : 0x%x", ret);
5572 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5574 int ret = CAMERA_ERROR_NONE;
5575 camera_cli_s *pc = (camera_cli_s *)camera;
5576 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5578 if (!pc || !pc->cb_info || !foreach_cb) {
5579 LOGE("NULL pointer %p %p", pc, foreach_cb);
5580 return CAMERA_ERROR_INVALID_PARAMETER;
5585 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5586 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5588 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5590 LOGD("ret : 0x%x", ret);
5596 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5598 int ret = CAMERA_ERROR_NONE;
5599 camera_cli_s *pc = (camera_cli_s *)camera;
5600 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5602 if (!pc || !pc->cb_info || !foreach_cb) {
5603 LOGE("NULL pointer %p %p", pc, foreach_cb);
5604 return CAMERA_ERROR_INVALID_PARAMETER;
5609 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5610 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5612 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5614 LOGD("Enter, handle :%x", pc->remote_handle);
5620 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)
5622 int ret = CAMERA_ERROR_NONE;
5623 camera_cli_s *pc = (camera_cli_s *)camera;
5624 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5625 camera_msg_param param;
5628 if (!pc || !pc->cb_info || !foreach_cb) {
5629 LOGE("NULL pointer %p %p", pc, foreach_cb);
5630 return CAMERA_ERROR_INVALID_PARAMETER;
5635 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5636 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5638 value = (width << 16) | height;
5639 CAMERA_MSG_PARAM_SET(param, INT, value);
5641 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5643 LOGD("ret : 0x%x", ret);
5649 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5651 int ret = CAMERA_ERROR_NONE;
5652 camera_cli_s *pc = (camera_cli_s *)camera;
5653 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5655 if (!pc || !pc->cb_info || !foreach_cb) {
5656 LOGE("NULL pointer %p %p", pc, foreach_cb);
5657 return CAMERA_ERROR_INVALID_PARAMETER;
5662 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5663 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5665 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5667 LOGD("ret : 0x%x", ret);
5673 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5675 int ret = CAMERA_ERROR_NONE;
5676 camera_cli_s *pc = (camera_cli_s *)camera;
5677 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5679 if (!pc || !pc->cb_info || !foreach_cb) {
5680 LOGE("NULL pointer %p %p", pc, foreach_cb);
5681 return CAMERA_ERROR_INVALID_PARAMETER;
5686 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5687 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5689 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5691 LOGD("ret : 0x%x", ret);
5697 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5699 int ret = CAMERA_ERROR_NONE;
5700 camera_cli_s *pc = (camera_cli_s *)camera;
5701 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5702 camera_msg_param param;
5703 int set_rotation = (int)rotation;
5705 if (!pc || !pc->cb_info) {
5706 LOGE("NULL handle");
5707 return CAMERA_ERROR_INVALID_PARAMETER;
5712 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5714 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5716 LOGD("ret : 0x%x", ret);
5722 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5724 int ret = CAMERA_ERROR_NONE;
5725 camera_cli_s *pc = (camera_cli_s *)camera;
5726 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5728 if (!pc || !pc->cb_info || !rotation) {
5729 LOGE("NULL pointer %p %p", pc, rotation);
5730 return CAMERA_ERROR_INVALID_PARAMETER;
5735 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5737 if (ret == CAMERA_ERROR_NONE)
5738 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5740 LOGD("ret : 0x%x", ret);
5746 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5748 int ret = CAMERA_ERROR_NONE;
5749 camera_cli_s *pc = (camera_cli_s *)camera;
5750 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5751 camera_msg_param param;
5752 int set_flip = (int)flip;
5754 if (!pc || !pc->cb_info) {
5755 LOGE("NULL handle");
5756 return CAMERA_ERROR_INVALID_PARAMETER;
5761 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5763 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5765 LOGD("ret : 0x%x", ret);
5771 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5773 int ret = CAMERA_ERROR_NONE;
5774 camera_cli_s *pc = (camera_cli_s *)camera;
5775 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5777 if (!pc || !pc->cb_info || !flip) {
5778 LOGE("NULL pointer %p %p", pc, flip);
5779 return CAMERA_ERROR_INVALID_PARAMETER;
5784 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5786 if (ret == CAMERA_ERROR_NONE)
5787 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5789 LOGD("ret : 0x%x", ret);
5794 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5796 int ret = CAMERA_ERROR_NONE;
5797 camera_cli_s *pc = (camera_cli_s *)camera;
5798 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5799 camera_msg_param param;
5800 int set_mode = (int)mode;
5802 if (!pc || !pc->cb_info) {
5803 LOGE("NULL handle");
5804 return CAMERA_ERROR_INVALID_PARAMETER;
5809 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5811 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5813 LOGD("ret : 0x%x", ret);
5819 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5821 int ret = CAMERA_ERROR_NONE;
5822 camera_cli_s *pc = (camera_cli_s *)camera;
5823 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5825 if (!pc || !pc->cb_info || !mode) {
5826 LOGE("NULL pointer %p %p", pc, mode);
5827 return CAMERA_ERROR_INVALID_PARAMETER;
5832 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5834 if (ret == CAMERA_ERROR_NONE)
5835 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
5837 LOGD("ret : 0x%x", ret);
5843 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5845 int ret = CAMERA_ERROR_NONE;
5846 camera_cli_s *pc = (camera_cli_s *)camera;
5847 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
5849 if (!pc || !pc->cb_info) {
5850 LOGE("NULL handle");
5851 return CAMERA_ERROR_INVALID_PARAMETER;
5856 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5859 LOGE("error is occurred 0x%x", ret);
5863 LOGD("ret : %d", ret);
5869 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5871 int ret = CAMERA_ERROR_NONE;
5872 camera_cli_s *pc = (camera_cli_s *)camera;
5873 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5875 if (!pc || !pc->cb_info) {
5876 LOGE("NULL handle");
5877 return CAMERA_ERROR_INVALID_PARAMETER;
5882 if (!camera_attr_is_supported_hdr_capture(camera)) {
5883 LOGE("HDR not supported");
5884 return CAMERA_ERROR_NOT_SUPPORTED;
5888 LOGE("NULL callback");
5889 return CAMERA_ERROR_INVALID_PARAMETER;
5892 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5893 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5895 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5897 LOGD("ret : 0x%x", ret);
5903 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5905 int ret = CAMERA_ERROR_NONE;
5906 camera_cli_s *pc = (camera_cli_s *)camera;
5907 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5909 if (!pc || !pc->cb_info) {
5910 LOGE("NULL handle");
5911 return CAMERA_ERROR_INVALID_PARAMETER;
5916 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5917 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5919 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5921 LOGD("ret : 0x%x", ret);
5927 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
5929 int ret = CAMERA_ERROR_NONE;
5930 camera_cli_s *pc = (camera_cli_s *)camera;
5931 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
5932 camera_msg_param param;
5933 int set_enable = (int)enable;
5935 if (!pc || !pc->cb_info) {
5936 LOGE("NULL handle");
5937 return CAMERA_ERROR_INVALID_PARAMETER;
5942 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
5944 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5946 LOGD("ret : 0x%x", ret);
5952 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
5954 int ret = CAMERA_ERROR_NONE;
5955 camera_cli_s *pc = (camera_cli_s *)camera;
5956 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
5958 if (!pc || !pc->cb_info || !enabled) {
5959 LOGE("NULL pointer %p %p", pc, enabled);
5960 return CAMERA_ERROR_INVALID_PARAMETER;
5965 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5967 if (ret == CAMERA_ERROR_NONE)
5968 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
5970 LOGD("ret : 0x%x", ret);
5976 bool camera_attr_is_supported_anti_shake(camera_h camera)
5978 int ret = CAMERA_ERROR_NONE;
5979 camera_cli_s *pc = (camera_cli_s *)camera;
5980 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
5982 if (!pc || !pc->cb_info) {
5983 LOGE("NULL handle");
5984 return CAMERA_ERROR_INVALID_PARAMETER;
5989 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5992 LOGE("error is occurred 0x%x", ret);
5996 LOGD("ret : %d", ret);
6002 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6004 int ret = CAMERA_ERROR_NONE;
6005 camera_cli_s *pc = (camera_cli_s *)camera;
6006 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6007 camera_msg_param param;
6008 int set_enable = (int)enable;
6010 if (!pc || !pc->cb_info) {
6011 LOGE("NULL handle");
6012 return CAMERA_ERROR_INVALID_PARAMETER;
6017 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6019 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6021 LOGD("ret : 0x%x", ret);
6027 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6029 int ret = CAMERA_ERROR_NONE;
6030 camera_cli_s *pc = (camera_cli_s *)camera;
6031 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6033 if (!pc || !pc->cb_info || !enabled) {
6034 LOGE("NULL pointer %p %p", pc, enabled);
6035 return CAMERA_ERROR_INVALID_PARAMETER;
6040 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6042 if (ret == CAMERA_ERROR_NONE)
6043 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6045 LOGD("ret : 0x%x", ret);
6051 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6053 int ret = CAMERA_ERROR_NONE;
6054 camera_cli_s *pc = (camera_cli_s *)camera;
6055 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6057 if (!pc || !pc->cb_info) {
6058 LOGE("NULL handle");
6059 return CAMERA_ERROR_INVALID_PARAMETER;
6064 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6067 LOGE("error is occurred 0x%x", ret);
6071 LOGD("ret : %d", ret);
6077 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6079 int ret = CAMERA_ERROR_NONE;
6080 camera_cli_s *pc = (camera_cli_s *)camera;
6081 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6082 camera_msg_param param;
6083 int set_enable = (int)enable;
6085 if (!pc || !pc->cb_info) {
6086 LOGE("NULL handle");
6087 return CAMERA_ERROR_INVALID_PARAMETER;
6092 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6094 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6096 LOGD("ret : 0x%x", ret);
6102 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6104 int ret = CAMERA_ERROR_NONE;
6105 camera_cli_s *pc = (camera_cli_s *)camera;
6106 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6108 if (!pc || !pc->cb_info || !enabled) {
6109 LOGE("NULL pointer %p %p", pc, enabled);
6110 return CAMERA_ERROR_INVALID_PARAMETER;
6115 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6117 if (ret == CAMERA_ERROR_NONE)
6118 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6120 LOGD("ret : 0x%x", ret);
6126 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6128 int ret = CAMERA_ERROR_NONE;
6129 camera_cli_s *pc = (camera_cli_s *)camera;
6130 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6132 if (!pc || !pc->cb_info) {
6133 LOGE("NULL handle");
6134 return CAMERA_ERROR_INVALID_PARAMETER;
6139 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6142 LOGE("error is occurred 0x%x", ret);
6146 LOGD("ret : %d", ret);
6152 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6154 int ret = CAMERA_ERROR_NONE;
6155 camera_cli_s *pc = (camera_cli_s *)camera;
6156 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6157 camera_msg_param param;
6158 int set_disable = (int)disable;
6160 if (!pc || !pc->cb_info) {
6161 LOGE("NULL handle");
6162 return CAMERA_ERROR_INVALID_PARAMETER;
6167 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6169 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6171 LOGD("ret : 0x%x", ret);
6177 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6179 int ret = CAMERA_ERROR_NONE;
6180 camera_cli_s *pc = (camera_cli_s *)camera;
6181 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6182 camera_msg_param param;
6183 int set_move_type = (int)move_type;
6186 if (!pc || !pc->cb_info) {
6187 LOGE("NULL handle");
6188 return CAMERA_ERROR_INVALID_PARAMETER;
6193 value = (set_move_type << 16) | pan_step;
6194 CAMERA_MSG_PARAM_SET(param, INT, value);
6196 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6198 LOGD("ret : 0x%x", ret);
6204 int camera_attr_get_pan(camera_h camera, int *pan_step)
6206 int ret = CAMERA_ERROR_NONE;
6207 camera_cli_s *pc = (camera_cli_s *)camera;
6208 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6210 if (!pc || !pc->cb_info || !pan_step) {
6211 LOGE("NULL pointer %p %p", pc, pan_step);
6212 return CAMERA_ERROR_INVALID_PARAMETER;
6217 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6219 if (ret == CAMERA_ERROR_NONE)
6220 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6222 LOGD("ret : 0x%x", ret);
6228 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6230 int ret = CAMERA_ERROR_NONE;
6231 camera_cli_s *pc = (camera_cli_s *)camera;
6232 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6234 if (!pc || !pc->cb_info || !min || !max) {
6235 LOGE("NULL pointer %p %p", pc, min, max);
6236 return CAMERA_ERROR_INVALID_PARAMETER;
6241 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6243 if (ret == CAMERA_ERROR_NONE) {
6244 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6245 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6248 LOGD("ret : 0x%x", ret);
6254 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6256 int ret = CAMERA_ERROR_NONE;
6257 camera_cli_s *pc = (camera_cli_s *)camera;
6258 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6259 camera_msg_param param;
6260 int set_move_type = (int)move_type;
6263 if (!pc || !pc->cb_info) {
6264 LOGE("NULL handle");
6265 return CAMERA_ERROR_INVALID_PARAMETER;
6270 value = (set_move_type << 16) | tilt_step;
6271 CAMERA_MSG_PARAM_SET(param, INT, value);
6273 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6275 LOGD("ret : 0x%x", ret);
6281 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6283 int ret = CAMERA_ERROR_NONE;
6284 camera_cli_s *pc = (camera_cli_s *)camera;
6285 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6287 if (!pc || !pc->cb_info || !tilt_step) {
6288 LOGE("NULL pointer %p %p", pc, tilt_step);
6289 return CAMERA_ERROR_INVALID_PARAMETER;
6294 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6296 if (ret == CAMERA_ERROR_NONE)
6297 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6299 LOGD("ret : 0x%x", ret);
6305 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6307 int ret = CAMERA_ERROR_NONE;
6308 camera_cli_s *pc = (camera_cli_s *)camera;
6309 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6311 if (!pc || !pc->cb_info || !min || !max) {
6312 LOGE("NULL pointer %p %p %p", pc, min, max);
6313 return CAMERA_ERROR_INVALID_PARAMETER;
6318 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6320 if (ret == CAMERA_ERROR_NONE) {
6321 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6322 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6325 LOGD("ret : 0x%x", ret);
6331 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6333 int ret = CAMERA_ERROR_NONE;
6334 camera_cli_s *pc = (camera_cli_s *)camera;
6335 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6336 camera_msg_param param;
6337 int set_ptz_type = (int)ptz_type;
6339 if (!pc || !pc->cb_info) {
6340 LOGE("NULL handle");
6341 return CAMERA_ERROR_INVALID_PARAMETER;
6346 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6348 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6350 LOGD("ret : 0x%x", ret);
6356 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6358 int ret = CAMERA_ERROR_NONE;
6359 camera_cli_s *pc = (camera_cli_s *)camera;
6360 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6362 if (!pc || !pc->cb_info || !foreach_cb) {
6363 LOGE("NULL pointer %p %p", pc, foreach_cb);
6364 return CAMERA_ERROR_INVALID_PARAMETER;
6369 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6370 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6372 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6374 LOGD("ret : 0x%x", ret);
6380 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6382 int ret = CAMERA_ERROR_NONE;
6383 camera_cli_s *pc = (camera_cli_s *)camera;
6384 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6385 int set_display_roi_area[4] = {x, y, width, height};
6390 if (!pc || !pc->cb_info) {
6391 LOGE("NULL handle");
6392 return CAMERA_ERROR_INVALID_PARAMETER;
6397 #ifdef TIZEN_FEATURE_EVAS_RENDERER
6398 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6399 g_mutex_lock(&pc->cb_info->evas_mutex);
6401 ret = mm_evas_renderer_set_roi_area(pc->cb_info->evas_info, x, y, width, height);
6403 g_mutex_unlock(&pc->cb_info->evas_mutex);
6405 if (ret != MM_ERROR_NONE) {
6406 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6407 return CAMERA_ERROR_INVALID_OPERATION;
6410 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
6412 length = sizeof(set_display_roi_area) / sizeof(int) + \
6413 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6415 msg = muse_core_msg_json_factory_new(api,
6416 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6419 LOGE("msg creation failed: api %d", api);
6420 return CAMERA_ERROR_OUT_OF_MEMORY;
6423 if (pc->cb_info->is_server_connected) {
6424 g_mutex_lock(&pc->cb_info->fd_lock);
6425 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
6426 g_mutex_unlock(&pc->cb_info->fd_lock);
6430 LOGE("message send failed");
6431 ret = CAMERA_ERROR_INVALID_OPERATION;
6433 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6436 muse_core_msg_json_factory_free(msg);
6438 LOGD("ret : 0x%x", ret);
6444 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6446 camera_cli_s *pc = (camera_cli_s *)camera;
6447 int ret = CAMERA_ERROR_NONE;
6448 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6450 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6451 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6452 return CAMERA_ERROR_INVALID_PARAMETER;
6457 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6459 if (ret == CAMERA_ERROR_NONE) {
6460 *x = pc->cb_info->get_display_roi_area[0];
6461 *y = pc->cb_info->get_display_roi_area[1];
6462 *width = pc->cb_info->get_display_roi_area[2];
6463 *height = pc->cb_info->get_display_roi_area[3];
6466 LOGD("ret : 0x%x", ret);
6472 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6474 int ret = CAMERA_ERROR_NONE;
6475 int get_device_state = 0;
6478 LOGE("NULL pointer");
6479 return CAMERA_ERROR_INVALID_PARAMETER;
6482 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6483 (int)device, "get_device_state", &get_device_state);
6485 if (ret == CAMERA_ERROR_NONE) {
6486 *state = (camera_device_state_e)get_device_state;
6487 LOGD("device state %d", *state);
6489 LOGE("failed 0x%x", ret);
6496 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6498 int ret = CAMERA_ERROR_NONE;
6499 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6500 camera_cb_info *info = NULL;
6502 if (!callback || !cb_id) {
6503 LOGE("invalid pointer %p %p", callback, cb_id);
6504 return CAMERA_ERROR_INVALID_PARAMETER;
6507 /* check camera support */
6508 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6509 if (ret != CAMERA_ERROR_NONE) {
6510 LOGE("get device state failed");
6514 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6516 info = g_new0(camera_cb_info, 1);
6518 LOGE("info failed");
6519 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6523 info->id = ++g_cam_dev_state_changed_cb_id;
6524 info->callback = (void *)callback;
6525 info->user_data = user_data;
6529 /* subscribe dbus signal for camera state change */
6530 if (!g_cam_dev_state_changed_cb_conn) {
6531 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6532 if (!g_cam_dev_state_changed_cb_conn) {
6533 LOGE("failed to get gdbus connection");
6534 ret = CAMERA_ERROR_INVALID_OPERATION;
6538 LOGD("subscribe signal %s - %s - %s",
6539 MM_CAMCORDER_DBUS_OBJECT,
6540 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6541 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6543 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6544 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6545 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6546 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6547 LOGE("failed to get gdbus connection");
6548 ret = CAMERA_ERROR_INVALID_OPERATION;
6552 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6555 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6557 LOGD("callback id %d", info->id);
6560 if (ret != CAMERA_ERROR_NONE) {
6566 if (g_cam_dev_state_changed_cb_conn) {
6567 g_object_unref(g_cam_dev_state_changed_cb_conn);
6568 g_cam_dev_state_changed_cb_conn = NULL;
6572 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6578 int camera_remove_device_state_changed_cb(int cb_id)
6580 int ret = CAMERA_ERROR_NONE;
6581 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6582 GList *tmp_list = NULL;
6583 camera_cb_info *info = NULL;
6585 /* check camera support */
6586 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6587 if (ret != CAMERA_ERROR_NONE) {
6588 LOGE("get device state failed");
6592 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6594 if (!g_cam_dev_state_changed_cb_list) {
6595 LOGE("there is no callback info");
6596 ret = CAMERA_ERROR_INVALID_OPERATION;
6600 tmp_list = g_cam_dev_state_changed_cb_list;
6603 info = tmp_list->data;
6604 tmp_list = tmp_list->next;
6611 if (info->id == cb_id) {
6612 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6617 if (!g_cam_dev_state_changed_cb_list) {
6618 /* no remained callback */
6619 if (g_cam_dev_state_changed_cb_conn) {
6620 /* unsubscribe signal */
6621 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6622 g_cam_dev_state_changed_cb_subscribe_id = 0;
6624 /* unref connection */
6625 g_object_unref(g_cam_dev_state_changed_cb_conn);
6626 g_cam_dev_state_changed_cb_conn = NULL;
6630 LOGD("id %d callback removed", cb_id);
6631 ret = CAMERA_ERROR_NONE;
6637 LOGE("id %d callback not found", cb_id);
6638 ret = CAMERA_ERROR_INVALID_PARAMETER;
6641 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);