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_surface *surface = NULL;
121 struct wl_registry *registry = NULL;
122 struct tizen_surface *tz_surface = NULL;
123 struct tizen_resource *tz_resource = NULL;
125 if (!obj || !wl_info) {
126 LOGE("NULL parameter %p %p", obj, wl_info);
127 return CAMERA_ERROR_INVALID_OPERATION;
130 window = elm_win_wl_window_get(obj);
132 LOGE("failed to get wayland window");
133 ret = CAMERA_ERROR_INVALID_OPERATION;
137 surface = (struct wl_surface *)ecore_wl_window_surface_get(window);
139 LOGE("failed to get wayland surface");
140 ret = CAMERA_ERROR_INVALID_OPERATION;
144 display = (struct wl_display *)ecore_wl_display_get();
146 LOGE("failed to get wayland display");
147 ret = CAMERA_ERROR_INVALID_OPERATION;
151 registry = wl_display_get_registry(display);
153 LOGE("failed to get wayland registry");
154 ret = CAMERA_ERROR_INVALID_OPERATION;
158 wl_registry_add_listener(registry, &_camera_wl_registry_listener, &tz_surface);
160 wl_display_dispatch(display);
161 wl_display_roundtrip(display);
164 LOGE("failed to get tizen surface");
165 ret = CAMERA_ERROR_INVALID_OPERATION;
169 /* Get parent_id which is unique in a entire systemw. */
170 tz_resource = tizen_surface_get_tizen_resource(tz_surface, surface);
172 LOGE("failed to get tizen resurce");
173 ret = CAMERA_ERROR_INVALID_OPERATION;
177 wl_info->parent_id = 0;
179 tizen_resource_add_listener(tz_resource, &_camera_tz_resource_listener, &wl_info->parent_id);
181 wl_display_roundtrip(display);
183 if (wl_info->parent_id > 0) {
185 Ecore_Evas *ecore_evas = NULL;
186 ret = CAMERA_ERROR_NONE;
188 wl_info->evas_obj = obj;
190 evas_object_geometry_get(obj, &wl_info->window_x, &wl_info->window_y,
191 &wl_info->window_width, &wl_info->window_height);
193 ecore_evas = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
195 rotation = ecore_evas_rotation_get(ecore_evas);
196 if (rotation == 90 || rotation == 270) {
197 int temp = wl_info->window_width;
199 LOGD("swap width and height %d, %d", wl_info->window_width, wl_info->window_height);
201 wl_info->window_width = wl_info->window_height;
202 wl_info->window_height = temp;
205 LOGW("failed to get ecore_evas.. skip rotation check");
208 LOGD("evas object : %p, rotation : %d, parent id : %u, window : %d,%d,%dx%d",
209 wl_info->evas_obj, rotation, wl_info->parent_id,
210 wl_info->window_x, wl_info->window_y,
211 wl_info->window_width, wl_info->window_height);
213 ret = CAMERA_ERROR_INVALID_OPERATION;
214 LOGE("failed to get parent id");
219 tizen_surface_destroy(tz_surface);
224 tizen_resource_destroy(tz_resource);
229 wl_registry_destroy(registry);
237 static void __camera_device_state_changed_cb(GDBusConnection *connection,
238 const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
239 const gchar *signal_name, GVariant *param, gpointer user_data)
242 camera_device_e device = CAMERA_DEVICE_CAMERA0;
243 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
244 GList *tmp_list = NULL;
245 camera_cb_info *info = NULL;
247 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
249 if (!g_cam_dev_state_changed_cb_list || !param) {
250 LOGW("no callback or NULL param %p", param);
254 /* get device and state */
255 g_variant_get(param, "(i)", &value);
257 device = value >> 16;
258 state = 0x0000ffff & value;
260 LOGD("device %d, state %d", device, state);
262 tmp_list = g_cam_dev_state_changed_cb_list;
265 info = (camera_cb_info *)tmp_list->data;
268 if (info->callback) {
269 LOGD("start id[%d] callback", info->id);
270 ((camera_device_state_changed_cb)info->callback)(device, state, info->user_data);
271 LOGD("returned id[%d] callback", info->id);
273 LOGW("NULL callback for id %d", info->id);
277 tmp_list = tmp_list->next;
281 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
287 static int _camera_import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle)
289 tbm_bo tmp_bo = NULL;
290 tbm_bo_handle tmp_bo_handle = {NULL, };
292 if (!bufmgr || !bo || !bo_handle || !tbm_key) {
293 LOGE("invalid parameter - %p %p %p, key %d",
294 bufmgr, bo, bo_handle, tbm_key);
298 tmp_bo = tbm_bo_import(bufmgr, tbm_key);
299 if (tmp_bo == NULL) {
300 LOGE("import failed - key %d", tbm_key);
304 tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
305 if (tmp_bo_handle.ptr == NULL) {
306 LOGE("map failed %p", tmp_bo);
307 tbm_bo_unref(tmp_bo);
312 tbm_bo_unmap(tmp_bo);
314 /* set bo and bo_handle */
316 *bo_handle = tmp_bo_handle;
321 static void _camera_release_imported_bo(tbm_bo *bo)
334 static int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
336 int ret = CAMERA_ERROR_NONE;
339 /*LOGD("Enter api : %d", api);*/
341 if (!cb_info->is_server_connected) {
342 LOGE("server is disconnected");
343 return CAMERA_ERROR_SERVICE_DISCONNECTED;
346 g_mutex_lock(&(cb_info->api_mutex[api]));
348 if (cb_info->api_activating[api] == 0) {
349 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
350 if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
351 ret = cb_info->api_ret[api];
352 cb_info->api_activating[api] = 0;
354 /*LOGD("return value : 0x%x", ret);*/
356 ret = CAMERA_ERROR_INVALID_OPERATION;
357 LOGE("api %d was TIMED OUT!", api);
360 ret = cb_info->api_ret[api];
361 cb_info->api_activating[api] = 0;
363 /*LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);*/
366 g_mutex_unlock(&(cb_info->api_mutex[api]));
368 if (ret != CAMERA_ERROR_NONE) {
369 LOGE("api %d : error 0x%x", api, ret);
371 if (ret == CAMERA_ERROR_SOUND_POLICY)
372 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
373 else if (ret == CAMERA_ERROR_SOUND_POLICY_BY_CALL)
374 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
375 else if (ret == CAMERA_ERROR_SOUND_POLICY_BY_ALARM)
376 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
383 static void _camera_msg_send(int api, camera_cb_info_s *cb_info,
384 int *ret, int timeout)
390 LOGE("NULL info - api %d", api);
393 *ret = CAMERA_ERROR_INVALID_PARAMETER;
398 msg = muse_core_msg_json_factory_new(api, NULL);
400 LOGE("msg failed: api %d", api);
403 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
408 /*LOGD("send msg %s", msg);*/
410 if (cb_info->is_server_connected)
411 send_ret = muse_core_ipc_send_msg(cb_info->fd, msg);
414 LOGE("msg send failed");
416 *ret = CAMERA_ERROR_INVALID_OPERATION;
419 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
422 muse_core_msg_json_factory_free(msg);
428 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
429 int *ret, camera_msg_param *param, int timeout)
434 if (!cb_info || !param) {
435 LOGE("invalid pointer : api %d - %p %p", api, cb_info, param);
438 *ret = CAMERA_ERROR_INVALID_PARAMETER;
443 /*LOGD("type %d, name %s", param->type, param->name);*/
445 switch (param->type) {
447 msg = muse_core_msg_json_factory_new(api,
448 param->type, param->name, param->value.value_INT,
451 case MUSE_TYPE_STRING:
452 msg = muse_core_msg_json_factory_new(api,
453 param->type, param->name, param->value.value_STRING,
457 LOGE("unknown type %d", param->type);
462 LOGE("msg failed: api %d", api);
465 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
470 /*LOGD("send msg %s", msg);*/
472 if (cb_info->is_server_connected)
473 send_ret = muse_core_ipc_send_msg(cb_info->fd, msg);
476 LOGE("msg send failed");
479 *ret = CAMERA_ERROR_INVALID_OPERATION;
482 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
485 muse_core_msg_json_factory_free(msg);
491 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
493 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
494 in_format >= MM_PIXEL_FORMAT_NUM ||
495 out_format == NULL) {
496 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
497 return CAMERA_ERROR_INVALID_PARAMETER;
501 case MM_PIXEL_FORMAT_NV12:
502 case MM_PIXEL_FORMAT_NV12T:
503 *out_format = TBM_FORMAT_NV12;
505 case MM_PIXEL_FORMAT_NV16:
506 *out_format = TBM_FORMAT_NV16;
508 case MM_PIXEL_FORMAT_NV21:
509 *out_format = TBM_FORMAT_NV21;
511 case MM_PIXEL_FORMAT_YUYV:
512 *out_format = TBM_FORMAT_YUYV;
514 case MM_PIXEL_FORMAT_UYVY:
515 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
516 *out_format = TBM_FORMAT_UYVY;
518 case MM_PIXEL_FORMAT_422P:
519 *out_format = TBM_FORMAT_YUV422;
521 case MM_PIXEL_FORMAT_I420:
522 *out_format = TBM_FORMAT_YUV420;
524 case MM_PIXEL_FORMAT_YV12:
525 *out_format = TBM_FORMAT_YVU420;
527 case MM_PIXEL_FORMAT_RGB565:
528 *out_format = TBM_FORMAT_RGB565;
530 case MM_PIXEL_FORMAT_RGB888:
531 *out_format = TBM_FORMAT_RGB888;
533 case MM_PIXEL_FORMAT_RGBA:
534 *out_format = TBM_FORMAT_RGBA8888;
536 case MM_PIXEL_FORMAT_ARGB:
537 *out_format = TBM_FORMAT_ARGB8888;
540 LOGE("invalid in_format %d", in_format);
541 return CAMERA_ERROR_INVALID_PARAMETER;
544 return CAMERA_ERROR_NONE;
548 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
550 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
551 in_format >= MM_PIXEL_FORMAT_NUM ||
553 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
554 return CAMERA_ERROR_INVALID_PARAMETER;
558 case MM_PIXEL_FORMAT_NV12:
559 case MM_PIXEL_FORMAT_NV12T:
560 *mimetype = MEDIA_FORMAT_NV12;
562 case MM_PIXEL_FORMAT_NV16:
563 *mimetype = MEDIA_FORMAT_NV16;
565 case MM_PIXEL_FORMAT_NV21:
566 *mimetype = MEDIA_FORMAT_NV21;
568 case MM_PIXEL_FORMAT_YUYV:
569 *mimetype = MEDIA_FORMAT_YUYV;
571 case MM_PIXEL_FORMAT_UYVY:
572 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
573 *mimetype = MEDIA_FORMAT_UYVY;
575 case MM_PIXEL_FORMAT_422P:
576 *mimetype = MEDIA_FORMAT_422P;
578 case MM_PIXEL_FORMAT_I420:
579 *mimetype = MEDIA_FORMAT_I420;
581 case MM_PIXEL_FORMAT_YV12:
582 *mimetype = MEDIA_FORMAT_YV12;
584 case MM_PIXEL_FORMAT_RGB565:
585 *mimetype = MEDIA_FORMAT_RGB565;
587 case MM_PIXEL_FORMAT_RGB888:
588 *mimetype = MEDIA_FORMAT_RGB888;
590 case MM_PIXEL_FORMAT_RGBA:
591 *mimetype = MEDIA_FORMAT_RGBA;
593 case MM_PIXEL_FORMAT_ARGB:
594 *mimetype = MEDIA_FORMAT_ARGB;
597 LOGE("invalid in_format %d", in_format);
598 return CAMERA_ERROR_INVALID_PARAMETER;
601 return CAMERA_ERROR_NONE;
604 void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_key,
605 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame)
608 unsigned char *buf_pos = NULL;
610 if (stream == NULL || buffer_bo_handle == NULL || frame == NULL) {
611 LOGE("invalid parameter - stream:%p, buffer_bo_handle:%p", stream, buffer_bo_handle);
616 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
617 frame->format = MM_PIXEL_FORMAT_UYVY;
619 frame->format = stream->format;
621 frame->width = stream->width;
622 frame->height = stream->height;
623 frame->timestamp = stream->timestamp;
624 frame->num_of_planes = stream->num_planes;
626 if (num_buffer_key == 0) {
628 if (!data_bo_handle || !data_bo_handle->ptr) {
629 LOGE("NULL pointer");
633 buf_pos = data_bo_handle->ptr;
635 if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) {
636 frame->data.encoded_plane.data = buf_pos;
637 frame->data.encoded_plane.size = stream->data.encoded.length_data;
638 total_size = stream->data.encoded.length_data;
640 switch (stream->num_planes) {
642 frame->data.single_plane.yuv = buf_pos;
643 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
644 total_size = stream->data.yuv420.length_yuv;
647 frame->data.double_plane.y = buf_pos;
648 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
649 buf_pos += stream->data.yuv420sp.length_y;
650 frame->data.double_plane.uv = buf_pos;
651 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
652 total_size = stream->data.yuv420sp.length_y + \
653 stream->data.yuv420sp.length_uv;
656 frame->data.triple_plane.y = buf_pos;
657 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
658 buf_pos += stream->data.yuv420p.length_y;
659 frame->data.triple_plane.u = buf_pos;
660 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
661 buf_pos += stream->data.yuv420p.length_u;
662 frame->data.triple_plane.v = buf_pos;
663 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
664 total_size = stream->data.yuv420p.length_y + \
665 stream->data.yuv420p.length_u + \
666 stream->data.yuv420p.length_v;
674 switch (stream->num_planes) {
676 frame->data.single_plane.yuv = buffer_bo_handle[0].ptr;
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 = buffer_bo_handle[0].ptr;
682 if (stream->num_planes == (unsigned int)num_buffer_key)
683 frame->data.double_plane.uv = buffer_bo_handle[1].ptr;
685 frame->data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
686 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
687 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
688 total_size = stream->data.yuv420sp.length_y + \
689 stream->data.yuv420sp.length_uv;
692 frame->data.triple_plane.y = buffer_bo_handle[0].ptr;
693 if (stream->num_planes == (unsigned int)num_buffer_key) {
694 frame->data.triple_plane.u = buffer_bo_handle[1].ptr;
695 frame->data.triple_plane.v = buffer_bo_handle[2].ptr;
697 frame->data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y;
698 frame->data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u;
700 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
701 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
702 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
703 total_size = stream->data.yuv420p.length_y + \
704 stream->data.yuv420p.length_u + \
705 stream->data.yuv420p.length_v;
713 LOGD("format %d, %dx%d, size %d plane num %d",
714 frame.format, frame.width, frame.height, total_size, frame.num_of_planes);
720 int _camera_media_packet_data_create(int tbm_key, int num_buffer_key, tbm_bo bo,
721 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
724 int ret = CAMERA_ERROR_NONE;
725 camera_media_packet_data *tmp_mp_data = NULL;
727 if (*mp_data == NULL) {
728 tmp_mp_data = g_new0(camera_media_packet_data, 1);
730 tmp_mp_data->tbm_key = tbm_key;
731 tmp_mp_data->num_buffer_key = num_buffer_key;
732 tmp_mp_data->bo = bo;
733 tmp_mp_data->data_bo = data_bo;
734 tmp_mp_data->ref_cnt++;
736 for (i = 0 ; i < num_buffer_key ; i++)
737 tmp_mp_data->buffer_bo[i] = buffer_bo[i];
739 *mp_data = tmp_mp_data;
740 /*LOGD("mp_data %p", tmp_mp_data);*/
742 ret = CAMERA_ERROR_OUT_OF_MEMORY;
743 LOGE("failed to alloc media packet data");
746 ((camera_media_packet_data *)*mp_data)->ref_cnt++;
752 void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
756 camera_msg_param param;
758 if (!mp_data || !cb_info) {
759 LOGE("NULL pointer %p %p", mp_data, cb_info);
763 if (mp_data->ref_cnt > 1) {
765 LOGD("ref count %d", mp_data->ref_cnt);
767 /* release imported bo */
768 for (i = 0 ; i < mp_data->num_buffer_key ; i++) {
769 tbm_bo_unref(mp_data->buffer_bo[i]);
770 mp_data->buffer_bo[i] = NULL;
774 _camera_release_imported_bo(&mp_data->bo);
775 _camera_release_imported_bo(&mp_data->data_bo);
778 tbm_key = mp_data->tbm_key;
780 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
782 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
791 int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
792 camera_media_packet_data *mp_data, media_packet_h *packet)
794 media_packet_h pkt = NULL;
795 bool make_pkt_fmt = false;
796 tbm_surface_h tsurf = NULL;
797 tbm_surface_info_s tsurf_info;
798 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
799 uint32_t bo_format = 0;
802 int num_buffer_key = 0;
803 tbm_bo *buffer_bo = NULL;
805 if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) {
806 LOGE("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p",
807 cb_info, stream, mp_data, packet);
808 return CAMERA_ERROR_INVALID_PARAMETER;
811 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
812 buffer_bo = mp_data->buffer_bo;
813 num_buffer_key = mp_data->num_buffer_key;
815 /* create tbm surface */
816 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
817 tsurf_info.planes[i].stride = stream->stride[i];
819 /* get tbm surface format */
820 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
821 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
823 if (ret == CAMERA_ERROR_NONE) {
824 tsurf_info.width = stream->width;
825 tsurf_info.height = stream->height;
826 tsurf_info.format = bo_format;
827 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
828 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
830 if (num_buffer_key > 0) {
832 case TBM_FORMAT_NV12:
833 case TBM_FORMAT_NV21:
834 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
835 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
836 tsurf_info.planes[0].offset = 0;
837 if (num_buffer_key == 1)
838 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
839 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
841 case TBM_FORMAT_YUV420:
842 case TBM_FORMAT_YVU420:
843 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
844 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
845 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
846 tsurf_info.planes[0].offset = 0;
847 if (num_buffer_key == 1) {
848 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
849 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
851 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
853 case TBM_FORMAT_UYVY:
854 case TBM_FORMAT_YUYV:
855 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
856 tsurf_info.planes[0].offset = 0;
857 tsurf_info.size = tsurf_info.planes[0].size;
863 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_key);
864 } else if (mp_data->data_bo) {
866 case TBM_FORMAT_NV12:
867 case TBM_FORMAT_NV21:
868 tsurf_info.planes[0].size = stream->width * stream->height;
869 tsurf_info.planes[1].size = (tsurf_info.planes[0].size) >> 1;
870 tsurf_info.planes[0].offset = 0;
871 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
872 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
874 case TBM_FORMAT_YUV420:
875 case TBM_FORMAT_YVU420:
876 tsurf_info.planes[0].size = stream->width * stream->height;
877 tsurf_info.planes[1].size = (stream->width >> 1) * (stream->height >> 1);
878 tsurf_info.planes[2].size = tsurf_info.planes[1].size;
879 tsurf_info.planes[0].offset = 0;
880 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
881 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
882 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
884 case TBM_FORMAT_UYVY:
885 case TBM_FORMAT_YUYV:
886 tsurf_info.planes[0].size = (stream->width * stream->height) << 1;
887 tsurf_info.planes[0].offset = 0;
888 tsurf_info.size = tsurf_info.planes[0].size;
894 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1);
896 /*LOGD("tbm surface %p", tsurf);*/
900 /* check media packet format */
901 if (cb_info->pkt_fmt) {
902 int pkt_fmt_width = 0;
903 int pkt_fmt_height = 0;
904 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
906 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
907 if (pkt_fmt_mimetype != mimetype ||
908 pkt_fmt_width != stream->width ||
909 pkt_fmt_height != stream->height) {
910 LOGW("change fmt: current 0x%x, %dx%d",
911 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
912 media_format_unref(cb_info->pkt_fmt);
913 cb_info->pkt_fmt = NULL;
920 /* create packet format */
922 LOGW("make new pkt_fmt - 0x%x, %dx%d", mimetype, stream->width, stream->height);
923 ret = media_format_create(&cb_info->pkt_fmt);
924 if (ret == MEDIA_FORMAT_ERROR_NONE) {
925 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
926 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
927 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
928 LOGW("media_format_set : 0x%x", ret);
930 LOGW("media_format_create failed 0x%x", ret);
934 /* create media packet */
935 ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt,
936 tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
937 (void *)cb_info, &pkt);
938 if (ret != MEDIA_PACKET_ERROR_NONE) {
939 LOGE("media_packet_create failed 0x%x", ret);
940 tbm_surface_destroy(tsurf);
944 LOGE("tbm surface failed. %dx%d, format %d, num_buffer_key %d, data_bo %p",
945 stream->width, stream->height, stream->format, num_buffer_key, mp_data->data_bo);
949 /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
950 /* set media packet data */
951 ret = media_packet_set_extra(pkt, (void *)mp_data);
952 if (ret != MEDIA_PACKET_ERROR_NONE) {
953 LOGE("media_packet_set_extra failed");
955 _camera_media_packet_data_release(mp_data, cb_info);
958 media_packet_destroy(pkt);
961 /* set timestamp : msec -> nsec */
962 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
963 LOGW("media_packet_set_pts failed");
972 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
975 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
976 camera_media_packet_data *mp_data = NULL;
977 tbm_surface_h tsurf = NULL;
979 if (!pkt || !cb_info) {
980 LOGE("NULL pointer %p %p", pkt, cb_info);
981 return MEDIA_PACKET_FINALIZE;
984 ret = media_packet_get_extra(pkt, (void **)&mp_data);
985 if (ret != MEDIA_PACKET_ERROR_NONE) {
986 LOGE("media_packet_get_extra failed 0x%x", ret);
987 return MEDIA_PACKET_FINALIZE;
990 /*LOGD("mp_data %p", mp_data);*/
992 g_mutex_lock(&cb_info->mp_data_mutex);
994 _camera_media_packet_data_release(mp_data, cb_info);
997 g_mutex_unlock(&cb_info->mp_data_mutex);
999 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1000 if (ret != MEDIA_PACKET_ERROR_NONE)
1001 LOGE("get tbm_surface failed 0x%x", ret);
1004 tbm_surface_destroy(tsurf);
1008 return MEDIA_PACKET_FINALIZE;
1011 static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event)
1017 tbm_bo_handle bo_handle = {NULL, };
1018 camera_msg_param param;
1020 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1021 LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event);
1025 /*LOGD("get camera msg %s, event %d", recv_msg, event);*/
1027 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1028 if (!(CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) &&
1029 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] == NULL &&
1030 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] == NULL) {
1031 LOGW("all preview callback from user are NULL");
1034 } else if (cb_info->user_cb[event] == NULL) {
1035 LOGW("user callback for event %d is not set", event);
1040 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1046 muse_camera_msg_get(previous, recv_msg);
1047 muse_camera_msg_get(current, recv_msg);
1048 muse_camera_msg_get(by_policy, recv_msg);
1050 LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
1051 previous, current, by_policy);
1053 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1054 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1057 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1061 muse_camera_msg_get(state, recv_msg);
1063 LOGD("FOCUS state - %d", state);
1065 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1068 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1069 LOGD("CAPTURE_COMPLETED");
1070 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1072 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1073 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1077 int num_buffer_key = 0;
1078 int buffer_key[BUFFER_MAX_PLANE_NUM] = {0, };
1080 unsigned char *buf_pos = NULL;
1082 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
1083 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
1084 tbm_bo data_bo = NULL;
1085 tbm_bo_handle data_bo_handle = {.ptr = NULL};
1087 camera_preview_data_s frame;
1088 camera_stream_data_s *stream = NULL;
1089 camera_media_packet_data *mp_data = NULL;
1090 media_packet_h pkt = NULL;
1091 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1092 media_packet_h pkt_evas = NULL;
1093 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1095 muse_camera_msg_get(tbm_key, recv_msg);
1096 muse_camera_msg_get(num_buffer_key, recv_msg);
1097 muse_camera_msg_get_array(buffer_key, recv_msg);
1098 muse_camera_msg_get(data_key, recv_msg);
1100 memset(&frame, 0x0, sizeof(camera_preview_data_s));
1103 LOGE("invalid key %d", tbm_key);
1107 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1110 /* import tbm data_bo and get virtual address */
1111 if (!_camera_import_tbm_key(cb_info->bufmgr, data_key, &data_bo, &data_bo_handle)) {
1112 LOGE("failed to import data key %d", data_key);
1113 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1118 /* import tbm bo and get virtual address */
1119 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
1120 LOGE("failed to import key %d", tbm_key);
1121 _camera_release_imported_bo(&data_bo);
1122 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1126 buf_pos = (unsigned char *)bo_handle.ptr;
1128 /* get stream info */
1129 stream = (camera_stream_data_s *)buf_pos;
1131 for (i = 0 ; i < num_buffer_key ; i++) {
1132 /* import buffer bo and get virtual address */
1133 if (!_camera_import_tbm_key(cb_info->bufmgr, buffer_key[i], &buffer_bo[i], &buffer_bo_handle[i])) {
1134 LOGE("failed to import buffer key %d", buffer_key[i]);
1136 /* release imported bo */
1137 _camera_release_imported_bo(&data_bo);
1138 _camera_release_imported_bo(&bo);
1140 for (i -= 1 ; i >= 0 ; i--)
1141 _camera_release_imported_bo(&buffer_bo[i]);
1143 /* send return buffer */
1144 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1150 /* call preview callback */
1151 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
1152 _camera_preview_frame_create(stream, num_buffer_key, buffer_bo_handle, &data_bo_handle, &frame);
1154 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
1155 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
1158 if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
1159 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1160 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
1162 if (ret == CAMERA_ERROR_NONE) {
1163 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt_evas);
1164 if (ret != CAMERA_ERROR_NONE) {
1165 LOGE("create pkt for evas failed");
1166 _camera_media_packet_data_release(mp_data, cb_info);
1170 #else /* TIZEN_FEATURE_EVAS_RENDERER */
1171 LOGW("evas renderer is not supported");
1172 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1175 /* call media packet callback */
1176 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
1177 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
1179 if (ret == CAMERA_ERROR_NONE) {
1180 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt);
1182 if (ret == CAMERA_ERROR_NONE) {
1183 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
1184 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
1186 _camera_media_packet_data_release(mp_data, cb_info);
1192 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1193 /* call evas renderer */
1195 g_mutex_lock(&cb_info->evas_mutex);
1196 if (cb_info->run_evas_render) {
1197 mm_evas_renderer_write(pkt_evas, cb_info->evas_info);
1199 LOGW("evas renderer is stopped, skip this buffer...");
1200 media_packet_destroy(pkt_evas);
1203 g_mutex_unlock(&cb_info->evas_mutex);
1205 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1207 /* send message for preview callback return */
1208 if (!CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS))
1209 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info, NULL, 0);
1211 if (mp_data == NULL) {
1212 /* release imported bo */
1213 for (i = 0 ; i < num_buffer_key ; i++)
1214 _camera_release_imported_bo(&buffer_bo[i]);
1216 /* unmap and unref tbm bo */
1217 _camera_release_imported_bo(&data_bo);
1218 _camera_release_imported_bo(&bo);
1221 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1223 /*LOGD("return buffer Done");*/
1227 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1231 muse_camera_msg_get(percent, recv_msg);
1233 LOGD("HDR progress - %d \%", percent);
1235 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1238 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1244 muse_camera_msg_get(policy, recv_msg);
1245 muse_camera_msg_get(previous, recv_msg);
1246 muse_camera_msg_get(current, recv_msg);
1248 LOGW("INTERRUPTED - policy %d, state previous %d, current %d",
1249 policy, previous, current);
1251 if (policy == CAMERA_POLICY_SOUND)
1252 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND is deprecated and will be removed from next release.");
1253 else if (policy == CAMERA_POLICY_SOUND_BY_CALL)
1254 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_CALL is deprecated and will be removed from next release.");
1255 else if (policy == CAMERA_POLICY_SOUND_BY_ALARM)
1256 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_ALARM is deprecated and will be removed from next release.");
1258 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1259 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1262 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1265 camera_detected_face_s *faces = NULL;
1267 muse_camera_msg_get(count, recv_msg);
1268 muse_camera_msg_get(tbm_key, recv_msg);
1270 if (count > 0 && tbm_key > 0) {
1271 LOGD("FACE_DETECTION - count %d, tbm_key %d", count, tbm_key);
1273 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle))
1277 faces = bo_handle.ptr;
1279 ((camera_face_detected_cb)cb_info->user_cb[event])(faces, count, cb_info->user_data[event]);
1285 for (i = 0 ; i < count ; i++) {
1286 LOGD("id[%2d] - score %d, position (%d,%d,%dx%d)",
1287 i, faces[i].score, faces[i].x, faces[i].y, faces[i].width, faces[i].height);
1293 _camera_release_imported_bo(&bo);
1296 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1297 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1299 /*LOGD("return buffer done");*/
1301 LOGE("invalid message - count %d, key %d", count, tbm_key);
1305 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1308 int current_state = 0;
1310 muse_camera_msg_get(error, recv_msg);
1311 muse_camera_msg_get(current_state, recv_msg);
1313 LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
1315 if (error == CAMERA_ERROR_SOUND_POLICY)
1316 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
1317 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_CALL)
1318 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
1319 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_ALARM)
1320 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
1322 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1323 (camera_state_e)current_state, cb_info->user_data[event]);
1326 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1328 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1329 muse_camera_msg_get(param1, recv_msg);
1330 muse_camera_msg_get(param2, recv_msg);
1332 /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/
1334 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1335 cb_info->user_cb[event] = NULL;
1336 cb_info->user_data[event] = NULL;
1337 LOGW("stop foreach callback for event %d", event);
1340 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1342 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1344 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1346 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1348 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1350 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1352 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1354 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1356 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1358 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1360 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1362 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1364 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1366 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1368 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1369 muse_camera_msg_get(param1, recv_msg);
1371 /*LOGD("event %d SUPPORTED %d ", event, param1);*/
1373 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1374 cb_info->user_cb[event] = NULL;
1375 cb_info->user_data[event] = NULL;
1376 LOGW("stop foreach callback for event %d", event);
1379 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1381 camera_image_data_s *rImage = NULL;
1382 camera_image_data_s *rPostview = NULL;
1383 camera_image_data_s *rThumbnail = NULL;
1384 unsigned char *buf_pos = NULL;
1385 int tbm_key_main = 0;
1386 int tbm_key_post = 0;
1387 int tbm_key_thumb = 0;
1388 tbm_bo bo_main = NULL;
1389 tbm_bo bo_post = NULL;
1390 tbm_bo bo_thumb = NULL;
1391 tbm_bo_handle bo_main_handle = {NULL, };
1392 tbm_bo_handle bo_post_handle = {NULL, };
1393 tbm_bo_handle bo_thumb_handle = {NULL, };
1395 muse_camera_msg_get(tbm_key_main, recv_msg);
1396 muse_camera_msg_get(tbm_key_post, recv_msg);
1397 muse_camera_msg_get(tbm_key_thumb, recv_msg);
1400 LOGD("camera capture callback came in. tbm_key_main %d, tbm_key_post %d, tbm_key_thumb %d",
1401 tbm_key_main, tbm_key_post, tbm_key_thumb);
1404 if (tbm_key_main <= 0) {
1405 LOGE("invalid key %d", tbm_key_main);
1409 /* import tbm bo and get virtual address */
1410 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_main, &bo_main, &bo_main_handle))
1413 buf_pos = (unsigned char *)bo_main_handle.ptr;
1414 rImage = (camera_image_data_s *)buf_pos;
1415 rImage->data = buf_pos + sizeof(camera_image_data_s);
1417 LOGD("image info %dx%d, size : %d", rImage->width, rImage->height, rImage->size);
1419 if (tbm_key_post > 0) {
1420 /* import tbm bo and get virtual address */
1421 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_post, &bo_post, &bo_post_handle))
1424 buf_pos = (unsigned char *)bo_post_handle.ptr;
1425 rPostview = (camera_image_data_s *)buf_pos;
1426 LOGD("rPostview->size : %d", rPostview->size);
1427 rPostview->data = buf_pos + sizeof(camera_image_data_s);
1430 if (tbm_key_thumb > 0) {
1431 /* import tbm bo and get virtual address */
1432 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_thumb, &bo_thumb, &bo_thumb_handle))
1435 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
1437 rThumbnail = (camera_image_data_s *)buf_pos;
1438 LOGD("rThumbnail->size : %d", rThumbnail->size);
1439 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
1442 ((camera_capturing_cb)cb_info->user_cb[event])(rImage, rPostview, rThumbnail, cb_info->user_data[event]);
1444 /* unmap and unref tbm bo */
1445 _camera_release_imported_bo(&bo_main);
1448 tbm_key = tbm_key_main;
1450 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1452 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1454 if (tbm_key_post > 0) {
1455 /* unmap and unref tbm bo */
1456 _camera_release_imported_bo(&bo_post);
1459 param.value.value_INT = tbm_key_post;
1460 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1463 if (tbm_key_thumb > 0) {
1464 /* unmap and unref tbm bo */
1465 _camera_release_imported_bo(&bo_thumb);
1468 param.value.value_INT = tbm_key_thumb;
1469 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1472 LOGD("return buffer done");
1475 case MUSE_CAMERA_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR:
1478 LOGW("Unknown event : %d", event);
1485 static bool _camera_idle_event_callback(void *data)
1487 camera_cb_info_s *cb_info = NULL;
1488 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1490 if (cam_idle_event == NULL) {
1491 LOGE("cam_idle_event is NULL");
1496 g_mutex_lock(&cam_idle_event->event_mutex);
1498 cb_info = cam_idle_event->cb_info;
1499 if (cb_info == NULL) {
1500 LOGW("camera cb_info is NULL. event %d", cam_idle_event->event);
1501 goto IDLE_EVENT_CALLBACK_DONE;
1504 /* remove event from list */
1505 g_mutex_lock(&cb_info->idle_event_mutex);
1507 if (cb_info->idle_event_list)
1508 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1510 /*LOGD("remove camera idle event %p, %p", cam_idle_event, cb_info->idle_event_list);*/
1511 g_mutex_unlock(&cb_info->idle_event_mutex);
1514 _camera_client_user_callback(cam_idle_event->cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
1516 /* send signal for waiting thread */
1517 g_cond_signal(&cb_info->idle_event_cond);
1519 IDLE_EVENT_CALLBACK_DONE:
1520 /* unlock and release event */
1521 g_mutex_unlock(&cam_idle_event->event_mutex);
1522 g_mutex_clear(&cam_idle_event->event_mutex);
1524 g_free(cam_idle_event);
1525 cam_idle_event = NULL;
1530 static void *_camera_msg_handler_func(gpointer data)
1534 camera_message_s *cam_msg = NULL;
1535 camera_idle_event_s *cam_idle_event = NULL;
1536 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1537 camera_cb_info_s *cb_info = NULL;
1539 if (!handler_info || !handler_info->cb_info) {
1540 LOGE("NULL handler %p", handler_info);
1544 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1545 type = handler_info->type;
1547 LOGD("t:%d start", type);
1549 g_mutex_lock(&handler_info->mutex);
1551 while (g_atomic_int_get(&handler_info->running)) {
1552 if (g_queue_is_empty(handler_info->queue)) {
1553 /*LOGD("t:%d signal wait...", type);*/
1554 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1555 /*LOGD("t:%d signal received", type);*/
1557 if (g_atomic_int_get(&handler_info->running) == 0) {
1558 LOGD("t:%d stop event thread", type);
1563 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1565 g_mutex_unlock(&handler_info->mutex);
1567 if (cam_msg == NULL) {
1568 LOGE("t:%d NULL message", type);
1569 g_mutex_lock(&handler_info->mutex);
1575 if (api < MUSE_CAMERA_API_MAX) {
1578 g_mutex_lock(&cb_info->api_mutex[api]);
1580 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1581 cb_info->api_ret[api] = ret;
1582 cb_info->api_activating[api] = 1;
1584 /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
1586 g_cond_signal(&cb_info->api_cond[api]);
1588 LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1591 g_mutex_unlock(&cb_info->api_mutex[api]);
1592 } else if (api == MUSE_CAMERA_CB_EVENT) {
1593 switch (cam_msg->event_class) {
1594 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1595 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event);
1597 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1598 cam_idle_event = g_new0(camera_idle_event_s, 1);
1599 if (cam_idle_event == NULL) {
1600 LOGE("t:%d cam_idle_event alloc failed", type);
1604 cam_idle_event->event = cam_msg->event;
1605 cam_idle_event->cb_info = cb_info;
1606 g_mutex_init(&cam_idle_event->event_mutex);
1607 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg) - 1);
1609 /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, cam_msg->event, cam_idle_event);*/
1611 g_mutex_lock(&cb_info->idle_event_mutex);
1612 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1613 g_mutex_unlock(&cb_info->idle_event_mutex);
1615 g_idle_add_full(G_PRIORITY_DEFAULT,
1616 (GSourceFunc)_camera_idle_event_callback,
1617 (gpointer)cam_idle_event,
1621 LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
1625 LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1631 g_mutex_lock(&handler_info->mutex);
1634 /* remove remained event */
1635 while (!g_queue_is_empty(handler_info->queue)) {
1636 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1638 LOGD("t:%d remove camera message %p", type, cam_msg);
1642 LOGW("t:%d NULL camera message", type);
1646 g_mutex_unlock(&handler_info->mutex);
1648 LOGD("t:%d return", type);
1654 static void _camera_remove_idle_event_all(camera_cb_info_s *cb_info)
1656 camera_idle_event_s *cam_idle_event = NULL;
1657 gboolean ret = TRUE;
1659 gint64 end_time = 0;
1661 if (cb_info == NULL) {
1662 LOGE("cb_info is NULL");
1666 g_mutex_lock(&cb_info->idle_event_mutex);
1668 if (cb_info->idle_event_list == NULL) {
1669 LOGD("No remained idle event");
1670 g_mutex_unlock(&cb_info->idle_event_mutex);
1674 list = cb_info->idle_event_list;
1677 cam_idle_event = list->data;
1678 list = g_list_next(list);
1680 if (!cam_idle_event) {
1681 LOGW("Fail to remove idle event. The event is NULL");
1685 if (g_mutex_trylock(&cam_idle_event->event_mutex)) {
1686 ret = g_idle_remove_by_data(cam_idle_event);
1688 LOGD("remove idle event [%p], ret[%d]", cam_idle_event, ret);
1691 cam_idle_event->cb_info = NULL;
1692 LOGW("idle event %p will be called later", cam_idle_event);
1695 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1697 g_mutex_unlock(&cam_idle_event->event_mutex);
1700 g_mutex_clear(&cam_idle_event->event_mutex);
1702 g_free(cam_idle_event);
1703 cam_idle_event = NULL;
1705 LOGD("remove idle event done");
1711 LOGW("event lock failed. it's being called...");
1713 end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
1715 if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
1716 LOGW("signal received");
1721 g_list_free(cb_info->idle_event_list);
1722 cb_info->idle_event_list = NULL;
1724 g_mutex_unlock(&cb_info->idle_event_mutex);
1730 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg)
1732 camera_message_s *cam_msg = NULL;
1734 if (!cb_info || !msg) {
1735 LOGE("NULL pointer %p %p", cb_info, msg);
1739 cam_msg = g_new0(camera_message_s, 1);
1741 LOGE("failed to alloc cam_msg for [%s]", msg);
1746 cam_msg->event = event;
1747 cam_msg->event_class = event_class;
1749 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1751 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1753 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1754 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1755 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1756 g_cond_signal(&cb_info->preview_cb_info.cond);
1757 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1758 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1759 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1760 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1761 g_cond_signal(&cb_info->capture_cb_info.cond);
1762 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1764 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1765 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1766 g_cond_signal(&cb_info->msg_handler_info.cond);
1767 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1776 static void *_camera_msg_recv_func(gpointer data)
1783 int event_class = 0;
1787 char *error_msg = NULL;
1788 char *recv_msg = NULL;
1789 char **parse_str = NULL;
1790 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
1793 LOGE("cb_info NULL");
1799 parse_str = (char **)malloc(sizeof(char *) * CAMERA_PARSE_STRING_SIZE);
1800 if (parse_str == NULL) {
1801 LOGE("parse_str malloc failed");
1805 for (i = 0 ; i < CAMERA_PARSE_STRING_SIZE ; i++) {
1806 parse_str[i] = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
1807 if (parse_str[i] == NULL) {
1808 LOGE("parse_str[%d] malloc failed", i);
1809 goto CB_HANDLER_EXIT;
1813 recv_msg = cb_info->recv_msg;
1815 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
1816 ret = muse_core_ipc_recv_msg(cb_info->fd, recv_msg);
1818 cb_info->is_server_connected = FALSE;
1819 LOGE("receive msg failed - server disconnected");
1823 recv_msg[ret] = '\0';
1829 /*LOGD("recvMSg : %s, length : %d", recv_msg, ret);*/
1831 /* Need to split the combined entering msgs.
1832 This module supports up to 200 combined msgs. */
1833 for (str_pos = 0; str_pos < ret; str_pos++) {
1834 if (recv_msg[str_pos] == '}') {
1835 strncpy(parse_str[num_token], recv_msg + prev_pos, str_pos - prev_pos + 1);
1836 /*LOGD("splitted msg : [%s], Index : %d", parse_str[num_token], num_token);*/
1837 prev_pos = str_pos + 1;
1842 /*LOGD("num_token : %d", num_token);*/
1844 /* Re-construct to the useful single msg. */
1845 for (i = 0; i < num_token; i++) {
1846 if (i >= CAMERA_PARSE_STRING_SIZE) {
1847 LOGE("invalid token index %d", i);
1856 if (!muse_camera_msg_get(api, parse_str[i])) {
1857 LOGE("failed to get camera api");
1861 if (api == MUSE_CAMERA_CB_EVENT) {
1862 if (!muse_camera_msg_get(event, parse_str[i]) ||
1863 !muse_camera_msg_get(event_class, parse_str[i])) {
1864 LOGE("failed to get camera event or event_class [%s]", parse_str[i]);
1868 if (!muse_camera_msg_get(api_class, parse_str[i])) {
1869 LOGE("failed to get camera api_class [%s]", parse_str[i]);
1874 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1875 if (api >= MUSE_CAMERA_API_MAX) {
1876 LOGE("invalid api %d", api);
1880 g_mutex_lock(&cb_info->api_mutex[api]);
1882 if (!muse_camera_msg_get(ret, parse_str[i])) {
1883 LOGE("failed to get camera ret");
1884 g_mutex_unlock(&cb_info->api_mutex[api]);
1888 cb_info->api_ret[api] = ret;
1889 cb_info->api_activating[api] = 1;
1891 if (api == MUSE_CAMERA_API_CREATE) {
1892 if (ret != CAMERA_ERROR_NONE) {
1893 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1894 LOGE("camera create error 0x%x. close client cb handler", ret);
1896 } else if (api == MUSE_CAMERA_API_DESTROY) {
1897 if (ret == CAMERA_ERROR_NONE) {
1898 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1899 LOGD("camera destroy done. close client cb handler");
1901 } else if (api == MUSE_CAMERA_API_GET_FLASH_STATE ||
1902 api == MUSE_CAMERA_API_GET_DEVICE_STATE) {
1903 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1904 LOGD("get flash or device state done. close client cb handler");
1907 g_cond_signal(&cb_info->api_cond[api]);
1908 g_mutex_unlock(&cb_info->api_mutex[api]);
1909 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
1910 __camera_add_msg_to_queue(cb_info, api, event, event_class, parse_str[i]);
1912 LOGW("unknown camera api %d, class %d", api, api_class);
1918 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
1920 if (!cb_info->is_server_connected) {
1921 /* send error msg for server disconnection */
1922 error_msg = muse_core_msg_json_factory_new(MUSE_CAMERA_CB_EVENT,
1923 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
1924 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
1927 LOGE("error_msg failed");
1928 goto CB_HANDLER_EXIT;
1931 __camera_add_msg_to_queue(cb_info,
1932 MUSE_CAMERA_CB_EVENT,
1933 MUSE_CAMERA_EVENT_TYPE_ERROR,
1934 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
1937 muse_core_msg_json_factory_free(error_msg);
1940 LOGE("add error msg for service disconnection done");
1945 for (i = 0 ; i < CAMERA_PARSE_STRING_SIZE ; i++) {
1948 parse_str[i] = NULL;
1960 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
1961 int type, const char *thread_name, camera_cb_info_s *cb_info)
1963 if (!handler_info || !thread_name || !cb_info) {
1964 LOGE("t:%d NULL %p %p %p",
1965 type, handler_info, thread_name, cb_info);
1971 handler_info->type = type;
1972 handler_info->queue = g_queue_new();
1973 if (handler_info->queue == NULL) {
1974 LOGE("t:%d queue failed", type);
1978 g_mutex_init(&handler_info->mutex);
1979 g_cond_init(&handler_info->cond);
1981 handler_info->cb_info = (void *)cb_info;
1982 g_atomic_int_set(&handler_info->running, 1);
1984 handler_info->thread = g_thread_try_new(thread_name,
1985 _camera_msg_handler_func, (gpointer)handler_info, NULL);
1986 if (handler_info->thread == NULL) {
1987 LOGE("t:%d thread failed", type);
1989 g_mutex_clear(&handler_info->mutex);
1990 g_cond_clear(&handler_info->cond);
1991 g_queue_free(handler_info->queue);
1992 handler_info->queue = NULL;
1997 LOGD("t:%d done", type);
2003 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2007 if (!handler_info) {
2008 LOGE("NULL handler");
2012 if (!handler_info->thread) {
2013 LOGW("thread is not created");
2017 type = handler_info->type;
2019 LOGD("t:%d thread %p", type, handler_info->thread);
2021 g_mutex_lock(&handler_info->mutex);
2022 g_atomic_int_set(&handler_info->running, 0);
2023 g_cond_signal(&handler_info->cond);
2024 g_mutex_unlock(&handler_info->mutex);
2026 g_thread_join(handler_info->thread);
2027 g_thread_unref(handler_info->thread);
2028 handler_info->thread = NULL;
2030 g_mutex_clear(&handler_info->mutex);
2031 g_cond_clear(&handler_info->cond);
2032 g_queue_free(handler_info->queue);
2033 handler_info->queue = NULL;
2035 LOGD("t:%d done", type);
2041 static camera_cb_info_s *_camera_client_callback_new(gint sockfd, bool need_msg_handler_thread)
2043 camera_cb_info_s *cb_info = NULL;
2046 g_return_val_if_fail(sockfd > 0, NULL);
2048 cb_info = g_new0(camera_cb_info_s, 1);
2049 if (cb_info == NULL) {
2050 LOGE("cb_info failed");
2054 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2055 g_mutex_init(&cb_info->api_mutex[i]);
2056 g_cond_init(&cb_info->api_cond[i]);
2059 g_mutex_init(&cb_info->idle_event_mutex);
2060 g_cond_init(&cb_info->idle_event_cond);
2061 g_mutex_init(&cb_info->mp_data_mutex);
2062 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2063 g_mutex_init(&cb_info->evas_mutex);
2064 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2066 if (need_msg_handler_thread) {
2067 /* message handler thread */
2068 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2069 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2070 LOGE("msg_handler_info failed");
2074 /* message handler thread for preview callback */
2075 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2076 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2077 LOGE("preview_cb_info failed");
2081 /* message handler thread for capture callback */
2082 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2083 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2084 LOGE("capture_cb_info failed");
2089 cb_info->fd = sockfd;
2090 cb_info->preview_cb_flag = 0;
2091 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2092 cb_info->evas_info = NULL;
2093 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2095 /* message receive thread */
2096 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2097 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2098 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2099 if (cb_info->msg_recv_thread == NULL) {
2100 LOGE("message receive thread creation failed");
2104 cb_info->is_server_connected = TRUE;
2110 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2111 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2112 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2114 g_mutex_clear(&cb_info->idle_event_mutex);
2115 g_cond_clear(&cb_info->idle_event_cond);
2116 g_mutex_clear(&cb_info->mp_data_mutex);
2117 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2118 g_mutex_clear(&cb_info->evas_mutex);
2119 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2121 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2122 g_mutex_clear(&cb_info->api_mutex[i]);
2123 g_cond_clear(&cb_info->api_cond[i]);
2133 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2137 g_return_if_fail(cb_info != NULL);
2139 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2141 g_thread_join(cb_info->msg_recv_thread);
2142 g_thread_unref(cb_info->msg_recv_thread);
2143 cb_info->msg_recv_thread = NULL;
2145 LOGD("msg_recv thread removed");
2147 /* destroy msg handler threads */
2148 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2149 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2150 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2152 g_mutex_clear(&cb_info->idle_event_mutex);
2153 g_cond_clear(&cb_info->idle_event_cond);
2154 g_mutex_clear(&cb_info->mp_data_mutex);
2155 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2156 g_mutex_clear(&cb_info->evas_mutex);
2157 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2159 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2160 g_mutex_clear(&cb_info->api_mutex[i]);
2161 g_cond_clear(&cb_info->api_cond[i]);
2164 if (cb_info->fd > -1) {
2165 muse_core_connection_close(cb_info->fd);
2169 if (cb_info->bufmgr) {
2170 tbm_bufmgr_deinit(cb_info->bufmgr);
2171 cb_info->bufmgr = NULL;
2173 if (cb_info->pkt_fmt) {
2174 media_format_unref(cb_info->pkt_fmt);
2175 cb_info->pkt_fmt = NULL;
2178 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2179 if (cb_info->evas_info)
2180 mm_evas_renderer_destroy(&cb_info->evas_info);
2181 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2183 cb_info->preview_cb_flag = 0;
2192 int _camera_start_evas_rendering(camera_h camera)
2194 int ret = CAMERA_ERROR_NONE;
2195 camera_cli_s *pc = (camera_cli_s *)camera;
2197 if (!pc || !pc->cb_info) {
2198 LOGE("NULL handle");
2199 return CAMERA_ERROR_INVALID_PARAMETER;
2204 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2205 LOGE("EVAS surface is not set");
2206 return CAMERA_ERROR_NONE;
2209 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2210 g_mutex_lock(&pc->cb_info->evas_mutex);
2212 /* set evas render flag as RUN */
2213 pc->cb_info->run_evas_render = true;
2214 ret = CAMERA_ERROR_NONE;
2216 g_mutex_unlock(&pc->cb_info->evas_mutex);
2217 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2218 LOGW("evas renderer is not supported");
2219 ret = CAMERA_ERROR_NOT_SUPPORTED;
2220 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2226 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2228 int ret = CAMERA_ERROR_NONE;
2229 camera_cli_s *pc = (camera_cli_s *)camera;
2231 if (!pc || !pc->cb_info) {
2232 LOGE("NULL handle");
2233 return CAMERA_ERROR_INVALID_PARAMETER;
2236 LOGD("stop - keep screen %d", keep_screen);
2238 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2239 LOGE("EVAS surface is not set");
2240 return CAMERA_ERROR_NONE;
2243 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2244 g_mutex_lock(&pc->cb_info->evas_mutex);
2246 /* set evas render flag as STOP and release buffers */
2247 pc->cb_info->run_evas_render = false;
2249 ret = mm_evas_renderer_retrieve_all_packets(pc->cb_info->evas_info, keep_screen);
2250 if (ret != MM_ERROR_NONE) {
2251 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2252 ret = CAMERA_ERROR_INVALID_OPERATION;
2255 g_mutex_unlock(&pc->cb_info->evas_mutex);
2256 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2257 LOGW("evas renderer is not supported");
2258 ret = CAMERA_ERROR_NOT_SUPPORTED;
2259 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2265 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2267 int ret = CAMERA_ERROR_NONE;
2271 camera_cb_info_s *cb_info = NULL;
2273 /* create muse connection */
2274 if (!key || !value) {
2275 LOGE("NULL pointer");
2276 return CAMERA_ERROR_INVALID_PARAMETER;
2279 sock_fd = muse_core_client_new();
2281 LOGE("muse_core_client_new failed");
2282 return CAMERA_ERROR_INVALID_OPERATION;
2285 msg = muse_core_msg_json_factory_new(api,
2286 MUSE_TYPE_INT, "module", MUSE_CAMERA,
2287 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2291 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2295 send_ret = muse_core_ipc_send_msg(sock_fd, msg);
2297 muse_core_msg_json_factory_free(msg);
2301 LOGE("send msg failed");
2302 ret = CAMERA_ERROR_INVALID_OPERATION;
2306 cb_info = _camera_client_callback_new(sock_fd, false);
2308 LOGE("cb_info alloc failed");
2309 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2315 ret = _camera_client_wait_for_cb_return(api, cb_info, CAMERA_CB_TIMEOUT);
2317 if (ret == CAMERA_ERROR_NONE)
2318 muse_core_msg_json_deserialize(key, cb_info->recv_msg, NULL, value, NULL, MUSE_TYPE_ANY);
2320 LOGD("api %d - value %d", api, *value);
2323 /* release resources */
2325 _camera_client_callback_destroy(cb_info);
2330 muse_core_connection_close(sock_fd);
2338 int camera_create(camera_device_e device, camera_h *camera)
2341 char *send_msg = NULL;
2343 int ret = CAMERA_ERROR_NONE;
2345 camera_cli_s *pc = NULL;
2346 tbm_bufmgr bufmgr = NULL;
2348 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2349 muse_core_api_module_e muse_module = MUSE_CAMERA;
2350 int device_type = (int)device;
2353 LOGE("NULL pointer");
2354 return CAMERA_ERROR_INVALID_PARAMETER;
2357 sock_fd = muse_core_client_new();
2359 LOGE("muse_core_client_new failed - returned fd %d", sock_fd);
2360 ret = CAMERA_ERROR_INVALID_OPERATION;
2366 send_msg = muse_core_msg_json_factory_new(api,
2367 MUSE_TYPE_INT, "module", muse_module,
2368 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2369 MUSE_TYPE_INT, "pid", pid,
2374 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2378 send_ret = muse_core_ipc_send_msg(sock_fd, send_msg);
2380 muse_core_msg_json_factory_free(send_msg);
2384 LOGE("send msg failed %d", errno);
2385 ret = CAMERA_ERROR_INVALID_OPERATION;
2389 pc = g_new0(camera_cli_s, 1);
2391 LOGE("camera_cli_s alloc failed");
2392 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2396 bufmgr = tbm_bufmgr_init(-1);
2397 if (bufmgr == NULL) {
2398 LOGE("get tbm bufmgr failed");
2399 ret = CAMERA_ERROR_INVALID_OPERATION;
2403 pc->cb_info = _camera_client_callback_new(sock_fd, true);
2404 if (pc->cb_info == NULL) {
2405 LOGE("cb_info alloc failed");
2406 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2412 LOGD("cb info : %d", pc->cb_info->fd);
2414 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2415 if (ret == CAMERA_ERROR_NONE) {
2416 intptr_t handle = 0;
2417 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2419 LOGE("Receiving Handle Failed!!");
2420 ret = CAMERA_ERROR_INVALID_OPERATION;
2424 pc->remote_handle = handle;
2425 pc->cb_info->bufmgr = bufmgr;
2427 ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL);
2428 if (ret != CAMERA_ERROR_NONE) {
2429 LOGE("init display failed 0x%x", ret);
2433 LOGD("camera create 0x%x", pc->remote_handle);
2434 *camera = (camera_h)pc;
2443 tbm_bufmgr_deinit(bufmgr);
2448 muse_core_connection_close(sock_fd);
2454 _camera_client_callback_destroy(pc->cb_info);
2461 LOGE("camera create error : 0x%x", ret);
2467 int camera_change_device(camera_h camera, camera_device_e device)
2469 int ret = CAMERA_ERROR_NONE;
2470 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2471 camera_cli_s *pc = (camera_cli_s *)camera;
2472 camera_msg_param param;
2474 if (!pc || !pc->cb_info) {
2475 LOGE("NULL handle");
2476 return CAMERA_ERROR_INVALID_PARAMETER;
2479 CAMERA_MSG_PARAM_SET(param, INT, device);
2481 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2487 int camera_destroy(camera_h camera)
2489 int ret = CAMERA_ERROR_NONE;
2490 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2491 camera_cli_s *pc = (camera_cli_s *)camera;
2493 if (!pc || !pc->cb_info) {
2494 LOGE("NULL handle");
2495 return CAMERA_ERROR_INVALID_PARAMETER;
2500 if (pc->cb_info->is_server_connected)
2501 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2503 LOGW("server disconnected. release resource without send message.");
2505 if (ret == CAMERA_ERROR_NONE) {
2506 _camera_remove_idle_event_all(pc->cb_info);
2507 _camera_client_callback_destroy(pc->cb_info);
2517 int camera_start_preview(camera_h camera)
2519 int ret = CAMERA_ERROR_NONE;
2520 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2521 camera_cli_s *pc = (camera_cli_s *)camera;
2523 if (!pc || !pc->cb_info) {
2524 LOGE("NULL handle");
2525 return CAMERA_ERROR_INVALID_PARAMETER;
2530 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT_LONG);
2531 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2532 ret = _camera_start_evas_rendering(camera);
2533 if (ret != CAMERA_ERROR_NONE) {
2534 LOGE("stop preview because of error");
2535 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, pc->cb_info, NULL, 0);
2539 LOGD("ret : 0x%x", ret);
2545 int camera_stop_preview(camera_h camera)
2547 int ret = CAMERA_ERROR_NONE;
2548 camera_cli_s *pc = (camera_cli_s *)camera;
2549 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2550 camera_state_e current_state = CAMERA_STATE_NONE;
2552 if (!pc || !pc->cb_info) {
2553 LOGE("NULL handle");
2554 return CAMERA_ERROR_INVALID_PARAMETER;
2559 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2560 ret = camera_get_state(camera, ¤t_state);
2561 if (ret != CAMERA_ERROR_NONE) {
2562 LOGE("failed to get current state 0x%x", ret);
2566 if (current_state == CAMERA_STATE_PREVIEW) {
2567 ret = _camera_stop_evas_rendering(camera, false);
2568 if (ret != CAMERA_ERROR_NONE)
2573 /* send stop preview message */
2574 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2576 if (ret != CAMERA_ERROR_NONE &&
2577 current_state == CAMERA_STATE_PREVIEW) {
2578 LOGW("restart evas rendering");
2579 _camera_start_evas_rendering(camera);
2582 LOGD("ret : 0x%x", ret);
2588 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2590 int ret = CAMERA_ERROR_NONE;
2591 camera_cli_s *pc = (camera_cli_s *)camera;
2592 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2594 if (!pc || !pc->cb_info) {
2595 LOGE("NULL handle");
2596 return CAMERA_ERROR_INVALID_PARAMETER;
2601 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2602 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2604 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2605 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2607 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2609 LOGD("ret : 0x%x", ret);
2615 bool camera_is_supported_continuous_capture(camera_h camera)
2617 int ret = CAMERA_ERROR_NONE;
2618 camera_cli_s *pc = (camera_cli_s *)camera;
2619 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2621 if (!pc || !pc->cb_info) {
2622 LOGE("NULL handle");
2623 return CAMERA_ERROR_INVALID_PARAMETER;
2628 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2631 LOGE("error is occurred 0x%x", ret);
2635 LOGD("ret : %d", ret);
2641 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)
2643 int ret = CAMERA_ERROR_NONE;
2644 camera_cli_s *pc = (camera_cli_s *)camera;
2645 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2646 camera_msg_param param;
2649 if (!pc || !pc->cb_info) {
2650 LOGE("NULL handle");
2651 return CAMERA_ERROR_INVALID_PARAMETER;
2656 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2657 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2658 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2660 value = (count << 16) | interval;
2661 CAMERA_MSG_PARAM_SET(param, INT, value);
2663 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2665 LOGD("ret : 0x%x", ret);
2671 int camera_stop_continuous_capture(camera_h camera)
2673 int ret = CAMERA_ERROR_NONE;
2674 camera_cli_s *pc = (camera_cli_s *)camera;
2675 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2677 if (!pc || !pc->cb_info) {
2678 LOGE("NULL handle");
2679 return CAMERA_ERROR_INVALID_PARAMETER;
2684 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2686 LOGD("ret : 0x%x", ret);
2692 bool camera_is_supported_face_detection(camera_h camera)
2694 int ret = CAMERA_ERROR_NONE;
2695 camera_cli_s *pc = (camera_cli_s *)camera;
2696 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2698 if (!pc || !pc->cb_info) {
2699 LOGE("NULL handle");
2700 return CAMERA_ERROR_INVALID_PARAMETER;
2705 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2708 LOGE("error is occurred 0x%x", ret);
2712 LOGD("ret : %d", ret);
2718 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2720 int ret = CAMERA_ERROR_NONE;
2721 camera_cli_s *pc = (camera_cli_s *)camera;
2722 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2724 if (!pc || !pc->cb_info) {
2725 LOGE("NULL handle");
2726 return CAMERA_ERROR_INVALID_PARAMETER;
2731 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2734 LOGE("error is occurred 0x%x", ret);
2738 LOGD("ret : %d", ret);
2744 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2746 int ret = CAMERA_ERROR_NONE;
2747 camera_cli_s *pc = (camera_cli_s *)camera;
2748 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2750 if (!pc || !pc->cb_info) {
2751 LOGE("NULL handle");
2752 return CAMERA_ERROR_INVALID_PARAMETER;
2757 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2760 LOGE("error is occurred 0x%x", ret);
2764 LOGD("ret : %d", ret);
2769 int camera_get_device_count(camera_h camera, int *device_count)
2771 int ret = CAMERA_ERROR_NONE;
2772 camera_cli_s *pc = (camera_cli_s *)camera;
2773 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2774 int get_device_count = 0;
2776 if (!pc || !pc->cb_info) {
2777 LOGE("NULL handle");
2778 return CAMERA_ERROR_INVALID_PARAMETER;
2783 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2785 if (ret == CAMERA_ERROR_NONE) {
2786 muse_camera_msg_get(get_device_count, pc->cb_info->recv_msg);
2787 *device_count = get_device_count;
2790 LOGD("ret : 0x%x", ret);
2795 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2797 int ret = CAMERA_ERROR_NONE;
2798 camera_cli_s *pc = (camera_cli_s *)camera;
2799 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2801 if (!pc || !pc->cb_info) {
2802 LOGE("NULL handle");
2803 return CAMERA_ERROR_INVALID_PARAMETER;
2808 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2809 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2811 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2813 LOGD("ret : 0x%x", ret);
2818 int camera_stop_face_detection(camera_h camera)
2820 int ret = CAMERA_ERROR_NONE;
2821 camera_cli_s *pc = (camera_cli_s *)camera;
2822 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
2824 if (!pc || !pc->cb_info) {
2825 LOGE("NULL handle");
2826 return CAMERA_ERROR_INVALID_PARAMETER;
2831 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2833 LOGD("ret : 0x%x", ret);
2838 int camera_get_state(camera_h camera, camera_state_e *state)
2840 int ret = CAMERA_ERROR_NONE;
2841 camera_cli_s *pc = (camera_cli_s *)camera;
2842 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
2843 int get_state = CAMERA_STATE_NONE;
2845 if (!pc || !pc->cb_info || !state) {
2846 LOGE("NULL pointer %p %p", pc, state);
2847 return CAMERA_ERROR_INVALID_PARAMETER;
2852 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2854 if (ret == CAMERA_ERROR_NONE) {
2855 muse_camera_msg_get(get_state, pc->cb_info->recv_msg);
2856 *state = (camera_state_e)get_state;
2859 LOGD("ret : 0x%x", ret);
2864 int camera_start_focusing(camera_h camera, bool continuous)
2866 int ret = CAMERA_ERROR_NONE;
2867 camera_cli_s *pc = (camera_cli_s *)camera;
2868 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
2869 camera_msg_param param;
2870 int is_continuous = (int)continuous;
2872 if (!pc || !pc->cb_info) {
2873 LOGE("NULL handle");
2874 return CAMERA_ERROR_INVALID_PARAMETER;
2879 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
2881 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2883 LOGD("ret : 0x%x", ret);
2888 int camera_cancel_focusing(camera_h camera)
2890 int ret = CAMERA_ERROR_NONE;
2891 camera_cli_s *pc = (camera_cli_s *)camera;
2892 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
2894 if (!pc || !pc->cb_info) {
2895 LOGE("NULL handle");
2896 return CAMERA_ERROR_INVALID_PARAMETER;
2899 LOGD("Enter, remote_handle : %x", pc->remote_handle);
2901 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2903 LOGD("ret : 0x%x", ret);
2908 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
2910 int ret = CAMERA_ERROR_NONE;
2911 void *set_display_handle = NULL;
2912 Evas_Object *obj = NULL;
2913 const char *object_type = NULL;
2914 camera_cli_s *pc = (camera_cli_s *)camera;
2915 camera_cb_info_s *cb_info = NULL;
2916 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
2917 camera_state_e current_state = CAMERA_STATE_NONE;
2918 camera_msg_param param;
2922 if (!pc || !pc->cb_info) {
2923 LOGE("NULL handle");
2924 return CAMERA_ERROR_INVALID_PARAMETER;
2927 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
2928 LOGE("invalid type %d", type);
2929 return CAMERA_ERROR_INVALID_PARAMETER;
2932 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
2933 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
2934 return CAMERA_ERROR_INVALID_PARAMETER;
2937 cb_info = (camera_cb_info_s *)pc->cb_info;
2939 ret = camera_get_state(camera, ¤t_state);
2940 if (ret != CAMERA_ERROR_NONE) {
2941 LOGE("failed to get current state 0x%x", ret);
2945 if (current_state != CAMERA_STATE_CREATED) {
2946 LOGE("INVALID_STATE : current %d", current_state);
2947 return CAMERA_ERROR_INVALID_STATE;
2950 LOGD("Enter - display : %p", display);
2952 if (type == CAMERA_DISPLAY_TYPE_NONE) {
2953 set_display_handle = 0;
2954 LOGD("display type NONE");
2956 obj = (Evas_Object *)display;
2957 object_type = evas_object_type_get(obj);
2959 if (type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
2960 /* get wayland parent id */
2961 if (_camera_get_wl_info(obj, &pc->wl_info) != CAMERA_ERROR_NONE) {
2962 LOGE("failed to get wayland info");
2963 return CAMERA_ERROR_INVALID_OPERATION;
2966 set_display_handle = (void *)&pc->wl_info;
2967 LOGD("display type OVERLAY : handle %p", set_display_handle);
2968 } else if (type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
2969 /* evas object surface */
2970 set_display_handle = (void *)display;
2971 LOGD("display type EVAS : handle %p", set_display_handle);
2973 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2974 g_mutex_lock(&cb_info->evas_mutex);
2976 if (cb_info->evas_info) {
2977 LOGW("destroy existed evas renderer %p", cb_info->evas_info);
2978 ret = mm_evas_renderer_destroy(&cb_info->evas_info);
2979 if (ret != MM_ERROR_NONE) {
2980 LOGE("failed to destroy evas renderer %p", cb_info->evas_info);
2981 g_mutex_unlock(&cb_info->evas_mutex);
2982 return CAMERA_ERROR_INVALID_OPERATION;
2986 /* create evas renderer */
2987 ret = mm_evas_renderer_create(&cb_info->evas_info, (Evas_Object *)set_display_handle);
2988 if (ret == MM_ERROR_NONE) {
2989 camera_flip_e flip = CAMERA_FLIP_NONE;
2990 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
2991 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
2998 camera_get_display_flip(camera, &flip);
2999 camera_get_display_mode(camera, &mode);
3000 camera_get_display_rotation(camera, &rotation);
3001 camera_is_display_visible(camera, &visible);
3002 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3004 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
3005 flip, mode, rotation, visible, x, y, width, height);
3007 ret = mm_evas_renderer_set_flip(cb_info->evas_info, flip);
3008 ret |= mm_evas_renderer_set_geometry(cb_info->evas_info, mode);
3009 ret |= mm_evas_renderer_set_rotation(cb_info->evas_info, rotation);
3010 ret |= mm_evas_renderer_set_visible(cb_info->evas_info, visible);
3012 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
3013 ret |= mm_evas_renderer_set_roi_area(cb_info->evas_info, x, y, width, height);
3016 g_mutex_unlock(&cb_info->evas_mutex);
3018 if (ret != MM_ERROR_NONE) {
3019 LOGE("mm_evas_renderer error 0x%x", ret);
3020 return CAMERA_ERROR_INVALID_OPERATION;
3022 #else /* TIZEN_FEATURE_EVAS_RENDERER */
3023 LOGE("EVAS surface is not supported");
3024 return CAMERA_ERROR_NOT_SUPPORTED;
3025 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3027 LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type);
3028 return CAMERA_ERROR_INVALID_PARAMETER;
3031 LOGE("failed to get evas object type from %p", obj);
3032 return CAMERA_ERROR_INVALID_PARAMETER;
3036 pc->display_handle = (intptr_t)set_display_handle;
3038 if (type == CAMERA_DISPLAY_TYPE_OVERLAY) {
3041 length = sizeof(camera_wl_info_s) / sizeof(int) + \
3042 (sizeof(camera_wl_info_s) % sizeof(int) ? 1 : 0);
3044 msg = muse_core_msg_json_factory_new(api,
3045 MUSE_TYPE_INT, "type", type,
3046 MUSE_TYPE_ARRAY, "wl_info", length, (int *)&pc->wl_info,
3049 LOGE("msg creation failed: api %d", api);
3050 return CAMERA_ERROR_OUT_OF_MEMORY;
3053 if (pc->cb_info->is_server_connected)
3054 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
3057 LOGE("message send failed");
3058 ret = CAMERA_ERROR_INVALID_OPERATION;
3060 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
3063 muse_core_msg_json_factory_free(msg);
3065 LOGD("wayland parent id : %d, window %d,%d,%dx%d",
3066 pc->wl_info.parent_id, pc->wl_info.window_x, pc->wl_info.window_y,
3067 pc->wl_info.window_width, pc->wl_info.window_height);
3069 CAMERA_MSG_PARAM_SET(param, INT, type);
3071 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3074 if (ret != CAMERA_ERROR_NONE)
3075 LOGE("set display error 0x%x", ret);
3076 else if (type == CAMERA_DISPLAY_TYPE_EVAS)
3077 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3083 int camera_set_preview_resolution(camera_h camera, int width, int height)
3085 int ret = CAMERA_ERROR_NONE;
3086 camera_cli_s *pc = (camera_cli_s *)camera;
3087 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3088 camera_msg_param param;
3091 if (!pc || !pc->cb_info) {
3092 LOGE("NULL handle");
3093 return CAMERA_ERROR_INVALID_PARAMETER;
3096 value = (width << 16) | height;
3097 CAMERA_MSG_PARAM_SET(param, INT, value);
3099 LOGD("%dx%d -> 0x%x", width, height, value);
3101 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3103 LOGD("ret : 0x%x", ret);
3109 int camera_set_capture_resolution(camera_h camera, int width, int height)
3111 int ret = CAMERA_ERROR_NONE;
3112 camera_cli_s *pc = (camera_cli_s *)camera;
3113 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3114 camera_msg_param param;
3117 if (!pc || !pc->cb_info) {
3118 LOGE("NULL handle");
3119 return CAMERA_ERROR_INVALID_PARAMETER;
3124 value = (width << 16) | height;
3125 CAMERA_MSG_PARAM_SET(param, INT, value);
3127 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3129 LOGD("ret : 0x%x", ret);
3135 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3137 int ret = CAMERA_ERROR_NONE;
3138 int set_format = (int)format;
3139 camera_cli_s *pc = (camera_cli_s *)camera;
3140 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3141 camera_msg_param param;
3143 if (!pc || !pc->cb_info) {
3144 LOGE("NULL handle");
3145 return CAMERA_ERROR_INVALID_PARAMETER;
3148 LOGD("Enter - format %d", set_format);
3150 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3152 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3154 LOGD("ret : 0x%x", ret);
3160 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3162 int ret = CAMERA_ERROR_NONE;
3163 int set_format = (int)format;
3164 camera_msg_param param;
3165 camera_cli_s *pc = (camera_cli_s *)camera;
3166 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3168 if (!pc || !pc->cb_info) {
3169 LOGE("NULL handle");
3170 return CAMERA_ERROR_INVALID_PARAMETER;
3173 LOGD("Enter - capture_format %d", set_format);
3175 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3177 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3179 LOGD("ret : 0x%x", ret);
3185 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3187 int ret = CAMERA_ERROR_NONE;
3188 camera_cli_s *pc = (camera_cli_s *)camera;
3189 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3193 if (!pc || !pc->cb_info || !width || !height) {
3194 LOGE("NULL pointer %p %p %p", pc, width, height);
3195 return CAMERA_ERROR_INVALID_PARAMETER;
3200 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3202 if (ret == CAMERA_ERROR_NONE) {
3203 muse_camera_msg_get(get_width, pc->cb_info->recv_msg);
3204 muse_camera_msg_get(get_height, pc->cb_info->recv_msg);
3206 *height = get_height;
3209 LOGD("ret : 0x%x", ret);
3215 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3217 int ret = CAMERA_ERROR_NONE;
3218 int set_rotation = (int)rotation;
3219 camera_cli_s *pc = (camera_cli_s *)camera;
3220 camera_msg_param param;
3222 if (!pc || !pc->cb_info) {
3223 LOGE("NULL handle");
3224 return CAMERA_ERROR_INVALID_PARAMETER;
3227 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3228 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3229 g_mutex_lock(&pc->cb_info->evas_mutex);
3231 ret = mm_evas_renderer_set_rotation(pc->cb_info->evas_info, rotation);
3233 g_mutex_unlock(&pc->cb_info->evas_mutex);
3235 if (ret != MM_ERROR_NONE) {
3236 LOGE("failed to set rotation for evas surface 0x%x", ret);
3237 return CAMERA_ERROR_INVALID_OPERATION;
3240 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3242 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3244 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3250 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3252 int ret = CAMERA_ERROR_NONE;
3253 int get_rotation = CAMERA_ROTATION_NONE;
3254 camera_cli_s *pc = (camera_cli_s *)camera;
3256 if (!pc || !pc->cb_info || !rotation) {
3257 LOGE("NULL pointer %p %p", pc, rotation);
3258 return CAMERA_ERROR_INVALID_PARAMETER;
3261 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3263 if (ret == CAMERA_ERROR_NONE) {
3264 muse_camera_msg_get(get_rotation, pc->cb_info->recv_msg);
3265 *rotation = (camera_rotation_e)get_rotation;
3272 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3274 int ret = CAMERA_ERROR_NONE;
3275 int set_flip = (int)flip;
3276 camera_cli_s *pc = (camera_cli_s *)camera;
3277 camera_msg_param param;
3279 if (!pc || !pc->cb_info) {
3280 LOGE("NULL handle");
3281 return CAMERA_ERROR_INVALID_PARAMETER;
3284 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3285 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3286 g_mutex_lock(&pc->cb_info->evas_mutex);
3288 ret = mm_evas_renderer_set_flip(pc->cb_info->evas_info, flip);
3290 g_mutex_unlock(&pc->cb_info->evas_mutex);
3292 if (ret != MM_ERROR_NONE) {
3293 LOGE("failed to set flip for evas surface 0x%x", ret);
3294 return CAMERA_ERROR_INVALID_OPERATION;
3297 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3299 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3301 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3307 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3309 int ret = CAMERA_ERROR_NONE;
3310 int get_flip = CAMERA_FLIP_NONE;
3311 camera_cli_s *pc = (camera_cli_s *)camera;
3313 if (!pc || !pc->cb_info || !flip) {
3314 LOGE("NULL pointer %p %p", pc, flip);
3315 return CAMERA_ERROR_INVALID_PARAMETER;
3318 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3320 if (ret == CAMERA_ERROR_NONE) {
3321 muse_camera_msg_get(get_flip, pc->cb_info->recv_msg);
3322 *flip = (camera_flip_e)get_flip;
3329 int camera_set_display_visible(camera_h camera, bool visible)
3331 int ret = CAMERA_ERROR_NONE;
3332 int set_visible = (int)visible;
3333 camera_cli_s *pc = (camera_cli_s *)camera;
3334 camera_msg_param param;
3336 if (!pc || !pc->cb_info) {
3337 LOGE("NULL handle");
3338 return CAMERA_ERROR_INVALID_PARAMETER;
3341 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3342 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3343 g_mutex_lock(&pc->cb_info->evas_mutex);
3345 ret = mm_evas_renderer_set_visible(pc->cb_info->evas_info, visible);
3347 g_mutex_unlock(&pc->cb_info->evas_mutex);
3349 if (ret != MM_ERROR_NONE) {
3350 LOGE("failed to set visible for evas surface 0x%x", ret);
3351 return CAMERA_ERROR_INVALID_OPERATION;
3354 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3356 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3358 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3364 int camera_is_display_visible(camera_h camera, bool *visible)
3366 int ret = CAMERA_ERROR_NONE;
3367 int get_visible = true;
3368 camera_cli_s *pc = (camera_cli_s *)camera;
3370 if (!pc || !pc->cb_info || !visible) {
3371 LOGE("NULL pointer %p %p", pc, visible);
3372 return CAMERA_ERROR_INVALID_PARAMETER;
3375 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3377 if (ret == CAMERA_ERROR_NONE) {
3378 muse_camera_msg_get(get_visible, pc->cb_info->recv_msg);
3379 *visible = (bool)get_visible;
3386 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3388 int ret = CAMERA_ERROR_NONE;
3389 int set_mode = (int)mode;
3390 camera_cli_s *pc = (camera_cli_s *)camera;
3391 camera_msg_param param;
3393 if (!pc || !pc->cb_info) {
3394 LOGE("NULL handle");
3395 return CAMERA_ERROR_INVALID_PARAMETER;
3398 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3399 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3400 g_mutex_lock(&pc->cb_info->evas_mutex);
3402 ret = mm_evas_renderer_set_geometry(pc->cb_info->evas_info, mode);
3404 g_mutex_unlock(&pc->cb_info->evas_mutex);
3406 if (ret != MM_ERROR_NONE) {
3407 LOGE("failed to set geometry for evas surface 0x%x", ret);
3408 return CAMERA_ERROR_INVALID_OPERATION;
3411 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3413 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3415 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3421 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3423 int ret = CAMERA_ERROR_NONE;
3424 int get_mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3425 camera_cli_s *pc = (camera_cli_s *)camera;
3427 if (!pc || !pc->cb_info || !mode) {
3428 LOGE("NULL pointer %p %p", pc, mode);
3429 return CAMERA_ERROR_INVALID_PARAMETER;
3432 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3434 if (ret == CAMERA_ERROR_NONE) {
3435 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
3436 *mode = (camera_display_mode_e)get_mode;
3443 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3445 int ret = CAMERA_ERROR_NONE;
3446 int set_hint = (int)hint;
3447 camera_cli_s *pc = (camera_cli_s *)camera;
3448 camera_msg_param param;
3450 if (!pc || !pc->cb_info) {
3451 LOGE("NULL handle");
3452 return CAMERA_ERROR_INVALID_PARAMETER;
3455 LOGD("Enter - hint %d", set_hint);
3457 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3459 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3465 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3467 int ret = CAMERA_ERROR_NONE;
3469 camera_cli_s *pc = (camera_cli_s *)camera;
3470 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3472 if (!pc || !pc->cb_info || !hint) {
3473 LOGE("NULL pointer %p %p", pc, hint);
3474 return CAMERA_ERROR_INVALID_PARAMETER;
3477 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3479 if (ret == CAMERA_ERROR_NONE) {
3480 muse_camera_msg_get(get_hint, pc->cb_info->recv_msg);
3481 *hint = (bool)get_hint;
3483 LOGD("display reuse hint %d", *hint);
3490 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3492 int ret = CAMERA_ERROR_NONE;
3493 camera_cli_s *pc = (camera_cli_s *)camera;
3494 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3498 if (!pc || !pc->cb_info || !width || !height) {
3499 LOGE("NULL pointer %p %p %p", pc, width, height);
3500 return CAMERA_ERROR_INVALID_PARAMETER;
3505 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3507 if (ret == CAMERA_ERROR_NONE) {
3508 muse_camera_msg_get(get_width, pc->cb_info->recv_msg);
3509 muse_camera_msg_get(get_height, pc->cb_info->recv_msg);
3511 *height = get_height;
3514 LOGD("ret : 0x%x", ret);
3520 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3522 int ret = CAMERA_ERROR_NONE;
3523 camera_cli_s *pc = (camera_cli_s *)camera;
3524 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3527 if (!pc || !pc->cb_info || !format) {
3528 LOGE("NULL pointer %p %p", pc, format);
3529 return CAMERA_ERROR_INVALID_PARAMETER;
3534 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3536 if (ret == CAMERA_ERROR_NONE) {
3537 muse_camera_msg_get(get_format, pc->cb_info->recv_msg);
3538 *format = (camera_pixel_format_e)get_format;
3541 LOGD("ret : 0x%x", ret);
3547 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3549 int ret = CAMERA_ERROR_NONE;
3550 camera_cli_s *pc = (camera_cli_s *)camera;
3551 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3554 if (!pc || !pc->cb_info || !format) {
3555 LOGE("NULL pointer %p %p", pc, format);
3556 return CAMERA_ERROR_INVALID_PARAMETER;
3561 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3563 if (ret == CAMERA_ERROR_NONE) {
3564 muse_camera_msg_get(get_format, pc->cb_info->recv_msg);
3565 *format = (camera_pixel_format_e)get_format;
3568 LOGD("ret : 0x%x", ret);
3574 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3576 int ret = CAMERA_ERROR_NONE;
3577 camera_cli_s *pc = (camera_cli_s *)camera;
3578 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3579 int get_facing_direction = 0;
3581 if (!pc || !pc->cb_info || !facing_direction) {
3582 LOGE("NULL pointer %p %p", pc, facing_direction);
3583 return CAMERA_ERROR_INVALID_PARAMETER;
3588 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3590 if (ret == CAMERA_ERROR_NONE) {
3591 muse_camera_msg_get(get_facing_direction, pc->cb_info->recv_msg);
3592 *facing_direction = (camera_facing_direction_e)get_facing_direction;
3595 LOGD("ret : 0x%x", ret);
3601 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3603 int ret = CAMERA_ERROR_NONE;
3604 camera_cli_s *pc = (camera_cli_s *)camera;
3605 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3607 if (!pc || !pc->cb_info || !callback) {
3608 LOGE("NULL pointer %p %p", pc, callback);
3609 return CAMERA_ERROR_INVALID_PARAMETER;
3614 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3616 if (ret == CAMERA_ERROR_NONE) {
3617 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3618 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3619 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3622 LOGD("ret : 0x%x", ret);
3628 int camera_unset_preview_cb(camera_h camera)
3630 int ret = CAMERA_ERROR_NONE;
3631 camera_cli_s *pc = (camera_cli_s *)camera;
3632 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3634 if (!pc || !pc->cb_info) {
3635 LOGE("NULL handle");
3636 return CAMERA_ERROR_INVALID_PARAMETER;
3641 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3642 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3644 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3646 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3648 LOGD("ret : 0x%x", ret);
3654 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3656 int ret = CAMERA_ERROR_NONE;
3657 camera_cli_s *pc = (camera_cli_s *)camera;
3658 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3660 if (!pc || !pc->cb_info) {
3661 LOGE("NULL handle");
3662 return CAMERA_ERROR_INVALID_PARAMETER;
3665 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3666 LOGE("NOT SUPPORTED");
3667 return CAMERA_ERROR_NOT_SUPPORTED;
3670 if (callback == NULL) {
3671 LOGE("NULL callback");
3672 return CAMERA_ERROR_INVALID_PARAMETER;
3677 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3679 if (ret == CAMERA_ERROR_NONE) {
3680 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3681 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3684 LOGD("ret : 0x%x", ret);
3690 int camera_unset_media_packet_preview_cb(camera_h camera)
3692 int ret = CAMERA_ERROR_NONE;
3693 camera_cli_s *pc = (camera_cli_s *)camera;
3694 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3696 if (!pc || !pc->cb_info) {
3697 LOGE("NULL handle");
3698 return CAMERA_ERROR_INVALID_PARAMETER;
3703 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3704 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3706 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3708 LOGD("ret : 0x%x", ret);
3714 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3716 int ret = CAMERA_ERROR_NONE;
3717 camera_cli_s *pc = (camera_cli_s *)camera;
3718 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3720 if (!pc || !pc->cb_info || !callback) {
3721 LOGE("NULL pointer %p %p", pc, callback);
3722 return CAMERA_ERROR_INVALID_PARAMETER;
3727 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3729 if (ret == CAMERA_ERROR_NONE) {
3730 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3731 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3734 LOGD("ret : 0x%x", ret);
3740 int camera_unset_state_changed_cb(camera_h camera)
3742 int ret = CAMERA_ERROR_NONE;
3743 camera_cli_s *pc = (camera_cli_s *)camera;
3744 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3746 if (!pc || !pc->cb_info) {
3747 LOGE("NULL handle");
3748 return CAMERA_ERROR_INVALID_PARAMETER;
3753 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3754 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3756 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3758 LOGD("ret : 0x%x", ret);
3764 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3766 int ret = CAMERA_ERROR_NONE;
3767 camera_cli_s *pc = (camera_cli_s *)camera;
3768 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3770 if (!pc || !pc->cb_info || !callback) {
3771 LOGE("NULL pointer %p %p", pc, callback);
3772 return CAMERA_ERROR_INVALID_PARAMETER;
3777 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3779 if (ret == CAMERA_ERROR_NONE) {
3780 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3781 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3784 LOGD("ret : 0x%x", ret);
3790 int camera_unset_interrupted_cb(camera_h camera)
3792 int ret = CAMERA_ERROR_NONE;
3793 camera_cli_s *pc = (camera_cli_s *)camera;
3794 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3796 if (!pc || !pc->cb_info) {
3797 LOGE("NULL handle");
3798 return CAMERA_ERROR_INVALID_PARAMETER;
3803 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3804 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3806 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3808 LOGD("ret : 0x%x", ret);
3814 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
3816 int ret = CAMERA_ERROR_NONE;
3817 camera_cli_s *pc = (camera_cli_s *)camera;
3818 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3820 if (!pc || !pc->cb_info || !callback) {
3821 LOGE("NULL pointer %p %p", pc, callback);
3822 return CAMERA_ERROR_INVALID_PARAMETER;
3827 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3829 if (ret == CAMERA_ERROR_NONE) {
3830 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3831 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3834 LOGD("ret : 0x%x", ret);
3840 int camera_unset_focus_changed_cb(camera_h camera)
3842 int ret = CAMERA_ERROR_NONE;
3843 camera_cli_s *pc = (camera_cli_s *)camera;
3844 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
3846 if (!pc || !pc->cb_info) {
3847 LOGE("NULL handle");
3848 return CAMERA_ERROR_INVALID_PARAMETER;
3853 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3854 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3856 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3858 LOGD("ret : 0x%x", ret);
3864 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
3866 int ret = CAMERA_ERROR_NONE;
3867 camera_cli_s *pc = (camera_cli_s *)camera;
3868 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
3870 if (!pc || !pc->cb_info || !callback) {
3871 LOGE("NULL pointer %p %p", pc, callback);
3872 return CAMERA_ERROR_INVALID_PARAMETER;
3877 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3879 if (ret == CAMERA_ERROR_NONE) {
3880 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
3881 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
3884 LOGD("ret : 0x%x", ret);
3890 int camera_unset_error_cb(camera_h camera)
3892 int ret = CAMERA_ERROR_NONE;
3893 camera_cli_s *pc = (camera_cli_s *)camera;
3894 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
3896 if (!pc || !pc->cb_info) {
3897 LOGE("NULL handle");
3898 return CAMERA_ERROR_INVALID_PARAMETER;
3903 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
3904 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
3906 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3908 LOGD("ret : 0x%x", ret);
3914 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
3916 int ret = CAMERA_ERROR_NONE;
3917 camera_cli_s *pc = (camera_cli_s *)camera;
3918 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
3920 if (!pc || !pc->cb_info || !foreach_cb) {
3921 LOGE("NULL pointer %p %p", pc, foreach_cb);
3922 return CAMERA_ERROR_INVALID_PARAMETER;
3927 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
3928 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
3930 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3932 LOGD("ret : 0x%x", ret);
3938 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
3940 int ret = CAMERA_ERROR_NONE;
3941 camera_cli_s *pc = (camera_cli_s *)camera;
3942 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
3944 if (!pc || !pc->cb_info || !foreach_cb) {
3945 LOGE("NULL pointer %p %p", pc, foreach_cb);
3946 return CAMERA_ERROR_INVALID_PARAMETER;
3951 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
3952 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
3954 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3956 LOGD("ret : 0x%x", ret);
3962 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
3964 int ret = CAMERA_ERROR_NONE;
3965 camera_cli_s *pc = (camera_cli_s *)camera;
3966 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
3968 if (!pc || !pc->cb_info || !foreach_cb) {
3969 LOGE("NULL pointer %p %p", pc, foreach_cb);
3970 return CAMERA_ERROR_INVALID_PARAMETER;
3975 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
3976 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
3978 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3980 LOGD("ret : 0x%x", ret);
3986 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
3988 int ret = CAMERA_ERROR_NONE;
3989 camera_cli_s *pc = (camera_cli_s *)camera;
3990 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
3992 if (!pc || !pc->cb_info || !foreach_cb) {
3993 LOGE("NULL pointer %p %p", pc, foreach_cb);
3994 return CAMERA_ERROR_INVALID_PARAMETER;
3999 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4000 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4002 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4004 LOGD("ret : 0x%x", ret);
4010 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4012 int ret = CAMERA_ERROR_NONE;
4013 camera_cli_s *pc = (camera_cli_s *)camera;
4014 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4018 if (!pc || !pc->cb_info || !width || !height) {
4019 LOGE("NULL pointer %p %p %p", pc, width, height);
4020 return CAMERA_ERROR_INVALID_PARAMETER;
4024 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4026 if (ret == CAMERA_ERROR_NONE) {
4027 muse_camera_msg_get(get_width, pc->cb_info->recv_msg);
4028 muse_camera_msg_get(get_height, pc->cb_info->recv_msg);
4030 *height = get_height;
4033 LOGD("ret : 0x%x", ret);
4039 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4041 int ret = CAMERA_ERROR_NONE;
4042 camera_cli_s *pc = (camera_cli_s *)camera;
4043 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4046 if (!pc || !pc->cb_info || !angle) {
4047 LOGE("NULL pointer %p %p", pc, angle);
4048 return CAMERA_ERROR_INVALID_PARAMETER;
4053 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4055 if (ret == CAMERA_ERROR_NONE) {
4056 muse_camera_msg_get(get_angle, pc->cb_info->recv_msg);
4060 LOGD("ret : 0x%x", ret);
4066 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4068 int ret = CAMERA_ERROR_NONE;
4069 camera_cli_s *pc = (camera_cli_s *)camera;
4070 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4071 camera_msg_param param;
4072 int set_mode = (int)mode;
4074 if (!pc || !pc->cb_info) {
4075 LOGE("NULL handle");
4076 return CAMERA_ERROR_INVALID_PARAMETER;
4081 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4083 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4085 LOGD("ret : 0x%x", ret);
4091 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4093 int ret = CAMERA_ERROR_NONE;
4094 camera_cli_s *pc = (camera_cli_s *)camera;
4095 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4098 if (!pc || !pc->cb_info || !mode) {
4099 LOGE("NULL pointer %p %p", pc, mode);
4100 return CAMERA_ERROR_INVALID_PARAMETER;
4105 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4107 if (ret == CAMERA_ERROR_NONE) {
4108 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
4109 *mode = (camera_attr_theater_mode_e)get_mode;
4112 LOGD("ret : 0x%x", ret);
4118 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4120 int ret = CAMERA_ERROR_NONE;
4121 camera_cli_s *pc = (camera_cli_s *)camera;
4122 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4124 if (!pc || !pc->cb_info || !foreach_cb) {
4125 LOGE("NULL pointer %p %p", pc, foreach_cb);
4126 return CAMERA_ERROR_INVALID_PARAMETER;
4131 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4132 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4134 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4136 LOGD("Finish, return :%x", ret);
4142 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4144 int ret = CAMERA_ERROR_NONE;
4145 camera_cli_s *pc = (camera_cli_s *)camera;
4146 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4147 camera_msg_param param;
4148 int set_fps = (int)fps;
4150 if (!pc || !pc->cb_info) {
4151 LOGE("NULL handle");
4152 return CAMERA_ERROR_INVALID_PARAMETER;
4157 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4159 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4161 LOGD("ret : 0x%x", ret);
4167 int camera_attr_set_image_quality(camera_h camera, int quality)
4169 int ret = CAMERA_ERROR_NONE;
4170 camera_cli_s *pc = (camera_cli_s *)camera;
4171 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4172 camera_msg_param param;
4174 if (!pc || !pc->cb_info) {
4175 LOGE("NULL handle");
4176 return CAMERA_ERROR_INVALID_PARAMETER;
4181 CAMERA_MSG_PARAM_SET(param, INT, quality);
4183 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4185 LOGD("ret : 0x%x", ret);
4191 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4193 int ret = CAMERA_ERROR_NONE;
4194 camera_cli_s *pc = (camera_cli_s *)camera;
4195 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4198 if (!pc || !pc->cb_info || !fps) {
4199 LOGE("NULL pointer %p %p", pc, fps);
4200 return CAMERA_ERROR_INVALID_PARAMETER;
4205 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4207 if (ret == CAMERA_ERROR_NONE) {
4208 muse_camera_msg_get(get_fps, pc->cb_info->recv_msg);
4209 *fps = (camera_attr_fps_e)get_fps;
4212 LOGD("ret : 0x%x", ret);
4218 int camera_attr_get_image_quality(camera_h camera, int *quality)
4220 int ret = CAMERA_ERROR_NONE;
4221 camera_cli_s *pc = (camera_cli_s *)camera;
4222 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4223 int get_quality = 0;
4225 if (!pc || !pc->cb_info || !quality) {
4226 LOGE("NULL pointer %p %p", pc, quality);
4227 return CAMERA_ERROR_INVALID_PARAMETER;
4232 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4234 if (ret == CAMERA_ERROR_NONE) {
4235 muse_camera_msg_get(get_quality, pc->cb_info->recv_msg);
4236 *quality = get_quality;
4239 LOGD("ret : 0x%x", ret);
4245 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4247 int ret = CAMERA_ERROR_NONE;
4248 camera_cli_s *pc = (camera_cli_s *)camera;
4249 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4250 int get_bitrate = 0;
4252 if (!pc || !pc->cb_info || !bitrate) {
4253 LOGE("NULL pointer %p %p", pc, bitrate);
4254 return CAMERA_ERROR_INVALID_PARAMETER;
4259 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4261 if (ret == CAMERA_ERROR_NONE) {
4262 muse_camera_msg_get(get_bitrate, pc->cb_info->recv_msg);
4263 *bitrate = get_bitrate;
4266 LOGD("ret : 0x%x", ret);
4272 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4274 int ret = CAMERA_ERROR_NONE;
4275 camera_cli_s *pc = (camera_cli_s *)camera;
4276 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4277 camera_msg_param param;
4278 int set_bitrate = bitrate;
4280 if (!pc || !pc->cb_info) {
4281 LOGE("NULL handle");
4282 return CAMERA_ERROR_INVALID_PARAMETER;
4287 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4289 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4291 LOGD("ret : 0x%x", ret);
4297 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4299 int ret = CAMERA_ERROR_NONE;
4300 camera_cli_s *pc = (camera_cli_s *)camera;
4301 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4302 int get_gop_interval = 0;
4304 if (!pc || !pc->cb_info || !interval) {
4305 LOGE("NULL pointer %p %p", pc, interval);
4306 return CAMERA_ERROR_INVALID_PARAMETER;
4311 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4313 if (ret == CAMERA_ERROR_NONE) {
4314 muse_camera_msg_get(get_gop_interval, pc->cb_info->recv_msg);
4315 *interval = get_gop_interval;
4318 LOGD("ret : 0x%x", ret);
4324 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4326 int ret = CAMERA_ERROR_NONE;
4327 camera_cli_s *pc = (camera_cli_s *)camera;
4328 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4329 camera_msg_param param;
4330 int set_gop_interval = interval;
4332 if (!pc || !pc->cb_info) {
4333 LOGE("NULL handle");
4334 return CAMERA_ERROR_INVALID_PARAMETER;
4339 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4341 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4343 LOGD("ret : 0x%x", ret);
4349 int camera_attr_set_zoom(camera_h camera, int zoom)
4351 int ret = CAMERA_ERROR_NONE;
4352 camera_cli_s *pc = (camera_cli_s *)camera;
4353 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4354 camera_msg_param param;
4356 if (!pc || !pc->cb_info) {
4357 LOGE("NULL handle");
4358 return CAMERA_ERROR_INVALID_PARAMETER;
4361 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4363 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4365 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4367 LOGD("ret : 0x%x", ret);
4373 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4375 int ret = CAMERA_ERROR_NONE;
4376 camera_cli_s *pc = (camera_cli_s *)camera;
4377 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4378 camera_msg_param param;
4379 int set_mode = (int)mode;
4381 if (!pc || !pc->cb_info) {
4382 LOGE("NULL handle");
4383 return CAMERA_ERROR_INVALID_PARAMETER;
4386 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4388 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4390 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4396 int camera_attr_set_af_area(camera_h camera, int x, int y)
4398 int ret = CAMERA_ERROR_NONE;
4399 camera_cli_s *pc = (camera_cli_s *)camera;
4400 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4401 camera_msg_param param;
4404 if (!pc || !pc->cb_info) {
4405 LOGE("NULL handle");
4406 return CAMERA_ERROR_INVALID_PARAMETER;
4409 LOGD("Enter - %d,%d", x, y);
4411 value = (x << 16) | y;
4412 CAMERA_MSG_PARAM_SET(param, INT, value);
4414 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4416 LOGD("ret : 0x%x", ret);
4422 int camera_attr_clear_af_area(camera_h camera)
4424 int ret = CAMERA_ERROR_NONE;
4425 camera_cli_s *pc = (camera_cli_s *)camera;
4426 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4428 if (!pc || !pc->cb_info) {
4429 LOGE("NULL handle");
4430 return CAMERA_ERROR_INVALID_PARAMETER;
4435 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4437 LOGD("ret : 0x%x", ret);
4443 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4445 int ret = CAMERA_ERROR_NONE;
4446 camera_cli_s *pc = (camera_cli_s *)camera;
4447 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4448 camera_msg_param param;
4449 int set_mode = (int)mode;
4451 if (!pc || !pc->cb_info) {
4452 LOGE("NULL handle");
4453 return CAMERA_ERROR_INVALID_PARAMETER;
4458 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4460 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4462 LOGD("ret : 0x%x", ret);
4468 int camera_attr_set_exposure(camera_h camera, int value)
4470 int ret = CAMERA_ERROR_NONE;
4471 camera_cli_s *pc = (camera_cli_s *)camera;
4472 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4473 camera_msg_param param;
4475 if (!pc || !pc->cb_info) {
4476 LOGE("NULL handle");
4477 return CAMERA_ERROR_INVALID_PARAMETER;
4482 CAMERA_MSG_PARAM_SET(param, INT, value);
4484 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4486 LOGD("ret : 0x%x", ret);
4492 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4494 int ret = CAMERA_ERROR_NONE;
4495 camera_cli_s *pc = (camera_cli_s *)camera;
4496 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4497 camera_msg_param param;
4498 int set_iso = (int)iso;
4500 if (!pc || !pc->cb_info) {
4501 LOGE("NULL handle");
4502 return CAMERA_ERROR_INVALID_PARAMETER;
4507 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4509 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4511 LOGD("ret : 0x%x", ret);
4517 int camera_attr_set_brightness(camera_h camera, int level)
4519 int ret = CAMERA_ERROR_NONE;
4520 camera_cli_s *pc = (camera_cli_s *)camera;
4521 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4522 camera_msg_param param;
4524 if (!pc || !pc->cb_info) {
4525 LOGE("NULL handle");
4526 return CAMERA_ERROR_INVALID_PARAMETER;
4531 CAMERA_MSG_PARAM_SET(param, INT, level);
4533 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4535 LOGD("ret : 0x%x", ret);
4541 int camera_attr_set_contrast(camera_h camera, int level)
4543 int ret = CAMERA_ERROR_NONE;
4544 camera_cli_s *pc = (camera_cli_s *)camera;
4545 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4546 camera_msg_param param;
4548 if (!pc || !pc->cb_info) {
4549 LOGE("NULL handle");
4550 return CAMERA_ERROR_INVALID_PARAMETER;
4555 CAMERA_MSG_PARAM_SET(param, INT, level);
4557 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4559 LOGD("ret : 0x%x", ret);
4565 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4567 int ret = CAMERA_ERROR_NONE;
4568 camera_cli_s *pc = (camera_cli_s *)camera;
4569 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4570 camera_msg_param param;
4571 int set_whitebalance = (int)wb;
4573 if (!pc || !pc->cb_info) {
4574 LOGE("NULL handle");
4575 return CAMERA_ERROR_INVALID_PARAMETER;
4580 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4582 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4584 LOGD("ret : 0x%x", ret);
4590 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4592 int ret = CAMERA_ERROR_NONE;
4593 camera_cli_s *pc = (camera_cli_s *)camera;
4594 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4595 camera_msg_param param;
4596 int set_effect = (int)effect;
4598 if (!pc || !pc->cb_info) {
4599 LOGE("NULL handle");
4600 return CAMERA_ERROR_INVALID_PARAMETER;
4605 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4607 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4609 LOGD("ret : 0x%x", ret);
4615 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4617 int ret = CAMERA_ERROR_NONE;
4618 camera_cli_s *pc = (camera_cli_s *)camera;
4619 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4620 camera_msg_param param;
4621 int set_mode = (int)mode;
4623 if (!pc || !pc->cb_info) {
4624 LOGE("NULL handle");
4625 return CAMERA_ERROR_INVALID_PARAMETER;
4630 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4632 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4634 LOGD("ret : 0x%x", ret);
4640 int camera_attr_enable_tag(camera_h camera, bool enable)
4642 int ret = CAMERA_ERROR_NONE;
4643 camera_cli_s *pc = (camera_cli_s *)camera;
4644 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4645 camera_msg_param param;
4646 int set_enable = (int)enable;
4648 if (!pc || !pc->cb_info) {
4649 LOGE("NULL handle");
4650 return CAMERA_ERROR_INVALID_PARAMETER;
4655 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4657 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4659 LOGD("ret : 0x%x", ret);
4665 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4667 int ret = CAMERA_ERROR_NONE;
4668 camera_cli_s *pc = (camera_cli_s *)camera;
4669 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4670 camera_msg_param param;
4672 if (!pc || !pc->cb_info || !description) {
4673 LOGE("NULL pointer %p %p", pc, description);
4674 return CAMERA_ERROR_INVALID_PARAMETER;
4679 CAMERA_MSG_PARAM_SET(param, STRING, description);
4681 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4683 LOGD("ret : 0x%x", ret);
4689 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4691 int ret = CAMERA_ERROR_NONE;
4692 camera_cli_s *pc = (camera_cli_s *)camera;
4693 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4694 camera_msg_param param;
4695 int set_orientation = (int)orientation;
4697 if (!pc || !pc->cb_info) {
4698 LOGE("NULL handle");
4699 return CAMERA_ERROR_INVALID_PARAMETER;
4704 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4706 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4708 LOGD("ret : 0x%x", ret);
4714 int camera_attr_set_tag_software(camera_h camera, const char *software)
4716 int ret = CAMERA_ERROR_NONE;
4717 camera_cli_s *pc = (camera_cli_s *)camera;
4718 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4719 camera_msg_param param;
4721 if (!pc || !pc->cb_info || !software) {
4722 LOGE("NULL pointer %p %p", pc, software);
4723 return CAMERA_ERROR_INVALID_PARAMETER;
4726 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4728 CAMERA_MSG_PARAM_SET(param, STRING, software);
4730 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4732 LOGD("ret : 0x%x", ret);
4738 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4740 int ret = CAMERA_ERROR_NONE;
4741 camera_cli_s *pc = (camera_cli_s *)camera;
4742 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4743 double set_geotag[3] = {latitude, longitude, altitude};
4748 if (!pc || !pc->cb_info) {
4749 LOGE("NULL handle");
4750 return CAMERA_ERROR_INVALID_PARAMETER;
4755 length = sizeof(set_geotag) / sizeof(int) + \
4756 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4758 msg = muse_core_msg_json_factory_new(api,
4759 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4762 LOGE("msg creation failed: api %d", api);
4763 return CAMERA_ERROR_OUT_OF_MEMORY;
4766 if (pc->cb_info->is_server_connected)
4767 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
4770 LOGE("message send failed");
4771 ret = CAMERA_ERROR_INVALID_OPERATION;
4773 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
4776 muse_core_msg_json_factory_free(msg);
4778 LOGD("ret : 0x%x", ret);
4784 int camera_attr_remove_geotag(camera_h camera)
4786 int ret = CAMERA_ERROR_NONE;
4787 camera_cli_s *pc = (camera_cli_s *)camera;
4788 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4790 if (!pc || !pc->cb_info) {
4791 LOGE("NULL handle");
4792 return CAMERA_ERROR_INVALID_PARAMETER;
4797 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4799 LOGD("ret : 0x%x", ret);
4805 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4807 int ret = CAMERA_ERROR_NONE;
4808 camera_cli_s *pc = (camera_cli_s *)camera;
4809 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
4810 camera_msg_param param;
4811 int set_mode = (int)mode;
4813 if (!pc || !pc->cb_info) {
4814 LOGE("NULL handle");
4815 return CAMERA_ERROR_INVALID_PARAMETER;
4820 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4822 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4824 LOGD("ret : 0x%x", ret);
4830 int camera_attr_get_zoom(camera_h camera, int *zoom)
4832 int ret = CAMERA_ERROR_NONE;
4833 camera_cli_s *pc = (camera_cli_s *)camera;
4834 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4837 if (!pc || !pc->cb_info || !zoom) {
4838 LOGE("NULL pointer %p %p", pc, zoom);
4839 return CAMERA_ERROR_INVALID_PARAMETER;
4844 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4846 if (ret == CAMERA_ERROR_NONE) {
4847 muse_camera_msg_get(get_zoom, pc->cb_info->recv_msg);
4851 LOGD("ret : 0x%x", ret);
4857 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
4859 int ret = CAMERA_ERROR_NONE;
4860 camera_cli_s *pc = (camera_cli_s *)camera;
4861 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
4865 if (!pc || !pc->cb_info || !min || !max) {
4866 LOGE("NULL pointer %p %p %p", pc, min, max);
4867 return CAMERA_ERROR_INVALID_PARAMETER;
4872 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4874 if (ret == CAMERA_ERROR_NONE) {
4875 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
4876 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
4881 LOGD("ret : 0x%x", ret);
4887 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_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_GET_AF_MODE;
4894 if (!pc || !pc->cb_info || !mode) {
4895 LOGE("NULL pointer %p %p", pc, mode);
4896 return CAMERA_ERROR_INVALID_PARAMETER;
4901 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4903 if (ret == CAMERA_ERROR_NONE) {
4904 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
4905 *mode = (camera_attr_af_mode_e)get_mode;
4908 LOGD("ret : 0x%x", ret);
4914 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
4916 int ret = CAMERA_ERROR_NONE;
4917 camera_cli_s *pc = (camera_cli_s *)camera;
4918 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
4921 if (!pc || !pc->cb_info || !mode) {
4922 LOGE("NULL pointer %p %p", pc, mode);
4923 return CAMERA_ERROR_INVALID_PARAMETER;
4928 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4930 if (ret == CAMERA_ERROR_NONE) {
4931 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
4932 *mode = (camera_attr_exposure_mode_e)get_mode;
4935 LOGD("ret : 0x%x", ret);
4941 int camera_attr_get_exposure(camera_h camera, int *value)
4943 int ret = CAMERA_ERROR_NONE;
4944 camera_cli_s *pc = (camera_cli_s *)camera;
4945 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
4948 if (!pc || !pc->cb_info || !value) {
4949 LOGE("NULL pointer %p %p", pc, value);
4950 return CAMERA_ERROR_INVALID_PARAMETER;
4955 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4957 if (ret == CAMERA_ERROR_NONE) {
4958 muse_camera_msg_get(get_value, pc->cb_info->recv_msg);
4962 LOGD("ret : 0x%x", ret);
4968 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
4970 int ret = CAMERA_ERROR_NONE;
4971 camera_cli_s *pc = (camera_cli_s *)camera;
4972 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
4976 if (!pc || !pc->cb_info || !min || !max) {
4977 LOGE("NULL pointer %p %p %p", pc, min, max);
4978 return CAMERA_ERROR_INVALID_PARAMETER;
4983 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4985 if (ret == CAMERA_ERROR_NONE) {
4986 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
4987 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
4992 LOGD("ret : 0x%x", ret);
4998 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5000 int ret = CAMERA_ERROR_NONE;
5001 camera_cli_s *pc = (camera_cli_s *)camera;
5002 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5005 if (!pc || !pc->cb_info || !iso) {
5006 LOGE("NULL pointer %p %p", pc, iso);
5007 return CAMERA_ERROR_INVALID_PARAMETER;
5012 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5014 if (ret == CAMERA_ERROR_NONE) {
5015 muse_camera_msg_get(get_iso, pc->cb_info->recv_msg);
5016 *iso = (camera_attr_iso_e)get_iso;
5019 LOGD("ret : 0x%x", ret);
5025 int camera_attr_get_brightness(camera_h camera, int *level)
5027 int ret = CAMERA_ERROR_NONE;
5028 camera_cli_s *pc = (camera_cli_s *)camera;
5029 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5032 if (!pc || !pc->cb_info || !level) {
5033 LOGE("NULL pointer %p %p", pc, level);
5034 return CAMERA_ERROR_INVALID_PARAMETER;
5039 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5041 if (ret == CAMERA_ERROR_NONE) {
5042 muse_camera_msg_get(get_level, pc->cb_info->recv_msg);
5046 LOGD("ret : 0x%x", ret);
5052 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5054 int ret = CAMERA_ERROR_NONE;
5055 camera_cli_s *pc = (camera_cli_s *)camera;
5056 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5060 if (!pc || !pc->cb_info || !min || !max) {
5061 LOGE("NULL pointer %p %p %p", pc, min, max);
5062 return CAMERA_ERROR_INVALID_PARAMETER;
5067 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5069 if (ret == CAMERA_ERROR_NONE) {
5070 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
5071 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
5076 LOGD("ret : 0x%x", ret);
5082 int camera_attr_get_contrast(camera_h camera, int *level)
5084 int ret = CAMERA_ERROR_NONE;
5085 camera_cli_s *pc = (camera_cli_s *)camera;
5086 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5089 if (!pc || !pc->cb_info || !level) {
5090 LOGE("NULL pointer %p %p", pc, level);
5091 return CAMERA_ERROR_INVALID_PARAMETER;
5096 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5098 if (ret == CAMERA_ERROR_NONE) {
5099 muse_camera_msg_get(get_level, pc->cb_info->recv_msg);
5103 LOGD("ret : 0x%x", ret);
5109 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5111 int ret = CAMERA_ERROR_NONE;
5112 camera_cli_s *pc = (camera_cli_s *)camera;
5113 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5117 if (!pc || !pc->cb_info || !min || !max) {
5118 LOGE("NULL pointer %p %p %p", pc, min, max);
5119 return CAMERA_ERROR_INVALID_PARAMETER;
5124 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5126 if (ret == CAMERA_ERROR_NONE) {
5127 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
5128 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
5133 LOGD("ret : 0x%x", ret);
5139 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5141 int ret = CAMERA_ERROR_NONE;
5142 camera_cli_s *pc = (camera_cli_s *)camera;
5143 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5146 if (!pc || !pc->cb_info || !wb) {
5147 LOGE("NULL pointer %p %p", pc, wb);
5148 return CAMERA_ERROR_INVALID_PARAMETER;
5153 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5155 if (ret == CAMERA_ERROR_NONE) {
5156 muse_camera_msg_get(get_wb, pc->cb_info->recv_msg);
5157 *wb = (camera_attr_whitebalance_e)get_wb;
5160 LOGD("ret : 0x%x", ret);
5166 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5168 int ret = CAMERA_ERROR_NONE;
5169 camera_cli_s *pc = (camera_cli_s *)camera;
5170 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5173 if (!pc || !pc->cb_info || !effect) {
5174 LOGE("NULL pointer %p %p", pc, effect);
5175 return CAMERA_ERROR_INVALID_PARAMETER;
5180 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5182 if (ret == CAMERA_ERROR_NONE) {
5183 muse_camera_msg_get(get_effect, pc->cb_info->recv_msg);
5184 *effect = (camera_attr_effect_mode_e)get_effect;
5187 LOGD("ret : 0x%x", ret);
5193 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5195 int ret = CAMERA_ERROR_NONE;
5196 camera_cli_s *pc = (camera_cli_s *)camera;
5197 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5200 if (!pc || !pc->cb_info || !mode) {
5201 LOGE("NULL pointer %p %p", pc, mode);
5202 return CAMERA_ERROR_INVALID_PARAMETER;
5207 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5209 if (ret == CAMERA_ERROR_NONE) {
5210 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
5211 *mode = (camera_attr_scene_mode_e)get_mode;
5214 LOGD("ret : 0x%x", ret);
5220 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5222 int ret = CAMERA_ERROR_NONE;
5223 camera_cli_s *pc = (camera_cli_s *)camera;
5224 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5225 int get_enabled = 0;
5227 if (!pc || !pc->cb_info || !enable) {
5228 LOGE("NULL pointer %p %p", pc, enable);
5229 return CAMERA_ERROR_INVALID_PARAMETER;
5234 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5236 if (ret == CAMERA_ERROR_NONE) {
5237 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
5238 *enable = (bool)get_enabled;
5241 LOGD("ret : 0x%x", ret);
5247 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5249 int ret = CAMERA_ERROR_NONE;
5250 camera_cli_s *pc = (camera_cli_s *)camera;
5251 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5252 char get_description[MUSE_CAMERA_MSG_MAX_LENGTH] = {0, };
5254 if (!pc || !pc->cb_info || !description) {
5255 LOGE("NULL pointer %p %p", pc, description);
5256 return CAMERA_ERROR_INVALID_PARAMETER;
5261 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5263 if (ret == CAMERA_ERROR_NONE) {
5264 muse_camera_msg_get_string(get_description, pc->cb_info->recv_msg);
5265 *description = strdup(get_description);
5268 LOGD("ret : 0x%x", ret);
5274 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5276 int ret = CAMERA_ERROR_NONE;
5277 camera_cli_s *pc = (camera_cli_s *)camera;
5278 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5279 int get_orientation = 0;
5281 if (!pc || !pc->cb_info || !orientation) {
5282 LOGE("NULL pointer %p %p", pc, orientation);
5283 return CAMERA_ERROR_INVALID_PARAMETER;
5288 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5290 if (ret == CAMERA_ERROR_NONE) {
5291 muse_camera_msg_get(get_orientation, pc->cb_info->recv_msg);
5292 *orientation = (camera_attr_tag_orientation_e)get_orientation;
5295 LOGD("ret : 0x%x", ret);
5301 int camera_attr_get_tag_software(camera_h camera, char **software)
5303 int ret = CAMERA_ERROR_NONE;
5304 camera_cli_s *pc = (camera_cli_s *)camera;
5305 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5306 char get_software[MUSE_CAMERA_MSG_MAX_LENGTH] = {0, };
5308 if (!pc || !pc->cb_info || !software) {
5309 LOGE("NULL pointer %p %p", pc, software);
5310 return CAMERA_ERROR_INVALID_PARAMETER;
5315 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5317 if (ret == CAMERA_ERROR_NONE) {
5318 muse_camera_msg_get_string(get_software, pc->cb_info->recv_msg);
5319 *software = strdup(get_software);
5322 LOGD("ret : 0x%x", ret);
5328 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5330 int ret = CAMERA_ERROR_NONE;
5331 camera_cli_s *pc = (camera_cli_s *)camera;
5332 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5333 double get_geotag[3] = {0.0, };
5335 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5336 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
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 muse_camera_msg_get_array(get_geotag, pc->cb_info->recv_msg);
5346 *latitude = get_geotag[0];
5347 *longitude = get_geotag[1];
5348 *altitude = get_geotag[2];
5351 LOGD("ret : 0x%x", ret);
5357 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5359 int ret = CAMERA_ERROR_NONE;
5360 camera_cli_s *pc = (camera_cli_s *)camera;
5361 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5364 if (!pc || !pc->cb_info || !mode) {
5365 LOGE("NULL pointer %p %p", pc, mode);
5366 return CAMERA_ERROR_INVALID_PARAMETER;
5371 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5373 if (ret == CAMERA_ERROR_NONE) {
5374 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
5375 *mode = (camera_attr_flash_mode_e)get_mode;
5378 LOGD("ret : 0x%x", ret);
5384 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5386 int ret = CAMERA_ERROR_NONE;
5387 int get_flash_state = 0;
5390 LOGE("NULL pointer");
5391 return CAMERA_ERROR_INVALID_PARAMETER;
5394 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5395 (int)device, "get_flash_state", &get_flash_state);
5397 if (ret == CAMERA_ERROR_NONE) {
5398 *state = (camera_flash_state_e)get_flash_state;
5399 LOGD("flash state %d", *state);
5401 LOGE("failed 0x%x", ret);
5408 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5410 int ret = CAMERA_ERROR_NONE;
5411 camera_cli_s *pc = (camera_cli_s *)camera;
5412 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5414 if (!pc || !pc->cb_info || !foreach_cb) {
5415 LOGE("NULL pointer %p %p", pc, foreach_cb);
5416 return CAMERA_ERROR_INVALID_PARAMETER;
5421 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5422 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5424 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5426 LOGD("ret : 0x%x", ret);
5432 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5434 int ret = CAMERA_ERROR_NONE;
5435 camera_cli_s *pc = (camera_cli_s *)camera;
5436 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5438 if (!pc || !pc->cb_info || !foreach_cb) {
5439 LOGE("NULL pointer %p %p", pc, foreach_cb);
5440 return CAMERA_ERROR_INVALID_PARAMETER;
5445 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5446 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5448 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5450 LOGD("ret : 0x%x", ret);
5456 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5458 int ret = CAMERA_ERROR_NONE;
5459 camera_cli_s *pc = (camera_cli_s *)camera;
5460 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5462 if (!pc || !pc->cb_info || !foreach_cb) {
5463 LOGE("NULL pointer %p %p", pc, foreach_cb);
5464 return CAMERA_ERROR_INVALID_PARAMETER;
5469 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5470 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5472 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5474 LOGD("ret : 0x%x", ret);
5480 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5482 int ret = CAMERA_ERROR_NONE;
5483 camera_cli_s *pc = (camera_cli_s *)camera;
5484 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5486 if (!pc || !pc->cb_info || !foreach_cb) {
5487 LOGE("NULL pointer %p %p", pc, foreach_cb);
5488 return CAMERA_ERROR_INVALID_PARAMETER;
5493 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5494 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5496 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5498 LOGD("ret : 0x%x", ret);
5504 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5506 int ret = CAMERA_ERROR_NONE;
5507 camera_cli_s *pc = (camera_cli_s *)camera;
5508 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5510 if (!pc || !pc->cb_info || !foreach_cb) {
5511 LOGE("NULL pointer %p %p", pc, foreach_cb);
5512 return CAMERA_ERROR_INVALID_PARAMETER;
5517 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5518 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5520 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5522 LOGD("ret : 0x%x", ret);
5528 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5530 int ret = CAMERA_ERROR_NONE;
5531 camera_cli_s *pc = (camera_cli_s *)camera;
5532 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5534 if (!pc || !pc->cb_info || !foreach_cb) {
5535 LOGE("NULL pointer %p %p", pc, foreach_cb);
5536 return CAMERA_ERROR_INVALID_PARAMETER;
5541 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5542 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5544 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5546 LOGD("ret : 0x%x", ret);
5552 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5554 int ret = CAMERA_ERROR_NONE;
5555 camera_cli_s *pc = (camera_cli_s *)camera;
5556 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5558 if (!pc || !pc->cb_info || !foreach_cb) {
5559 LOGE("NULL pointer %p %p", pc, foreach_cb);
5560 return CAMERA_ERROR_INVALID_PARAMETER;
5565 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5566 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5568 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5570 LOGD("ret : 0x%x", ret);
5576 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5578 int ret = CAMERA_ERROR_NONE;
5579 camera_cli_s *pc = (camera_cli_s *)camera;
5580 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5582 if (!pc || !pc->cb_info || !foreach_cb) {
5583 LOGE("NULL pointer %p %p", pc, foreach_cb);
5584 return CAMERA_ERROR_INVALID_PARAMETER;
5589 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5590 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5592 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5594 LOGD("Enter, handle :%x", pc->remote_handle);
5600 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)
5602 int ret = CAMERA_ERROR_NONE;
5603 camera_cli_s *pc = (camera_cli_s *)camera;
5604 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5605 camera_msg_param param;
5608 if (!pc || !pc->cb_info || !foreach_cb) {
5609 LOGE("NULL pointer %p %p", pc, foreach_cb);
5610 return CAMERA_ERROR_INVALID_PARAMETER;
5615 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5616 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5618 value = (width << 16) | height;
5619 CAMERA_MSG_PARAM_SET(param, INT, value);
5621 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5623 LOGD("ret : 0x%x", ret);
5629 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5631 int ret = CAMERA_ERROR_NONE;
5632 camera_cli_s *pc = (camera_cli_s *)camera;
5633 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5635 if (!pc || !pc->cb_info || !foreach_cb) {
5636 LOGE("NULL pointer %p %p", pc, foreach_cb);
5637 return CAMERA_ERROR_INVALID_PARAMETER;
5642 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5643 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5645 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5647 LOGD("ret : 0x%x", ret);
5653 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5655 int ret = CAMERA_ERROR_NONE;
5656 camera_cli_s *pc = (camera_cli_s *)camera;
5657 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5659 if (!pc || !pc->cb_info || !foreach_cb) {
5660 LOGE("NULL pointer %p %p", pc, foreach_cb);
5661 return CAMERA_ERROR_INVALID_PARAMETER;
5666 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5667 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5669 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5671 LOGD("ret : 0x%x", ret);
5677 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5679 int ret = CAMERA_ERROR_NONE;
5680 camera_cli_s *pc = (camera_cli_s *)camera;
5681 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5682 camera_msg_param param;
5683 int set_rotation = (int)rotation;
5685 if (!pc || !pc->cb_info) {
5686 LOGE("NULL handle");
5687 return CAMERA_ERROR_INVALID_PARAMETER;
5692 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5694 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5696 LOGD("ret : 0x%x", ret);
5702 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5704 int ret = CAMERA_ERROR_NONE;
5705 camera_cli_s *pc = (camera_cli_s *)camera;
5706 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5707 int get_rotation = 0;
5709 if (!pc || !pc->cb_info || !rotation) {
5710 LOGE("NULL pointer %p %p", pc, rotation);
5711 return CAMERA_ERROR_INVALID_PARAMETER;
5716 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5718 if (ret == CAMERA_ERROR_NONE) {
5719 muse_camera_msg_get(get_rotation, pc->cb_info->recv_msg);
5720 *rotation = (camera_rotation_e)get_rotation;
5723 LOGD("ret : 0x%x", ret);
5729 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5731 int ret = CAMERA_ERROR_NONE;
5732 camera_cli_s *pc = (camera_cli_s *)camera;
5733 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5734 camera_msg_param param;
5735 int set_flip = (int)flip;
5737 if (!pc || !pc->cb_info) {
5738 LOGE("NULL handle");
5739 return CAMERA_ERROR_INVALID_PARAMETER;
5744 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5746 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5748 LOGD("ret : 0x%x", ret);
5754 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5756 int ret = CAMERA_ERROR_NONE;
5757 camera_cli_s *pc = (camera_cli_s *)camera;
5758 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5761 if (!pc || !pc->cb_info || !flip) {
5762 LOGE("NULL pointer %p %p", pc, flip);
5763 return CAMERA_ERROR_INVALID_PARAMETER;
5768 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5770 if (ret == CAMERA_ERROR_NONE) {
5771 muse_camera_msg_get(get_flip, pc->cb_info->recv_msg);
5772 *flip = (camera_flip_e)get_flip;
5775 LOGD("ret : 0x%x", ret);
5780 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5782 int ret = CAMERA_ERROR_NONE;
5783 camera_cli_s *pc = (camera_cli_s *)camera;
5784 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5785 camera_msg_param param;
5786 int set_mode = (int)mode;
5788 if (!pc || !pc->cb_info) {
5789 LOGE("NULL handle");
5790 return CAMERA_ERROR_INVALID_PARAMETER;
5795 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5797 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5799 LOGD("ret : 0x%x", ret);
5805 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5807 int ret = CAMERA_ERROR_NONE;
5808 camera_cli_s *pc = (camera_cli_s *)camera;
5809 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5812 if (!pc || !pc->cb_info || !mode) {
5813 LOGE("NULL pointer %p %p", pc, mode);
5814 return CAMERA_ERROR_INVALID_PARAMETER;
5819 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5821 if (ret == CAMERA_ERROR_NONE) {
5822 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
5823 *mode = (camera_attr_hdr_mode_e)get_mode;
5826 LOGD("ret : 0x%x", ret);
5832 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5834 int ret = CAMERA_ERROR_NONE;
5835 camera_cli_s *pc = (camera_cli_s *)camera;
5836 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
5838 if (!pc || !pc->cb_info) {
5839 LOGE("NULL handle");
5840 return CAMERA_ERROR_INVALID_PARAMETER;
5845 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5848 LOGE("error is occurred 0x%x", ret);
5852 LOGD("ret : %d", ret);
5858 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5860 int ret = CAMERA_ERROR_NONE;
5861 camera_cli_s *pc = (camera_cli_s *)camera;
5862 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5864 if (!pc || !pc->cb_info) {
5865 LOGE("NULL handle");
5866 return CAMERA_ERROR_INVALID_PARAMETER;
5871 if (!camera_attr_is_supported_hdr_capture(camera)) {
5872 LOGE("HDR not supported");
5873 return CAMERA_ERROR_NOT_SUPPORTED;
5877 LOGE("NULL callback");
5878 return CAMERA_ERROR_INVALID_PARAMETER;
5881 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5882 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5884 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5886 LOGD("ret : 0x%x", ret);
5892 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5894 int ret = CAMERA_ERROR_NONE;
5895 camera_cli_s *pc = (camera_cli_s *)camera;
5896 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5898 if (!pc || !pc->cb_info) {
5899 LOGE("NULL handle");
5900 return CAMERA_ERROR_INVALID_PARAMETER;
5905 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5906 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5908 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5910 LOGD("ret : 0x%x", ret);
5916 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
5918 int ret = CAMERA_ERROR_NONE;
5919 camera_cli_s *pc = (camera_cli_s *)camera;
5920 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
5921 camera_msg_param param;
5922 int set_enable = (int)enable;
5924 if (!pc || !pc->cb_info) {
5925 LOGE("NULL handle");
5926 return CAMERA_ERROR_INVALID_PARAMETER;
5931 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
5933 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5935 LOGD("ret : 0x%x", ret);
5941 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
5943 int ret = CAMERA_ERROR_NONE;
5944 camera_cli_s *pc = (camera_cli_s *)camera;
5945 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
5946 int get_enabled = 0;
5948 if (!pc || !pc->cb_info || !enabled) {
5949 LOGE("NULL pointer %p %p", pc, enabled);
5950 return CAMERA_ERROR_INVALID_PARAMETER;
5955 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5957 if (ret == CAMERA_ERROR_NONE) {
5958 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
5959 *enabled = (bool)get_enabled;
5962 LOGD("ret : 0x%x", ret);
5968 bool camera_attr_is_supported_anti_shake(camera_h camera)
5970 int ret = CAMERA_ERROR_NONE;
5971 camera_cli_s *pc = (camera_cli_s *)camera;
5972 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
5974 if (!pc || !pc->cb_info) {
5975 LOGE("NULL handle");
5976 return CAMERA_ERROR_INVALID_PARAMETER;
5981 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5984 LOGE("error is occurred 0x%x", ret);
5988 LOGD("ret : %d", ret);
5994 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
5996 int ret = CAMERA_ERROR_NONE;
5997 camera_cli_s *pc = (camera_cli_s *)camera;
5998 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
5999 camera_msg_param param;
6000 int set_enable = (int)enable;
6002 if (!pc || !pc->cb_info) {
6003 LOGE("NULL handle");
6004 return CAMERA_ERROR_INVALID_PARAMETER;
6009 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6011 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6013 LOGD("ret : 0x%x", ret);
6019 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6021 int ret = CAMERA_ERROR_NONE;
6022 camera_cli_s *pc = (camera_cli_s *)camera;
6023 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6024 int get_enabled = 0;
6026 if (!pc || !pc->cb_info || !enabled) {
6027 LOGE("NULL pointer %p %p", pc, enabled);
6028 return CAMERA_ERROR_INVALID_PARAMETER;
6033 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6035 if (ret == CAMERA_ERROR_NONE) {
6036 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
6037 *enabled = (bool)get_enabled;
6040 LOGD("ret : 0x%x", ret);
6046 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6048 int ret = CAMERA_ERROR_NONE;
6049 camera_cli_s *pc = (camera_cli_s *)camera;
6050 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6052 if (!pc || !pc->cb_info) {
6053 LOGE("NULL handle");
6054 return CAMERA_ERROR_INVALID_PARAMETER;
6059 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6062 LOGE("error is occurred 0x%x", ret);
6066 LOGD("ret : %d", ret);
6072 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6074 int ret = CAMERA_ERROR_NONE;
6075 camera_cli_s *pc = (camera_cli_s *)camera;
6076 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6077 camera_msg_param param;
6078 int set_enable = (int)enable;
6080 if (!pc || !pc->cb_info) {
6081 LOGE("NULL handle");
6082 return CAMERA_ERROR_INVALID_PARAMETER;
6087 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6089 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6091 LOGD("ret : 0x%x", ret);
6097 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6099 int ret = CAMERA_ERROR_NONE;
6100 camera_cli_s *pc = (camera_cli_s *)camera;
6101 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6102 int get_enabled = 0;
6104 if (!pc || !pc->cb_info || !enabled) {
6105 LOGE("NULL pointer %p %p", pc, enabled);
6106 return CAMERA_ERROR_INVALID_PARAMETER;
6111 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6113 if (ret == CAMERA_ERROR_NONE) {
6114 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
6115 *enabled = (bool)get_enabled;
6118 LOGD("ret : 0x%x", ret);
6124 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6126 int ret = CAMERA_ERROR_NONE;
6127 camera_cli_s *pc = (camera_cli_s *)camera;
6128 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6130 if (!pc || !pc->cb_info) {
6131 LOGE("NULL handle");
6132 return CAMERA_ERROR_INVALID_PARAMETER;
6137 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6140 LOGE("error is occurred 0x%x", ret);
6144 LOGD("ret : %d", ret);
6150 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6152 int ret = CAMERA_ERROR_NONE;
6153 camera_cli_s *pc = (camera_cli_s *)camera;
6154 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6155 camera_msg_param param;
6156 int set_disable = (int)disable;
6158 if (!pc || !pc->cb_info) {
6159 LOGE("NULL handle");
6160 return CAMERA_ERROR_INVALID_PARAMETER;
6165 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6167 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6169 LOGD("ret : 0x%x", ret);
6175 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6177 int ret = CAMERA_ERROR_NONE;
6178 camera_cli_s *pc = (camera_cli_s *)camera;
6179 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6180 camera_msg_param param;
6181 int set_move_type = (int)move_type;
6184 if (!pc || !pc->cb_info) {
6185 LOGE("NULL handle");
6186 return CAMERA_ERROR_INVALID_PARAMETER;
6191 value = (set_move_type << 16) | pan_step;
6192 CAMERA_MSG_PARAM_SET(param, INT, value);
6194 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6196 LOGD("ret : 0x%x", ret);
6202 int camera_attr_get_pan(camera_h camera, int *pan_step)
6204 int ret = CAMERA_ERROR_NONE;
6205 camera_cli_s *pc = (camera_cli_s *)camera;
6206 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6207 int get_pan_step = 0;
6209 if (!pc || !pc->cb_info || !pan_step) {
6210 LOGE("NULL pointer %p %p", pc, pan_step);
6211 return CAMERA_ERROR_INVALID_PARAMETER;
6216 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6218 if (ret == CAMERA_ERROR_NONE) {
6219 muse_camera_msg_get(get_pan_step, pc->cb_info->recv_msg);
6220 *pan_step = get_pan_step;
6223 LOGD("ret : 0x%x", ret);
6229 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6231 int ret = CAMERA_ERROR_NONE;
6232 camera_cli_s *pc = (camera_cli_s *)camera;
6233 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6237 if (!pc || !pc->cb_info || !min || !max) {
6238 LOGE("NULL pointer %p %p", pc, min, max);
6239 return CAMERA_ERROR_INVALID_PARAMETER;
6244 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6246 if (ret == CAMERA_ERROR_NONE) {
6247 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
6248 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
6253 LOGD("ret : 0x%x", ret);
6259 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6261 int ret = CAMERA_ERROR_NONE;
6262 camera_cli_s *pc = (camera_cli_s *)camera;
6263 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6264 camera_msg_param param;
6265 int set_move_type = (int)move_type;
6268 if (!pc || !pc->cb_info) {
6269 LOGE("NULL handle");
6270 return CAMERA_ERROR_INVALID_PARAMETER;
6275 value = (set_move_type << 16) | tilt_step;
6276 CAMERA_MSG_PARAM_SET(param, INT, value);
6278 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6280 LOGD("ret : 0x%x", ret);
6286 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6288 int ret = CAMERA_ERROR_NONE;
6289 camera_cli_s *pc = (camera_cli_s *)camera;
6290 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6291 int get_tilt_step = 0;
6293 if (!pc || !pc->cb_info || !tilt_step) {
6294 LOGE("NULL pointer %p %p", pc, tilt_step);
6295 return CAMERA_ERROR_INVALID_PARAMETER;
6300 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6302 if (ret == CAMERA_ERROR_NONE) {
6303 muse_camera_msg_get(get_tilt_step, pc->cb_info->recv_msg);
6304 *tilt_step = get_tilt_step;
6307 LOGD("ret : 0x%x", ret);
6313 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6315 int ret = CAMERA_ERROR_NONE;
6316 camera_cli_s *pc = (camera_cli_s *)camera;
6317 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6321 if (!pc || !pc->cb_info || !min || !max) {
6322 LOGE("NULL pointer %p %p %p", pc, min, max);
6323 return CAMERA_ERROR_INVALID_PARAMETER;
6328 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6330 if (ret == CAMERA_ERROR_NONE) {
6331 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
6332 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
6337 LOGD("ret : 0x%x", ret);
6343 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6345 int ret = CAMERA_ERROR_NONE;
6346 camera_cli_s *pc = (camera_cli_s *)camera;
6347 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6348 camera_msg_param param;
6349 int set_ptz_type = (int)ptz_type;
6351 if (!pc || !pc->cb_info) {
6352 LOGE("NULL handle");
6353 return CAMERA_ERROR_INVALID_PARAMETER;
6358 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6360 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6362 LOGD("ret : 0x%x", ret);
6368 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6370 int ret = CAMERA_ERROR_NONE;
6371 camera_cli_s *pc = (camera_cli_s *)camera;
6372 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6374 if (!pc || !pc->cb_info || !foreach_cb) {
6375 LOGE("NULL pointer %p %p", pc, foreach_cb);
6376 return CAMERA_ERROR_INVALID_PARAMETER;
6381 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6382 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6384 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6386 LOGD("ret : 0x%x", ret);
6392 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6394 int ret = CAMERA_ERROR_NONE;
6395 camera_cli_s *pc = (camera_cli_s *)camera;
6396 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6397 int set_display_roi_area[4] = {x, y, width, height};
6402 if (!pc || !pc->cb_info) {
6403 LOGE("NULL handle");
6404 return CAMERA_ERROR_INVALID_PARAMETER;
6409 #ifdef TIZEN_FEATURE_EVAS_RENDERER
6410 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6411 g_mutex_lock(&pc->cb_info->evas_mutex);
6413 ret = mm_evas_renderer_set_roi_area(pc->cb_info->evas_info, x, y, width, height);
6415 g_mutex_unlock(&pc->cb_info->evas_mutex);
6417 if (ret != MM_ERROR_NONE) {
6418 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6419 return CAMERA_ERROR_INVALID_OPERATION;
6422 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
6424 length = sizeof(set_display_roi_area) / sizeof(int) + \
6425 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6427 msg = muse_core_msg_json_factory_new(api,
6428 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6431 LOGE("msg creation failed: api %d", api);
6432 return CAMERA_ERROR_OUT_OF_MEMORY;
6435 if (pc->cb_info->is_server_connected)
6436 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
6439 LOGE("message send failed");
6440 ret = CAMERA_ERROR_INVALID_OPERATION;
6442 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6445 muse_core_msg_json_factory_free(msg);
6447 LOGD("ret : 0x%x", ret);
6453 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6455 camera_cli_s *pc = (camera_cli_s *)camera;
6456 int ret = CAMERA_ERROR_NONE;
6457 int get_display_roi_area[4] = {0,};
6458 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6460 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6461 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6462 return CAMERA_ERROR_INVALID_PARAMETER;
6467 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6469 if (ret == CAMERA_ERROR_NONE) {
6470 muse_camera_msg_get_array(get_display_roi_area, pc->cb_info->recv_msg);
6471 *x = get_display_roi_area[0];
6472 *y = get_display_roi_area[1];
6473 *width = get_display_roi_area[2];
6474 *height = get_display_roi_area[3];
6477 LOGD("ret : 0x%x", ret);
6483 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6485 int ret = CAMERA_ERROR_NONE;
6486 int get_device_state = 0;
6489 LOGE("NULL pointer");
6490 return CAMERA_ERROR_INVALID_PARAMETER;
6493 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6494 (int)device, "get_device_state", &get_device_state);
6496 if (ret == CAMERA_ERROR_NONE) {
6497 *state = (camera_device_state_e)get_device_state;
6498 LOGD("device state %d", *state);
6500 LOGE("failed 0x%x", ret);
6507 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6509 int ret = CAMERA_ERROR_NONE;
6510 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6511 camera_cb_info *info = NULL;
6513 if (!callback || !cb_id) {
6514 LOGE("invalid pointer %p %p", callback, cb_id);
6515 return CAMERA_ERROR_INVALID_PARAMETER;
6518 /* check camera support */
6519 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6520 if (ret != CAMERA_ERROR_NONE) {
6521 LOGE("get device state failed");
6525 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6527 info = g_new0(camera_cb_info, 1);
6529 LOGE("info failed");
6530 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6534 info->id = ++g_cam_dev_state_changed_cb_id;
6535 info->callback = (void *)callback;
6539 /* subscribe dbus signal for camera state change */
6540 if (!g_cam_dev_state_changed_cb_conn) {
6541 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6542 if (!g_cam_dev_state_changed_cb_conn) {
6543 LOGE("failed to get gdbus connection");
6544 ret = CAMERA_ERROR_INVALID_OPERATION;
6548 LOGD("subscribe signal %s - %s - %s",
6549 MM_CAMCORDER_DBUS_OBJECT,
6550 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6551 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6553 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6554 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6555 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6556 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6557 LOGE("failed to get gdbus connection");
6558 ret = CAMERA_ERROR_INVALID_OPERATION;
6562 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6565 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6567 LOGD("callback id %d", info->id);
6570 if (ret != CAMERA_ERROR_NONE) {
6576 if (g_cam_dev_state_changed_cb_conn) {
6577 g_object_unref(g_cam_dev_state_changed_cb_conn);
6578 g_cam_dev_state_changed_cb_conn = NULL;
6582 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6588 int camera_remove_device_state_changed_cb(int cb_id)
6590 int ret = CAMERA_ERROR_NONE;
6591 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6592 GList *tmp_list = NULL;
6593 camera_cb_info *info = NULL;
6595 /* check camera support */
6596 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6597 if (ret != CAMERA_ERROR_NONE) {
6598 LOGE("get device state failed");
6602 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6604 if (!g_cam_dev_state_changed_cb_list) {
6605 LOGE("there is no callback info");
6606 ret = CAMERA_ERROR_INVALID_OPERATION;
6610 tmp_list = g_cam_dev_state_changed_cb_list;
6613 info = tmp_list->data;
6614 tmp_list = tmp_list->next;
6621 if (info->id == cb_id) {
6622 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6627 if (!g_cam_dev_state_changed_cb_list) {
6628 /* no remained callback */
6629 if (g_cam_dev_state_changed_cb_conn) {
6630 /* unsubscribe signal */
6631 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6632 g_cam_dev_state_changed_cb_subscribe_id = 0;
6634 /* unref connection */
6635 g_object_unref(g_cam_dev_state_changed_cb_conn);
6636 g_cam_dev_state_changed_cb_conn = NULL;
6640 LOGD("id %d callback removed", cb_id);
6641 ret = CAMERA_ERROR_NONE;
6647 LOGE("id %d callback not found", cb_id);
6648 ret = CAMERA_ERROR_INVALID_PARAMETER;
6651 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);