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;
1788 char *error_msg = NULL;
1789 char *recv_msg = NULL;
1790 char **parse_str = NULL;
1791 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
1794 LOGE("cb_info NULL");
1800 parse_str = (char **)malloc(sizeof(char *) * CAMERA_PARSED_STRING_NUM_MAX);
1801 if (parse_str == NULL) {
1802 LOGE("parse_str malloc failed");
1806 for (i = 0 ; i < CAMERA_PARSED_STRING_NUM_MAX ; i++) {
1807 parse_str[i] = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
1808 if (parse_str[i] == NULL) {
1809 LOGE("parse_str[%d] malloc failed", i);
1810 goto CB_HANDLER_EXIT;
1814 recv_msg = cb_info->recv_msg;
1816 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
1817 ret = muse_core_ipc_recv_msg(cb_info->fd, recv_msg);
1819 cb_info->is_server_connected = FALSE;
1820 LOGE("receive msg failed - server disconnected");
1824 recv_msg[ret] = '\0';
1830 /*LOGD("recvMSg : %s, length : %d", recv_msg, ret);*/
1832 /* Need to split the combined entering msgs.
1833 This module supports up to 20 combined msgs. */
1834 for (str_pos = 0; str_pos < ret; str_pos++) {
1835 if (recv_msg[str_pos] == '}') {
1836 msg_length = str_pos - prev_pos + 1;
1838 if (msg_length < MUSE_CAMERA_MSG_MAX_LENGTH) {
1839 strncpy(parse_str[num_token], recv_msg + prev_pos, msg_length);
1840 parse_str[num_token][msg_length] = '\0';
1842 /*LOGD("splitted msg : [%s], Index : %d", parse_str[num_token], num_token);*/
1844 LOGW("too long message : length %d [%s]", msg_length, recv_msg + prev_pos);
1847 prev_pos = str_pos + 1;
1849 if (num_token >= CAMERA_PARSED_STRING_NUM_MAX) {
1850 LOGE("There's too many tokens. Remained msg : %s", recv_msg[++str_pos]);
1856 /*LOGD("num_token : %d", num_token);*/
1858 /* Re-construct to the useful single msg. */
1859 for (i = 0; i < num_token; i++) {
1860 if (i >= CAMERA_PARSED_STRING_NUM_MAX) {
1861 LOGE("invalid token index %d", i);
1870 if (!muse_camera_msg_get(api, parse_str[i])) {
1871 LOGE("failed to get camera api");
1875 if (api == MUSE_CAMERA_CB_EVENT) {
1876 if (!muse_camera_msg_get(event, parse_str[i]) ||
1877 !muse_camera_msg_get(event_class, parse_str[i])) {
1878 LOGE("failed to get camera event or event_class [%s]", parse_str[i]);
1882 if (!muse_camera_msg_get(api_class, parse_str[i])) {
1883 LOGE("failed to get camera api_class [%s]", parse_str[i]);
1888 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1889 if (api >= MUSE_CAMERA_API_MAX) {
1890 LOGE("invalid api %d", api);
1894 g_mutex_lock(&cb_info->api_mutex[api]);
1896 if (!muse_camera_msg_get(ret, parse_str[i])) {
1897 LOGE("failed to get camera ret");
1898 g_mutex_unlock(&cb_info->api_mutex[api]);
1902 cb_info->api_ret[api] = ret;
1903 cb_info->api_activating[api] = 1;
1905 if (api == MUSE_CAMERA_API_CREATE) {
1906 if (ret != CAMERA_ERROR_NONE) {
1907 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1908 LOGE("camera create error 0x%x. close client cb handler", ret);
1910 } else if (api == MUSE_CAMERA_API_DESTROY) {
1911 if (ret == CAMERA_ERROR_NONE) {
1912 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1913 LOGD("camera destroy done. close client cb handler");
1915 } else if (api == MUSE_CAMERA_API_GET_FLASH_STATE ||
1916 api == MUSE_CAMERA_API_GET_DEVICE_STATE) {
1917 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1918 LOGD("get flash or device state done. close client cb handler");
1921 g_cond_signal(&cb_info->api_cond[api]);
1922 g_mutex_unlock(&cb_info->api_mutex[api]);
1923 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
1924 __camera_add_msg_to_queue(cb_info, api, event, event_class, parse_str[i]);
1926 LOGW("unknown camera api %d, class %d", api, api_class);
1932 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
1934 if (!cb_info->is_server_connected) {
1935 /* send error msg for server disconnection */
1936 error_msg = muse_core_msg_json_factory_new(MUSE_CAMERA_CB_EVENT,
1937 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
1938 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
1941 LOGE("error_msg failed");
1942 goto CB_HANDLER_EXIT;
1945 __camera_add_msg_to_queue(cb_info,
1946 MUSE_CAMERA_CB_EVENT,
1947 MUSE_CAMERA_EVENT_TYPE_ERROR,
1948 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
1951 muse_core_msg_json_factory_free(error_msg);
1954 LOGE("add error msg for service disconnection done");
1959 for (i = 0 ; i < CAMERA_PARSED_STRING_NUM_MAX ; i++) {
1962 parse_str[i] = NULL;
1974 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
1975 int type, const char *thread_name, camera_cb_info_s *cb_info)
1977 if (!handler_info || !thread_name || !cb_info) {
1978 LOGE("t:%d NULL %p %p %p",
1979 type, handler_info, thread_name, cb_info);
1985 handler_info->type = type;
1986 handler_info->queue = g_queue_new();
1987 if (handler_info->queue == NULL) {
1988 LOGE("t:%d queue failed", type);
1992 g_mutex_init(&handler_info->mutex);
1993 g_cond_init(&handler_info->cond);
1995 handler_info->cb_info = (void *)cb_info;
1996 g_atomic_int_set(&handler_info->running, 1);
1998 handler_info->thread = g_thread_try_new(thread_name,
1999 _camera_msg_handler_func, (gpointer)handler_info, NULL);
2000 if (handler_info->thread == NULL) {
2001 LOGE("t:%d thread failed", type);
2003 g_mutex_clear(&handler_info->mutex);
2004 g_cond_clear(&handler_info->cond);
2005 g_queue_free(handler_info->queue);
2006 handler_info->queue = NULL;
2011 LOGD("t:%d done", type);
2017 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2021 if (!handler_info) {
2022 LOGE("NULL handler");
2026 if (!handler_info->thread) {
2027 LOGW("thread is not created");
2031 type = handler_info->type;
2033 LOGD("t:%d thread %p", type, handler_info->thread);
2035 g_mutex_lock(&handler_info->mutex);
2036 g_atomic_int_set(&handler_info->running, 0);
2037 g_cond_signal(&handler_info->cond);
2038 g_mutex_unlock(&handler_info->mutex);
2040 g_thread_join(handler_info->thread);
2041 g_thread_unref(handler_info->thread);
2042 handler_info->thread = NULL;
2044 g_mutex_clear(&handler_info->mutex);
2045 g_cond_clear(&handler_info->cond);
2046 g_queue_free(handler_info->queue);
2047 handler_info->queue = NULL;
2049 LOGD("t:%d done", type);
2055 static camera_cb_info_s *_camera_client_callback_new(gint sockfd, bool need_msg_handler_thread)
2057 camera_cb_info_s *cb_info = NULL;
2060 g_return_val_if_fail(sockfd > 0, NULL);
2062 cb_info = g_new0(camera_cb_info_s, 1);
2063 if (cb_info == NULL) {
2064 LOGE("cb_info failed");
2068 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2069 g_mutex_init(&cb_info->api_mutex[i]);
2070 g_cond_init(&cb_info->api_cond[i]);
2073 g_mutex_init(&cb_info->idle_event_mutex);
2074 g_cond_init(&cb_info->idle_event_cond);
2075 g_mutex_init(&cb_info->mp_data_mutex);
2076 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2077 g_mutex_init(&cb_info->evas_mutex);
2078 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2080 if (need_msg_handler_thread) {
2081 /* message handler thread */
2082 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2083 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2084 LOGE("msg_handler_info failed");
2088 /* message handler thread for preview callback */
2089 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2090 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2091 LOGE("preview_cb_info failed");
2095 /* message handler thread for capture callback */
2096 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2097 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2098 LOGE("capture_cb_info failed");
2103 cb_info->fd = sockfd;
2104 cb_info->preview_cb_flag = 0;
2105 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2106 cb_info->evas_info = NULL;
2107 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2109 /* message receive thread */
2110 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2111 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2112 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2113 if (cb_info->msg_recv_thread == NULL) {
2114 LOGE("message receive thread creation failed");
2118 cb_info->is_server_connected = TRUE;
2124 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2125 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2126 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2128 g_mutex_clear(&cb_info->idle_event_mutex);
2129 g_cond_clear(&cb_info->idle_event_cond);
2130 g_mutex_clear(&cb_info->mp_data_mutex);
2131 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2132 g_mutex_clear(&cb_info->evas_mutex);
2133 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2135 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2136 g_mutex_clear(&cb_info->api_mutex[i]);
2137 g_cond_clear(&cb_info->api_cond[i]);
2147 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2151 g_return_if_fail(cb_info != NULL);
2153 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2155 g_thread_join(cb_info->msg_recv_thread);
2156 g_thread_unref(cb_info->msg_recv_thread);
2157 cb_info->msg_recv_thread = NULL;
2159 LOGD("msg_recv thread removed");
2161 /* destroy msg handler threads */
2162 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2163 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2164 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2166 g_mutex_clear(&cb_info->idle_event_mutex);
2167 g_cond_clear(&cb_info->idle_event_cond);
2168 g_mutex_clear(&cb_info->mp_data_mutex);
2169 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2170 g_mutex_clear(&cb_info->evas_mutex);
2171 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2173 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2174 g_mutex_clear(&cb_info->api_mutex[i]);
2175 g_cond_clear(&cb_info->api_cond[i]);
2178 if (cb_info->fd > -1) {
2179 muse_core_connection_close(cb_info->fd);
2183 if (cb_info->bufmgr) {
2184 tbm_bufmgr_deinit(cb_info->bufmgr);
2185 cb_info->bufmgr = NULL;
2187 if (cb_info->pkt_fmt) {
2188 media_format_unref(cb_info->pkt_fmt);
2189 cb_info->pkt_fmt = NULL;
2192 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2193 if (cb_info->evas_info)
2194 mm_evas_renderer_destroy(&cb_info->evas_info);
2195 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2197 cb_info->preview_cb_flag = 0;
2206 int _camera_start_evas_rendering(camera_h camera)
2208 int ret = CAMERA_ERROR_NONE;
2209 camera_cli_s *pc = (camera_cli_s *)camera;
2211 if (!pc || !pc->cb_info) {
2212 LOGE("NULL handle");
2213 return CAMERA_ERROR_INVALID_PARAMETER;
2218 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2219 LOGE("EVAS surface is not set");
2220 return CAMERA_ERROR_NONE;
2223 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2224 g_mutex_lock(&pc->cb_info->evas_mutex);
2226 /* set evas render flag as RUN */
2227 pc->cb_info->run_evas_render = true;
2228 ret = CAMERA_ERROR_NONE;
2230 g_mutex_unlock(&pc->cb_info->evas_mutex);
2231 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2232 LOGW("evas renderer is not supported");
2233 ret = CAMERA_ERROR_NOT_SUPPORTED;
2234 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2240 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2242 int ret = CAMERA_ERROR_NONE;
2243 camera_cli_s *pc = (camera_cli_s *)camera;
2245 if (!pc || !pc->cb_info) {
2246 LOGE("NULL handle");
2247 return CAMERA_ERROR_INVALID_PARAMETER;
2250 LOGD("stop - keep screen %d", keep_screen);
2252 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2253 LOGE("EVAS surface is not set");
2254 return CAMERA_ERROR_NONE;
2257 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2258 g_mutex_lock(&pc->cb_info->evas_mutex);
2260 /* set evas render flag as STOP and release buffers */
2261 pc->cb_info->run_evas_render = false;
2263 ret = mm_evas_renderer_retrieve_all_packets(pc->cb_info->evas_info, keep_screen);
2264 if (ret != MM_ERROR_NONE) {
2265 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2266 ret = CAMERA_ERROR_INVALID_OPERATION;
2269 g_mutex_unlock(&pc->cb_info->evas_mutex);
2270 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2271 LOGW("evas renderer is not supported");
2272 ret = CAMERA_ERROR_NOT_SUPPORTED;
2273 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2279 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2281 int ret = CAMERA_ERROR_NONE;
2285 camera_cb_info_s *cb_info = NULL;
2287 /* create muse connection */
2288 if (!key || !value) {
2289 LOGE("NULL pointer");
2290 return CAMERA_ERROR_INVALID_PARAMETER;
2293 sock_fd = muse_core_client_new();
2295 LOGE("muse_core_client_new failed");
2296 return CAMERA_ERROR_INVALID_OPERATION;
2299 msg = muse_core_msg_json_factory_new(api,
2300 MUSE_TYPE_INT, "module", MUSE_CAMERA,
2301 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2305 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2309 send_ret = muse_core_ipc_send_msg(sock_fd, msg);
2311 muse_core_msg_json_factory_free(msg);
2315 LOGE("send msg failed");
2316 ret = CAMERA_ERROR_INVALID_OPERATION;
2320 cb_info = _camera_client_callback_new(sock_fd, false);
2322 LOGE("cb_info alloc failed");
2323 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2329 ret = _camera_client_wait_for_cb_return(api, cb_info, CAMERA_CB_TIMEOUT);
2331 if (ret == CAMERA_ERROR_NONE)
2332 muse_core_msg_json_deserialize(key, cb_info->recv_msg, NULL, value, NULL, MUSE_TYPE_ANY);
2334 LOGD("api %d - value %d", api, *value);
2337 /* release resources */
2339 _camera_client_callback_destroy(cb_info);
2344 muse_core_connection_close(sock_fd);
2352 int camera_create(camera_device_e device, camera_h *camera)
2355 char *send_msg = NULL;
2357 int ret = CAMERA_ERROR_NONE;
2359 camera_cli_s *pc = NULL;
2360 tbm_bufmgr bufmgr = NULL;
2362 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2363 muse_core_api_module_e muse_module = MUSE_CAMERA;
2364 int device_type = (int)device;
2367 LOGE("NULL pointer");
2368 return CAMERA_ERROR_INVALID_PARAMETER;
2371 sock_fd = muse_core_client_new();
2373 LOGE("muse_core_client_new failed - returned fd %d", sock_fd);
2374 ret = CAMERA_ERROR_INVALID_OPERATION;
2380 send_msg = muse_core_msg_json_factory_new(api,
2381 MUSE_TYPE_INT, "module", muse_module,
2382 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2383 MUSE_TYPE_INT, "pid", pid,
2388 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2392 send_ret = muse_core_ipc_send_msg(sock_fd, send_msg);
2394 muse_core_msg_json_factory_free(send_msg);
2398 LOGE("send msg failed %d", errno);
2399 ret = CAMERA_ERROR_INVALID_OPERATION;
2403 pc = g_new0(camera_cli_s, 1);
2405 LOGE("camera_cli_s alloc failed");
2406 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2410 bufmgr = tbm_bufmgr_init(-1);
2411 if (bufmgr == NULL) {
2412 LOGE("get tbm bufmgr failed");
2413 ret = CAMERA_ERROR_INVALID_OPERATION;
2417 pc->cb_info = _camera_client_callback_new(sock_fd, true);
2418 if (pc->cb_info == NULL) {
2419 LOGE("cb_info alloc failed");
2420 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2426 LOGD("cb info : %d", pc->cb_info->fd);
2428 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2429 if (ret == CAMERA_ERROR_NONE) {
2430 intptr_t handle = 0;
2431 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2433 LOGE("Receiving Handle Failed!!");
2434 ret = CAMERA_ERROR_INVALID_OPERATION;
2438 pc->remote_handle = handle;
2439 pc->cb_info->bufmgr = bufmgr;
2441 ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL);
2442 if (ret != CAMERA_ERROR_NONE) {
2443 LOGE("init display failed 0x%x", ret);
2447 LOGD("camera create 0x%x", pc->remote_handle);
2448 *camera = (camera_h)pc;
2457 tbm_bufmgr_deinit(bufmgr);
2462 muse_core_connection_close(sock_fd);
2468 _camera_client_callback_destroy(pc->cb_info);
2475 LOGE("camera create error : 0x%x", ret);
2481 int camera_change_device(camera_h camera, camera_device_e device)
2483 int ret = CAMERA_ERROR_NONE;
2484 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2485 camera_cli_s *pc = (camera_cli_s *)camera;
2486 camera_msg_param param;
2488 if (!pc || !pc->cb_info) {
2489 LOGE("NULL handle");
2490 return CAMERA_ERROR_INVALID_PARAMETER;
2493 CAMERA_MSG_PARAM_SET(param, INT, device);
2495 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2501 int camera_destroy(camera_h camera)
2503 int ret = CAMERA_ERROR_NONE;
2504 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2505 camera_cli_s *pc = (camera_cli_s *)camera;
2507 if (!pc || !pc->cb_info) {
2508 LOGE("NULL handle");
2509 return CAMERA_ERROR_INVALID_PARAMETER;
2514 if (pc->cb_info->is_server_connected)
2515 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2517 LOGW("server disconnected. release resource without send message.");
2519 if (ret == CAMERA_ERROR_NONE) {
2520 _camera_remove_idle_event_all(pc->cb_info);
2521 _camera_client_callback_destroy(pc->cb_info);
2531 int camera_start_preview(camera_h camera)
2533 int ret = CAMERA_ERROR_NONE;
2534 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2535 camera_cli_s *pc = (camera_cli_s *)camera;
2537 if (!pc || !pc->cb_info) {
2538 LOGE("NULL handle");
2539 return CAMERA_ERROR_INVALID_PARAMETER;
2544 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT_LONG);
2545 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2546 ret = _camera_start_evas_rendering(camera);
2547 if (ret != CAMERA_ERROR_NONE) {
2548 LOGE("stop preview because of error");
2549 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, pc->cb_info, NULL, 0);
2553 LOGD("ret : 0x%x", ret);
2559 int camera_stop_preview(camera_h camera)
2561 int ret = CAMERA_ERROR_NONE;
2562 camera_cli_s *pc = (camera_cli_s *)camera;
2563 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2564 camera_state_e current_state = CAMERA_STATE_NONE;
2566 if (!pc || !pc->cb_info) {
2567 LOGE("NULL handle");
2568 return CAMERA_ERROR_INVALID_PARAMETER;
2573 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2574 ret = camera_get_state(camera, ¤t_state);
2575 if (ret != CAMERA_ERROR_NONE) {
2576 LOGE("failed to get current state 0x%x", ret);
2580 if (current_state == CAMERA_STATE_PREVIEW) {
2581 ret = _camera_stop_evas_rendering(camera, false);
2582 if (ret != CAMERA_ERROR_NONE)
2587 /* send stop preview message */
2588 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2590 if (ret != CAMERA_ERROR_NONE &&
2591 current_state == CAMERA_STATE_PREVIEW) {
2592 LOGW("restart evas rendering");
2593 _camera_start_evas_rendering(camera);
2596 LOGD("ret : 0x%x", ret);
2602 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2604 int ret = CAMERA_ERROR_NONE;
2605 camera_cli_s *pc = (camera_cli_s *)camera;
2606 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2608 if (!pc || !pc->cb_info) {
2609 LOGE("NULL handle");
2610 return CAMERA_ERROR_INVALID_PARAMETER;
2615 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2616 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2618 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2619 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2621 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2623 LOGD("ret : 0x%x", ret);
2629 bool camera_is_supported_continuous_capture(camera_h camera)
2631 int ret = CAMERA_ERROR_NONE;
2632 camera_cli_s *pc = (camera_cli_s *)camera;
2633 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2635 if (!pc || !pc->cb_info) {
2636 LOGE("NULL handle");
2637 return CAMERA_ERROR_INVALID_PARAMETER;
2642 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2645 LOGE("error is occurred 0x%x", ret);
2649 LOGD("ret : %d", ret);
2655 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)
2657 int ret = CAMERA_ERROR_NONE;
2658 camera_cli_s *pc = (camera_cli_s *)camera;
2659 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2660 camera_msg_param param;
2663 if (!pc || !pc->cb_info) {
2664 LOGE("NULL handle");
2665 return CAMERA_ERROR_INVALID_PARAMETER;
2670 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2671 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2672 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2674 value = (count << 16) | interval;
2675 CAMERA_MSG_PARAM_SET(param, INT, value);
2677 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2679 LOGD("ret : 0x%x", ret);
2685 int camera_stop_continuous_capture(camera_h camera)
2687 int ret = CAMERA_ERROR_NONE;
2688 camera_cli_s *pc = (camera_cli_s *)camera;
2689 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2691 if (!pc || !pc->cb_info) {
2692 LOGE("NULL handle");
2693 return CAMERA_ERROR_INVALID_PARAMETER;
2698 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2700 LOGD("ret : 0x%x", ret);
2706 bool camera_is_supported_face_detection(camera_h camera)
2708 int ret = CAMERA_ERROR_NONE;
2709 camera_cli_s *pc = (camera_cli_s *)camera;
2710 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2712 if (!pc || !pc->cb_info) {
2713 LOGE("NULL handle");
2714 return CAMERA_ERROR_INVALID_PARAMETER;
2719 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2722 LOGE("error is occurred 0x%x", ret);
2726 LOGD("ret : %d", ret);
2732 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2734 int ret = CAMERA_ERROR_NONE;
2735 camera_cli_s *pc = (camera_cli_s *)camera;
2736 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2738 if (!pc || !pc->cb_info) {
2739 LOGE("NULL handle");
2740 return CAMERA_ERROR_INVALID_PARAMETER;
2745 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2748 LOGE("error is occurred 0x%x", ret);
2752 LOGD("ret : %d", ret);
2758 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2760 int ret = CAMERA_ERROR_NONE;
2761 camera_cli_s *pc = (camera_cli_s *)camera;
2762 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2764 if (!pc || !pc->cb_info) {
2765 LOGE("NULL handle");
2766 return CAMERA_ERROR_INVALID_PARAMETER;
2771 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2774 LOGE("error is occurred 0x%x", ret);
2778 LOGD("ret : %d", ret);
2783 int camera_get_device_count(camera_h camera, int *device_count)
2785 int ret = CAMERA_ERROR_NONE;
2786 camera_cli_s *pc = (camera_cli_s *)camera;
2787 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2788 int get_device_count = 0;
2790 if (!pc || !pc->cb_info) {
2791 LOGE("NULL handle");
2792 return CAMERA_ERROR_INVALID_PARAMETER;
2797 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2799 if (ret == CAMERA_ERROR_NONE) {
2800 muse_camera_msg_get(get_device_count, pc->cb_info->recv_msg);
2801 *device_count = get_device_count;
2804 LOGD("ret : 0x%x", ret);
2809 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2811 int ret = CAMERA_ERROR_NONE;
2812 camera_cli_s *pc = (camera_cli_s *)camera;
2813 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2815 if (!pc || !pc->cb_info) {
2816 LOGE("NULL handle");
2817 return CAMERA_ERROR_INVALID_PARAMETER;
2822 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2823 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2825 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2827 LOGD("ret : 0x%x", ret);
2832 int camera_stop_face_detection(camera_h camera)
2834 int ret = CAMERA_ERROR_NONE;
2835 camera_cli_s *pc = (camera_cli_s *)camera;
2836 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
2838 if (!pc || !pc->cb_info) {
2839 LOGE("NULL handle");
2840 return CAMERA_ERROR_INVALID_PARAMETER;
2845 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2847 LOGD("ret : 0x%x", ret);
2852 int camera_get_state(camera_h camera, camera_state_e *state)
2854 int ret = CAMERA_ERROR_NONE;
2855 camera_cli_s *pc = (camera_cli_s *)camera;
2856 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
2857 int get_state = CAMERA_STATE_NONE;
2859 if (!pc || !pc->cb_info || !state) {
2860 LOGE("NULL pointer %p %p", pc, state);
2861 return CAMERA_ERROR_INVALID_PARAMETER;
2866 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2868 if (ret == CAMERA_ERROR_NONE) {
2869 muse_camera_msg_get(get_state, pc->cb_info->recv_msg);
2870 *state = (camera_state_e)get_state;
2873 LOGD("ret : 0x%x", ret);
2878 int camera_start_focusing(camera_h camera, bool continuous)
2880 int ret = CAMERA_ERROR_NONE;
2881 camera_cli_s *pc = (camera_cli_s *)camera;
2882 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
2883 camera_msg_param param;
2884 int is_continuous = (int)continuous;
2886 if (!pc || !pc->cb_info) {
2887 LOGE("NULL handle");
2888 return CAMERA_ERROR_INVALID_PARAMETER;
2893 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
2895 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2897 LOGD("ret : 0x%x", ret);
2902 int camera_cancel_focusing(camera_h camera)
2904 int ret = CAMERA_ERROR_NONE;
2905 camera_cli_s *pc = (camera_cli_s *)camera;
2906 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
2908 if (!pc || !pc->cb_info) {
2909 LOGE("NULL handle");
2910 return CAMERA_ERROR_INVALID_PARAMETER;
2913 LOGD("Enter, remote_handle : %x", pc->remote_handle);
2915 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2917 LOGD("ret : 0x%x", ret);
2922 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
2924 int ret = CAMERA_ERROR_NONE;
2925 void *set_display_handle = NULL;
2926 Evas_Object *obj = NULL;
2927 const char *object_type = NULL;
2928 camera_cli_s *pc = (camera_cli_s *)camera;
2929 camera_cb_info_s *cb_info = NULL;
2930 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
2931 camera_state_e current_state = CAMERA_STATE_NONE;
2932 camera_msg_param param;
2936 if (!pc || !pc->cb_info) {
2937 LOGE("NULL handle");
2938 return CAMERA_ERROR_INVALID_PARAMETER;
2941 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
2942 LOGE("invalid type %d", type);
2943 return CAMERA_ERROR_INVALID_PARAMETER;
2946 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
2947 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
2948 return CAMERA_ERROR_INVALID_PARAMETER;
2951 cb_info = (camera_cb_info_s *)pc->cb_info;
2953 ret = camera_get_state(camera, ¤t_state);
2954 if (ret != CAMERA_ERROR_NONE) {
2955 LOGE("failed to get current state 0x%x", ret);
2959 if (current_state != CAMERA_STATE_CREATED) {
2960 LOGE("INVALID_STATE : current %d", current_state);
2961 return CAMERA_ERROR_INVALID_STATE;
2964 LOGD("Enter - display : %p", display);
2966 if (type == CAMERA_DISPLAY_TYPE_NONE) {
2967 set_display_handle = 0;
2968 LOGD("display type NONE");
2970 obj = (Evas_Object *)display;
2971 object_type = evas_object_type_get(obj);
2973 if (type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
2974 /* get wayland parent id */
2975 if (_camera_get_wl_info(obj, &pc->wl_info) != CAMERA_ERROR_NONE) {
2976 LOGE("failed to get wayland info");
2977 return CAMERA_ERROR_INVALID_OPERATION;
2980 set_display_handle = (void *)&pc->wl_info;
2981 LOGD("display type OVERLAY : handle %p", set_display_handle);
2982 } else if (type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
2983 /* evas object surface */
2984 set_display_handle = (void *)display;
2985 LOGD("display type EVAS : handle %p", set_display_handle);
2987 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2988 g_mutex_lock(&cb_info->evas_mutex);
2990 if (cb_info->evas_info) {
2991 LOGW("destroy existed evas renderer %p", cb_info->evas_info);
2992 ret = mm_evas_renderer_destroy(&cb_info->evas_info);
2993 if (ret != MM_ERROR_NONE) {
2994 LOGE("failed to destroy evas renderer %p", cb_info->evas_info);
2995 g_mutex_unlock(&cb_info->evas_mutex);
2996 return CAMERA_ERROR_INVALID_OPERATION;
3000 /* create evas renderer */
3001 ret = mm_evas_renderer_create(&cb_info->evas_info, (Evas_Object *)set_display_handle);
3002 if (ret == MM_ERROR_NONE) {
3003 camera_flip_e flip = CAMERA_FLIP_NONE;
3004 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3005 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3012 camera_get_display_flip(camera, &flip);
3013 camera_get_display_mode(camera, &mode);
3014 camera_get_display_rotation(camera, &rotation);
3015 camera_is_display_visible(camera, &visible);
3016 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3018 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
3019 flip, mode, rotation, visible, x, y, width, height);
3021 ret = mm_evas_renderer_set_flip(cb_info->evas_info, flip);
3022 ret |= mm_evas_renderer_set_geometry(cb_info->evas_info, mode);
3023 ret |= mm_evas_renderer_set_rotation(cb_info->evas_info, rotation);
3024 ret |= mm_evas_renderer_set_visible(cb_info->evas_info, visible);
3026 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
3027 ret |= mm_evas_renderer_set_roi_area(cb_info->evas_info, x, y, width, height);
3030 g_mutex_unlock(&cb_info->evas_mutex);
3032 if (ret != MM_ERROR_NONE) {
3033 LOGE("mm_evas_renderer error 0x%x", ret);
3034 return CAMERA_ERROR_INVALID_OPERATION;
3036 #else /* TIZEN_FEATURE_EVAS_RENDERER */
3037 LOGE("EVAS surface is not supported");
3038 return CAMERA_ERROR_NOT_SUPPORTED;
3039 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3041 LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type);
3042 return CAMERA_ERROR_INVALID_PARAMETER;
3045 LOGE("failed to get evas object type from %p", obj);
3046 return CAMERA_ERROR_INVALID_PARAMETER;
3050 pc->display_handle = (intptr_t)set_display_handle;
3052 if (type == CAMERA_DISPLAY_TYPE_OVERLAY) {
3055 length = sizeof(camera_wl_info_s) / sizeof(int) + \
3056 (sizeof(camera_wl_info_s) % sizeof(int) ? 1 : 0);
3058 msg = muse_core_msg_json_factory_new(api,
3059 MUSE_TYPE_INT, "type", type,
3060 MUSE_TYPE_ARRAY, "wl_info", length, (int *)&pc->wl_info,
3063 LOGE("msg creation failed: api %d", api);
3064 return CAMERA_ERROR_OUT_OF_MEMORY;
3067 if (pc->cb_info->is_server_connected)
3068 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
3071 LOGE("message send failed");
3072 ret = CAMERA_ERROR_INVALID_OPERATION;
3074 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
3077 muse_core_msg_json_factory_free(msg);
3079 LOGD("wayland parent id : %d, window %d,%d,%dx%d",
3080 pc->wl_info.parent_id, pc->wl_info.window_x, pc->wl_info.window_y,
3081 pc->wl_info.window_width, pc->wl_info.window_height);
3083 CAMERA_MSG_PARAM_SET(param, INT, type);
3085 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3088 if (ret != CAMERA_ERROR_NONE)
3089 LOGE("set display error 0x%x", ret);
3090 else if (type == CAMERA_DISPLAY_TYPE_EVAS)
3091 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3097 int camera_set_preview_resolution(camera_h camera, int width, int height)
3099 int ret = CAMERA_ERROR_NONE;
3100 camera_cli_s *pc = (camera_cli_s *)camera;
3101 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3102 camera_msg_param param;
3105 if (!pc || !pc->cb_info) {
3106 LOGE("NULL handle");
3107 return CAMERA_ERROR_INVALID_PARAMETER;
3110 value = (width << 16) | height;
3111 CAMERA_MSG_PARAM_SET(param, INT, value);
3113 LOGD("%dx%d -> 0x%x", width, height, value);
3115 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3117 LOGD("ret : 0x%x", ret);
3123 int camera_set_capture_resolution(camera_h camera, int width, int height)
3125 int ret = CAMERA_ERROR_NONE;
3126 camera_cli_s *pc = (camera_cli_s *)camera;
3127 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3128 camera_msg_param param;
3131 if (!pc || !pc->cb_info) {
3132 LOGE("NULL handle");
3133 return CAMERA_ERROR_INVALID_PARAMETER;
3138 value = (width << 16) | height;
3139 CAMERA_MSG_PARAM_SET(param, INT, value);
3141 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3143 LOGD("ret : 0x%x", ret);
3149 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3151 int ret = CAMERA_ERROR_NONE;
3152 int set_format = (int)format;
3153 camera_cli_s *pc = (camera_cli_s *)camera;
3154 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3155 camera_msg_param param;
3157 if (!pc || !pc->cb_info) {
3158 LOGE("NULL handle");
3159 return CAMERA_ERROR_INVALID_PARAMETER;
3162 LOGD("Enter - format %d", set_format);
3164 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3166 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3168 LOGD("ret : 0x%x", ret);
3174 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3176 int ret = CAMERA_ERROR_NONE;
3177 int set_format = (int)format;
3178 camera_msg_param param;
3179 camera_cli_s *pc = (camera_cli_s *)camera;
3180 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3182 if (!pc || !pc->cb_info) {
3183 LOGE("NULL handle");
3184 return CAMERA_ERROR_INVALID_PARAMETER;
3187 LOGD("Enter - capture_format %d", set_format);
3189 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3191 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3193 LOGD("ret : 0x%x", ret);
3199 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3201 int ret = CAMERA_ERROR_NONE;
3202 camera_cli_s *pc = (camera_cli_s *)camera;
3203 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3207 if (!pc || !pc->cb_info || !width || !height) {
3208 LOGE("NULL pointer %p %p %p", pc, width, height);
3209 return CAMERA_ERROR_INVALID_PARAMETER;
3214 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3216 if (ret == CAMERA_ERROR_NONE) {
3217 muse_camera_msg_get(get_width, pc->cb_info->recv_msg);
3218 muse_camera_msg_get(get_height, pc->cb_info->recv_msg);
3220 *height = get_height;
3223 LOGD("ret : 0x%x", ret);
3229 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3231 int ret = CAMERA_ERROR_NONE;
3232 int set_rotation = (int)rotation;
3233 camera_cli_s *pc = (camera_cli_s *)camera;
3234 camera_msg_param param;
3236 if (!pc || !pc->cb_info) {
3237 LOGE("NULL handle");
3238 return CAMERA_ERROR_INVALID_PARAMETER;
3241 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3242 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3243 g_mutex_lock(&pc->cb_info->evas_mutex);
3245 ret = mm_evas_renderer_set_rotation(pc->cb_info->evas_info, rotation);
3247 g_mutex_unlock(&pc->cb_info->evas_mutex);
3249 if (ret != MM_ERROR_NONE) {
3250 LOGE("failed to set rotation for evas surface 0x%x", ret);
3251 return CAMERA_ERROR_INVALID_OPERATION;
3254 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3256 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3258 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3264 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3266 int ret = CAMERA_ERROR_NONE;
3267 int get_rotation = CAMERA_ROTATION_NONE;
3268 camera_cli_s *pc = (camera_cli_s *)camera;
3270 if (!pc || !pc->cb_info || !rotation) {
3271 LOGE("NULL pointer %p %p", pc, rotation);
3272 return CAMERA_ERROR_INVALID_PARAMETER;
3275 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3277 if (ret == CAMERA_ERROR_NONE) {
3278 muse_camera_msg_get(get_rotation, pc->cb_info->recv_msg);
3279 *rotation = (camera_rotation_e)get_rotation;
3286 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3288 int ret = CAMERA_ERROR_NONE;
3289 int set_flip = (int)flip;
3290 camera_cli_s *pc = (camera_cli_s *)camera;
3291 camera_msg_param param;
3293 if (!pc || !pc->cb_info) {
3294 LOGE("NULL handle");
3295 return CAMERA_ERROR_INVALID_PARAMETER;
3298 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3299 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3300 g_mutex_lock(&pc->cb_info->evas_mutex);
3302 ret = mm_evas_renderer_set_flip(pc->cb_info->evas_info, flip);
3304 g_mutex_unlock(&pc->cb_info->evas_mutex);
3306 if (ret != MM_ERROR_NONE) {
3307 LOGE("failed to set flip for evas surface 0x%x", ret);
3308 return CAMERA_ERROR_INVALID_OPERATION;
3311 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3313 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3315 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3321 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3323 int ret = CAMERA_ERROR_NONE;
3324 int get_flip = CAMERA_FLIP_NONE;
3325 camera_cli_s *pc = (camera_cli_s *)camera;
3327 if (!pc || !pc->cb_info || !flip) {
3328 LOGE("NULL pointer %p %p", pc, flip);
3329 return CAMERA_ERROR_INVALID_PARAMETER;
3332 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3334 if (ret == CAMERA_ERROR_NONE) {
3335 muse_camera_msg_get(get_flip, pc->cb_info->recv_msg);
3336 *flip = (camera_flip_e)get_flip;
3343 int camera_set_display_visible(camera_h camera, bool visible)
3345 int ret = CAMERA_ERROR_NONE;
3346 int set_visible = (int)visible;
3347 camera_cli_s *pc = (camera_cli_s *)camera;
3348 camera_msg_param param;
3350 if (!pc || !pc->cb_info) {
3351 LOGE("NULL handle");
3352 return CAMERA_ERROR_INVALID_PARAMETER;
3355 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3356 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3357 g_mutex_lock(&pc->cb_info->evas_mutex);
3359 ret = mm_evas_renderer_set_visible(pc->cb_info->evas_info, visible);
3361 g_mutex_unlock(&pc->cb_info->evas_mutex);
3363 if (ret != MM_ERROR_NONE) {
3364 LOGE("failed to set visible for evas surface 0x%x", ret);
3365 return CAMERA_ERROR_INVALID_OPERATION;
3368 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3370 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3372 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3378 int camera_is_display_visible(camera_h camera, bool *visible)
3380 int ret = CAMERA_ERROR_NONE;
3381 int get_visible = true;
3382 camera_cli_s *pc = (camera_cli_s *)camera;
3384 if (!pc || !pc->cb_info || !visible) {
3385 LOGE("NULL pointer %p %p", pc, visible);
3386 return CAMERA_ERROR_INVALID_PARAMETER;
3389 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3391 if (ret == CAMERA_ERROR_NONE) {
3392 muse_camera_msg_get(get_visible, pc->cb_info->recv_msg);
3393 *visible = (bool)get_visible;
3400 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3402 int ret = CAMERA_ERROR_NONE;
3403 int set_mode = (int)mode;
3404 camera_cli_s *pc = (camera_cli_s *)camera;
3405 camera_msg_param param;
3407 if (!pc || !pc->cb_info) {
3408 LOGE("NULL handle");
3409 return CAMERA_ERROR_INVALID_PARAMETER;
3412 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3413 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3414 g_mutex_lock(&pc->cb_info->evas_mutex);
3416 ret = mm_evas_renderer_set_geometry(pc->cb_info->evas_info, mode);
3418 g_mutex_unlock(&pc->cb_info->evas_mutex);
3420 if (ret != MM_ERROR_NONE) {
3421 LOGE("failed to set geometry for evas surface 0x%x", ret);
3422 return CAMERA_ERROR_INVALID_OPERATION;
3425 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3427 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3429 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3435 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3437 int ret = CAMERA_ERROR_NONE;
3438 int get_mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3439 camera_cli_s *pc = (camera_cli_s *)camera;
3441 if (!pc || !pc->cb_info || !mode) {
3442 LOGE("NULL pointer %p %p", pc, mode);
3443 return CAMERA_ERROR_INVALID_PARAMETER;
3446 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3448 if (ret == CAMERA_ERROR_NONE) {
3449 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
3450 *mode = (camera_display_mode_e)get_mode;
3457 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3459 int ret = CAMERA_ERROR_NONE;
3460 int set_hint = (int)hint;
3461 camera_cli_s *pc = (camera_cli_s *)camera;
3462 camera_msg_param param;
3464 if (!pc || !pc->cb_info) {
3465 LOGE("NULL handle");
3466 return CAMERA_ERROR_INVALID_PARAMETER;
3469 LOGD("Enter - hint %d", set_hint);
3471 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3473 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3479 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3481 int ret = CAMERA_ERROR_NONE;
3483 camera_cli_s *pc = (camera_cli_s *)camera;
3484 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3486 if (!pc || !pc->cb_info || !hint) {
3487 LOGE("NULL pointer %p %p", pc, hint);
3488 return CAMERA_ERROR_INVALID_PARAMETER;
3491 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3493 if (ret == CAMERA_ERROR_NONE) {
3494 muse_camera_msg_get(get_hint, pc->cb_info->recv_msg);
3495 *hint = (bool)get_hint;
3497 LOGD("display reuse hint %d", *hint);
3504 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3506 int ret = CAMERA_ERROR_NONE;
3507 camera_cli_s *pc = (camera_cli_s *)camera;
3508 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3512 if (!pc || !pc->cb_info || !width || !height) {
3513 LOGE("NULL pointer %p %p %p", pc, width, height);
3514 return CAMERA_ERROR_INVALID_PARAMETER;
3519 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3521 if (ret == CAMERA_ERROR_NONE) {
3522 muse_camera_msg_get(get_width, pc->cb_info->recv_msg);
3523 muse_camera_msg_get(get_height, pc->cb_info->recv_msg);
3525 *height = get_height;
3528 LOGD("ret : 0x%x", ret);
3534 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3536 int ret = CAMERA_ERROR_NONE;
3537 camera_cli_s *pc = (camera_cli_s *)camera;
3538 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3541 if (!pc || !pc->cb_info || !format) {
3542 LOGE("NULL pointer %p %p", pc, format);
3543 return CAMERA_ERROR_INVALID_PARAMETER;
3548 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3550 if (ret == CAMERA_ERROR_NONE) {
3551 muse_camera_msg_get(get_format, pc->cb_info->recv_msg);
3552 *format = (camera_pixel_format_e)get_format;
3555 LOGD("ret : 0x%x", ret);
3561 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3563 int ret = CAMERA_ERROR_NONE;
3564 camera_cli_s *pc = (camera_cli_s *)camera;
3565 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3568 if (!pc || !pc->cb_info || !format) {
3569 LOGE("NULL pointer %p %p", pc, format);
3570 return CAMERA_ERROR_INVALID_PARAMETER;
3575 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3577 if (ret == CAMERA_ERROR_NONE) {
3578 muse_camera_msg_get(get_format, pc->cb_info->recv_msg);
3579 *format = (camera_pixel_format_e)get_format;
3582 LOGD("ret : 0x%x", ret);
3588 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3590 int ret = CAMERA_ERROR_NONE;
3591 camera_cli_s *pc = (camera_cli_s *)camera;
3592 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3593 int get_facing_direction = 0;
3595 if (!pc || !pc->cb_info || !facing_direction) {
3596 LOGE("NULL pointer %p %p", pc, facing_direction);
3597 return CAMERA_ERROR_INVALID_PARAMETER;
3602 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3604 if (ret == CAMERA_ERROR_NONE) {
3605 muse_camera_msg_get(get_facing_direction, pc->cb_info->recv_msg);
3606 *facing_direction = (camera_facing_direction_e)get_facing_direction;
3609 LOGD("ret : 0x%x", ret);
3615 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3617 int ret = CAMERA_ERROR_NONE;
3618 camera_cli_s *pc = (camera_cli_s *)camera;
3619 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3621 if (!pc || !pc->cb_info || !callback) {
3622 LOGE("NULL pointer %p %p", pc, callback);
3623 return CAMERA_ERROR_INVALID_PARAMETER;
3628 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3630 if (ret == CAMERA_ERROR_NONE) {
3631 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3632 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3633 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3636 LOGD("ret : 0x%x", ret);
3642 int camera_unset_preview_cb(camera_h camera)
3644 int ret = CAMERA_ERROR_NONE;
3645 camera_cli_s *pc = (camera_cli_s *)camera;
3646 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3648 if (!pc || !pc->cb_info) {
3649 LOGE("NULL handle");
3650 return CAMERA_ERROR_INVALID_PARAMETER;
3655 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3656 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3658 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3660 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3662 LOGD("ret : 0x%x", ret);
3668 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3670 int ret = CAMERA_ERROR_NONE;
3671 camera_cli_s *pc = (camera_cli_s *)camera;
3672 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3674 if (!pc || !pc->cb_info) {
3675 LOGE("NULL handle");
3676 return CAMERA_ERROR_INVALID_PARAMETER;
3679 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3680 LOGE("NOT SUPPORTED");
3681 return CAMERA_ERROR_NOT_SUPPORTED;
3684 if (callback == NULL) {
3685 LOGE("NULL callback");
3686 return CAMERA_ERROR_INVALID_PARAMETER;
3691 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3693 if (ret == CAMERA_ERROR_NONE) {
3694 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3695 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3698 LOGD("ret : 0x%x", ret);
3704 int camera_unset_media_packet_preview_cb(camera_h camera)
3706 int ret = CAMERA_ERROR_NONE;
3707 camera_cli_s *pc = (camera_cli_s *)camera;
3708 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3710 if (!pc || !pc->cb_info) {
3711 LOGE("NULL handle");
3712 return CAMERA_ERROR_INVALID_PARAMETER;
3717 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3718 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3720 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3722 LOGD("ret : 0x%x", ret);
3728 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3730 int ret = CAMERA_ERROR_NONE;
3731 camera_cli_s *pc = (camera_cli_s *)camera;
3732 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3734 if (!pc || !pc->cb_info || !callback) {
3735 LOGE("NULL pointer %p %p", pc, callback);
3736 return CAMERA_ERROR_INVALID_PARAMETER;
3741 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3743 if (ret == CAMERA_ERROR_NONE) {
3744 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3745 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3748 LOGD("ret : 0x%x", ret);
3754 int camera_unset_state_changed_cb(camera_h camera)
3756 int ret = CAMERA_ERROR_NONE;
3757 camera_cli_s *pc = (camera_cli_s *)camera;
3758 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3760 if (!pc || !pc->cb_info) {
3761 LOGE("NULL handle");
3762 return CAMERA_ERROR_INVALID_PARAMETER;
3767 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3768 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3770 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3772 LOGD("ret : 0x%x", ret);
3778 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3780 int ret = CAMERA_ERROR_NONE;
3781 camera_cli_s *pc = (camera_cli_s *)camera;
3782 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3784 if (!pc || !pc->cb_info || !callback) {
3785 LOGE("NULL pointer %p %p", pc, callback);
3786 return CAMERA_ERROR_INVALID_PARAMETER;
3791 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3793 if (ret == CAMERA_ERROR_NONE) {
3794 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3795 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3798 LOGD("ret : 0x%x", ret);
3804 int camera_unset_interrupted_cb(camera_h camera)
3806 int ret = CAMERA_ERROR_NONE;
3807 camera_cli_s *pc = (camera_cli_s *)camera;
3808 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3810 if (!pc || !pc->cb_info) {
3811 LOGE("NULL handle");
3812 return CAMERA_ERROR_INVALID_PARAMETER;
3817 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3818 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3820 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3822 LOGD("ret : 0x%x", ret);
3828 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
3830 int ret = CAMERA_ERROR_NONE;
3831 camera_cli_s *pc = (camera_cli_s *)camera;
3832 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3834 if (!pc || !pc->cb_info || !callback) {
3835 LOGE("NULL pointer %p %p", pc, callback);
3836 return CAMERA_ERROR_INVALID_PARAMETER;
3841 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3843 if (ret == CAMERA_ERROR_NONE) {
3844 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3845 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3848 LOGD("ret : 0x%x", ret);
3854 int camera_unset_focus_changed_cb(camera_h camera)
3856 int ret = CAMERA_ERROR_NONE;
3857 camera_cli_s *pc = (camera_cli_s *)camera;
3858 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
3860 if (!pc || !pc->cb_info) {
3861 LOGE("NULL handle");
3862 return CAMERA_ERROR_INVALID_PARAMETER;
3867 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3868 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3870 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3872 LOGD("ret : 0x%x", ret);
3878 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
3880 int ret = CAMERA_ERROR_NONE;
3881 camera_cli_s *pc = (camera_cli_s *)camera;
3882 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
3884 if (!pc || !pc->cb_info || !callback) {
3885 LOGE("NULL pointer %p %p", pc, callback);
3886 return CAMERA_ERROR_INVALID_PARAMETER;
3891 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3893 if (ret == CAMERA_ERROR_NONE) {
3894 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
3895 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
3898 LOGD("ret : 0x%x", ret);
3904 int camera_unset_error_cb(camera_h camera)
3906 int ret = CAMERA_ERROR_NONE;
3907 camera_cli_s *pc = (camera_cli_s *)camera;
3908 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
3910 if (!pc || !pc->cb_info) {
3911 LOGE("NULL handle");
3912 return CAMERA_ERROR_INVALID_PARAMETER;
3917 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
3918 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
3920 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3922 LOGD("ret : 0x%x", ret);
3928 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
3930 int ret = CAMERA_ERROR_NONE;
3931 camera_cli_s *pc = (camera_cli_s *)camera;
3932 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
3934 if (!pc || !pc->cb_info || !foreach_cb) {
3935 LOGE("NULL pointer %p %p", pc, foreach_cb);
3936 return CAMERA_ERROR_INVALID_PARAMETER;
3941 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
3942 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
3944 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3946 LOGD("ret : 0x%x", ret);
3952 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
3954 int ret = CAMERA_ERROR_NONE;
3955 camera_cli_s *pc = (camera_cli_s *)camera;
3956 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
3958 if (!pc || !pc->cb_info || !foreach_cb) {
3959 LOGE("NULL pointer %p %p", pc, foreach_cb);
3960 return CAMERA_ERROR_INVALID_PARAMETER;
3965 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
3966 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
3968 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3970 LOGD("ret : 0x%x", ret);
3976 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
3978 int ret = CAMERA_ERROR_NONE;
3979 camera_cli_s *pc = (camera_cli_s *)camera;
3980 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
3982 if (!pc || !pc->cb_info || !foreach_cb) {
3983 LOGE("NULL pointer %p %p", pc, foreach_cb);
3984 return CAMERA_ERROR_INVALID_PARAMETER;
3989 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
3990 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
3992 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3994 LOGD("ret : 0x%x", ret);
4000 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4002 int ret = CAMERA_ERROR_NONE;
4003 camera_cli_s *pc = (camera_cli_s *)camera;
4004 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4006 if (!pc || !pc->cb_info || !foreach_cb) {
4007 LOGE("NULL pointer %p %p", pc, foreach_cb);
4008 return CAMERA_ERROR_INVALID_PARAMETER;
4013 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4014 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4016 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4018 LOGD("ret : 0x%x", ret);
4024 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4026 int ret = CAMERA_ERROR_NONE;
4027 camera_cli_s *pc = (camera_cli_s *)camera;
4028 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4032 if (!pc || !pc->cb_info || !width || !height) {
4033 LOGE("NULL pointer %p %p %p", pc, width, height);
4034 return CAMERA_ERROR_INVALID_PARAMETER;
4038 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4040 if (ret == CAMERA_ERROR_NONE) {
4041 muse_camera_msg_get(get_width, pc->cb_info->recv_msg);
4042 muse_camera_msg_get(get_height, pc->cb_info->recv_msg);
4044 *height = get_height;
4047 LOGD("ret : 0x%x", ret);
4053 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4055 int ret = CAMERA_ERROR_NONE;
4056 camera_cli_s *pc = (camera_cli_s *)camera;
4057 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4060 if (!pc || !pc->cb_info || !angle) {
4061 LOGE("NULL pointer %p %p", pc, angle);
4062 return CAMERA_ERROR_INVALID_PARAMETER;
4067 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4069 if (ret == CAMERA_ERROR_NONE) {
4070 muse_camera_msg_get(get_angle, pc->cb_info->recv_msg);
4074 LOGD("ret : 0x%x", ret);
4080 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4082 int ret = CAMERA_ERROR_NONE;
4083 camera_cli_s *pc = (camera_cli_s *)camera;
4084 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4085 camera_msg_param param;
4086 int set_mode = (int)mode;
4088 if (!pc || !pc->cb_info) {
4089 LOGE("NULL handle");
4090 return CAMERA_ERROR_INVALID_PARAMETER;
4095 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4097 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4099 LOGD("ret : 0x%x", ret);
4105 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4107 int ret = CAMERA_ERROR_NONE;
4108 camera_cli_s *pc = (camera_cli_s *)camera;
4109 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4112 if (!pc || !pc->cb_info || !mode) {
4113 LOGE("NULL pointer %p %p", pc, mode);
4114 return CAMERA_ERROR_INVALID_PARAMETER;
4119 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4121 if (ret == CAMERA_ERROR_NONE) {
4122 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
4123 *mode = (camera_attr_theater_mode_e)get_mode;
4126 LOGD("ret : 0x%x", ret);
4132 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4134 int ret = CAMERA_ERROR_NONE;
4135 camera_cli_s *pc = (camera_cli_s *)camera;
4136 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4138 if (!pc || !pc->cb_info || !foreach_cb) {
4139 LOGE("NULL pointer %p %p", pc, foreach_cb);
4140 return CAMERA_ERROR_INVALID_PARAMETER;
4145 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4146 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4148 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4150 LOGD("Finish, return :%x", ret);
4156 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4158 int ret = CAMERA_ERROR_NONE;
4159 camera_cli_s *pc = (camera_cli_s *)camera;
4160 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4161 camera_msg_param param;
4162 int set_fps = (int)fps;
4164 if (!pc || !pc->cb_info) {
4165 LOGE("NULL handle");
4166 return CAMERA_ERROR_INVALID_PARAMETER;
4171 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4173 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4175 LOGD("ret : 0x%x", ret);
4181 int camera_attr_set_image_quality(camera_h camera, int quality)
4183 int ret = CAMERA_ERROR_NONE;
4184 camera_cli_s *pc = (camera_cli_s *)camera;
4185 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4186 camera_msg_param param;
4188 if (!pc || !pc->cb_info) {
4189 LOGE("NULL handle");
4190 return CAMERA_ERROR_INVALID_PARAMETER;
4195 CAMERA_MSG_PARAM_SET(param, INT, quality);
4197 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4199 LOGD("ret : 0x%x", ret);
4205 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4207 int ret = CAMERA_ERROR_NONE;
4208 camera_cli_s *pc = (camera_cli_s *)camera;
4209 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4212 if (!pc || !pc->cb_info || !fps) {
4213 LOGE("NULL pointer %p %p", pc, fps);
4214 return CAMERA_ERROR_INVALID_PARAMETER;
4219 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4221 if (ret == CAMERA_ERROR_NONE) {
4222 muse_camera_msg_get(get_fps, pc->cb_info->recv_msg);
4223 *fps = (camera_attr_fps_e)get_fps;
4226 LOGD("ret : 0x%x", ret);
4232 int camera_attr_get_image_quality(camera_h camera, int *quality)
4234 int ret = CAMERA_ERROR_NONE;
4235 camera_cli_s *pc = (camera_cli_s *)camera;
4236 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4237 int get_quality = 0;
4239 if (!pc || !pc->cb_info || !quality) {
4240 LOGE("NULL pointer %p %p", pc, quality);
4241 return CAMERA_ERROR_INVALID_PARAMETER;
4246 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4248 if (ret == CAMERA_ERROR_NONE) {
4249 muse_camera_msg_get(get_quality, pc->cb_info->recv_msg);
4250 *quality = get_quality;
4253 LOGD("ret : 0x%x", ret);
4259 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4261 int ret = CAMERA_ERROR_NONE;
4262 camera_cli_s *pc = (camera_cli_s *)camera;
4263 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4264 int get_bitrate = 0;
4266 if (!pc || !pc->cb_info || !bitrate) {
4267 LOGE("NULL pointer %p %p", pc, bitrate);
4268 return CAMERA_ERROR_INVALID_PARAMETER;
4273 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4275 if (ret == CAMERA_ERROR_NONE) {
4276 muse_camera_msg_get(get_bitrate, pc->cb_info->recv_msg);
4277 *bitrate = get_bitrate;
4280 LOGD("ret : 0x%x", ret);
4286 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4288 int ret = CAMERA_ERROR_NONE;
4289 camera_cli_s *pc = (camera_cli_s *)camera;
4290 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4291 camera_msg_param param;
4292 int set_bitrate = bitrate;
4294 if (!pc || !pc->cb_info) {
4295 LOGE("NULL handle");
4296 return CAMERA_ERROR_INVALID_PARAMETER;
4301 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4303 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4305 LOGD("ret : 0x%x", ret);
4311 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4313 int ret = CAMERA_ERROR_NONE;
4314 camera_cli_s *pc = (camera_cli_s *)camera;
4315 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4316 int get_gop_interval = 0;
4318 if (!pc || !pc->cb_info || !interval) {
4319 LOGE("NULL pointer %p %p", pc, interval);
4320 return CAMERA_ERROR_INVALID_PARAMETER;
4325 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4327 if (ret == CAMERA_ERROR_NONE) {
4328 muse_camera_msg_get(get_gop_interval, pc->cb_info->recv_msg);
4329 *interval = get_gop_interval;
4332 LOGD("ret : 0x%x", ret);
4338 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4340 int ret = CAMERA_ERROR_NONE;
4341 camera_cli_s *pc = (camera_cli_s *)camera;
4342 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4343 camera_msg_param param;
4344 int set_gop_interval = interval;
4346 if (!pc || !pc->cb_info) {
4347 LOGE("NULL handle");
4348 return CAMERA_ERROR_INVALID_PARAMETER;
4353 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4355 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4357 LOGD("ret : 0x%x", ret);
4363 int camera_attr_set_zoom(camera_h camera, int zoom)
4365 int ret = CAMERA_ERROR_NONE;
4366 camera_cli_s *pc = (camera_cli_s *)camera;
4367 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4368 camera_msg_param param;
4370 if (!pc || !pc->cb_info) {
4371 LOGE("NULL handle");
4372 return CAMERA_ERROR_INVALID_PARAMETER;
4375 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4377 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4379 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4381 LOGD("ret : 0x%x", ret);
4387 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4389 int ret = CAMERA_ERROR_NONE;
4390 camera_cli_s *pc = (camera_cli_s *)camera;
4391 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4392 camera_msg_param param;
4393 int set_mode = (int)mode;
4395 if (!pc || !pc->cb_info) {
4396 LOGE("NULL handle");
4397 return CAMERA_ERROR_INVALID_PARAMETER;
4400 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4402 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4404 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4410 int camera_attr_set_af_area(camera_h camera, int x, int y)
4412 int ret = CAMERA_ERROR_NONE;
4413 camera_cli_s *pc = (camera_cli_s *)camera;
4414 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4415 camera_msg_param param;
4418 if (!pc || !pc->cb_info) {
4419 LOGE("NULL handle");
4420 return CAMERA_ERROR_INVALID_PARAMETER;
4423 LOGD("Enter - %d,%d", x, y);
4425 value = (x << 16) | y;
4426 CAMERA_MSG_PARAM_SET(param, INT, value);
4428 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4430 LOGD("ret : 0x%x", ret);
4436 int camera_attr_clear_af_area(camera_h camera)
4438 int ret = CAMERA_ERROR_NONE;
4439 camera_cli_s *pc = (camera_cli_s *)camera;
4440 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4442 if (!pc || !pc->cb_info) {
4443 LOGE("NULL handle");
4444 return CAMERA_ERROR_INVALID_PARAMETER;
4449 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4451 LOGD("ret : 0x%x", ret);
4457 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4459 int ret = CAMERA_ERROR_NONE;
4460 camera_cli_s *pc = (camera_cli_s *)camera;
4461 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4462 camera_msg_param param;
4463 int set_mode = (int)mode;
4465 if (!pc || !pc->cb_info) {
4466 LOGE("NULL handle");
4467 return CAMERA_ERROR_INVALID_PARAMETER;
4472 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4474 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4476 LOGD("ret : 0x%x", ret);
4482 int camera_attr_set_exposure(camera_h camera, int value)
4484 int ret = CAMERA_ERROR_NONE;
4485 camera_cli_s *pc = (camera_cli_s *)camera;
4486 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4487 camera_msg_param param;
4489 if (!pc || !pc->cb_info) {
4490 LOGE("NULL handle");
4491 return CAMERA_ERROR_INVALID_PARAMETER;
4496 CAMERA_MSG_PARAM_SET(param, INT, value);
4498 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4500 LOGD("ret : 0x%x", ret);
4506 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4508 int ret = CAMERA_ERROR_NONE;
4509 camera_cli_s *pc = (camera_cli_s *)camera;
4510 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4511 camera_msg_param param;
4512 int set_iso = (int)iso;
4514 if (!pc || !pc->cb_info) {
4515 LOGE("NULL handle");
4516 return CAMERA_ERROR_INVALID_PARAMETER;
4521 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4523 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4525 LOGD("ret : 0x%x", ret);
4531 int camera_attr_set_brightness(camera_h camera, int level)
4533 int ret = CAMERA_ERROR_NONE;
4534 camera_cli_s *pc = (camera_cli_s *)camera;
4535 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4536 camera_msg_param param;
4538 if (!pc || !pc->cb_info) {
4539 LOGE("NULL handle");
4540 return CAMERA_ERROR_INVALID_PARAMETER;
4545 CAMERA_MSG_PARAM_SET(param, INT, level);
4547 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4549 LOGD("ret : 0x%x", ret);
4555 int camera_attr_set_contrast(camera_h camera, int level)
4557 int ret = CAMERA_ERROR_NONE;
4558 camera_cli_s *pc = (camera_cli_s *)camera;
4559 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4560 camera_msg_param param;
4562 if (!pc || !pc->cb_info) {
4563 LOGE("NULL handle");
4564 return CAMERA_ERROR_INVALID_PARAMETER;
4569 CAMERA_MSG_PARAM_SET(param, INT, level);
4571 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4573 LOGD("ret : 0x%x", ret);
4579 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4581 int ret = CAMERA_ERROR_NONE;
4582 camera_cli_s *pc = (camera_cli_s *)camera;
4583 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4584 camera_msg_param param;
4585 int set_whitebalance = (int)wb;
4587 if (!pc || !pc->cb_info) {
4588 LOGE("NULL handle");
4589 return CAMERA_ERROR_INVALID_PARAMETER;
4594 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4596 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4598 LOGD("ret : 0x%x", ret);
4604 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4606 int ret = CAMERA_ERROR_NONE;
4607 camera_cli_s *pc = (camera_cli_s *)camera;
4608 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4609 camera_msg_param param;
4610 int set_effect = (int)effect;
4612 if (!pc || !pc->cb_info) {
4613 LOGE("NULL handle");
4614 return CAMERA_ERROR_INVALID_PARAMETER;
4619 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4621 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4623 LOGD("ret : 0x%x", ret);
4629 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4631 int ret = CAMERA_ERROR_NONE;
4632 camera_cli_s *pc = (camera_cli_s *)camera;
4633 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4634 camera_msg_param param;
4635 int set_mode = (int)mode;
4637 if (!pc || !pc->cb_info) {
4638 LOGE("NULL handle");
4639 return CAMERA_ERROR_INVALID_PARAMETER;
4644 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4646 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4648 LOGD("ret : 0x%x", ret);
4654 int camera_attr_enable_tag(camera_h camera, bool enable)
4656 int ret = CAMERA_ERROR_NONE;
4657 camera_cli_s *pc = (camera_cli_s *)camera;
4658 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4659 camera_msg_param param;
4660 int set_enable = (int)enable;
4662 if (!pc || !pc->cb_info) {
4663 LOGE("NULL handle");
4664 return CAMERA_ERROR_INVALID_PARAMETER;
4669 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4671 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4673 LOGD("ret : 0x%x", ret);
4679 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4681 int ret = CAMERA_ERROR_NONE;
4682 camera_cli_s *pc = (camera_cli_s *)camera;
4683 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4684 camera_msg_param param;
4686 if (!pc || !pc->cb_info || !description) {
4687 LOGE("NULL pointer %p %p", pc, description);
4688 return CAMERA_ERROR_INVALID_PARAMETER;
4693 CAMERA_MSG_PARAM_SET(param, STRING, description);
4695 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4697 LOGD("ret : 0x%x", ret);
4703 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4705 int ret = CAMERA_ERROR_NONE;
4706 camera_cli_s *pc = (camera_cli_s *)camera;
4707 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4708 camera_msg_param param;
4709 int set_orientation = (int)orientation;
4711 if (!pc || !pc->cb_info) {
4712 LOGE("NULL handle");
4713 return CAMERA_ERROR_INVALID_PARAMETER;
4718 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4720 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4722 LOGD("ret : 0x%x", ret);
4728 int camera_attr_set_tag_software(camera_h camera, const char *software)
4730 int ret = CAMERA_ERROR_NONE;
4731 camera_cli_s *pc = (camera_cli_s *)camera;
4732 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4733 camera_msg_param param;
4735 if (!pc || !pc->cb_info || !software) {
4736 LOGE("NULL pointer %p %p", pc, software);
4737 return CAMERA_ERROR_INVALID_PARAMETER;
4740 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4742 CAMERA_MSG_PARAM_SET(param, STRING, software);
4744 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4746 LOGD("ret : 0x%x", ret);
4752 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4754 int ret = CAMERA_ERROR_NONE;
4755 camera_cli_s *pc = (camera_cli_s *)camera;
4756 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4757 double set_geotag[3] = {latitude, longitude, altitude};
4762 if (!pc || !pc->cb_info) {
4763 LOGE("NULL handle");
4764 return CAMERA_ERROR_INVALID_PARAMETER;
4769 length = sizeof(set_geotag) / sizeof(int) + \
4770 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4772 msg = muse_core_msg_json_factory_new(api,
4773 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4776 LOGE("msg creation failed: api %d", api);
4777 return CAMERA_ERROR_OUT_OF_MEMORY;
4780 if (pc->cb_info->is_server_connected)
4781 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
4784 LOGE("message send failed");
4785 ret = CAMERA_ERROR_INVALID_OPERATION;
4787 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
4790 muse_core_msg_json_factory_free(msg);
4792 LOGD("ret : 0x%x", ret);
4798 int camera_attr_remove_geotag(camera_h camera)
4800 int ret = CAMERA_ERROR_NONE;
4801 camera_cli_s *pc = (camera_cli_s *)camera;
4802 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4804 if (!pc || !pc->cb_info) {
4805 LOGE("NULL handle");
4806 return CAMERA_ERROR_INVALID_PARAMETER;
4811 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4813 LOGD("ret : 0x%x", ret);
4819 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4821 int ret = CAMERA_ERROR_NONE;
4822 camera_cli_s *pc = (camera_cli_s *)camera;
4823 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
4824 camera_msg_param param;
4825 int set_mode = (int)mode;
4827 if (!pc || !pc->cb_info) {
4828 LOGE("NULL handle");
4829 return CAMERA_ERROR_INVALID_PARAMETER;
4834 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4836 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4838 LOGD("ret : 0x%x", ret);
4844 int camera_attr_get_zoom(camera_h camera, int *zoom)
4846 int ret = CAMERA_ERROR_NONE;
4847 camera_cli_s *pc = (camera_cli_s *)camera;
4848 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4851 if (!pc || !pc->cb_info || !zoom) {
4852 LOGE("NULL pointer %p %p", pc, zoom);
4853 return CAMERA_ERROR_INVALID_PARAMETER;
4858 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4860 if (ret == CAMERA_ERROR_NONE) {
4861 muse_camera_msg_get(get_zoom, pc->cb_info->recv_msg);
4865 LOGD("ret : 0x%x", ret);
4871 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
4873 int ret = CAMERA_ERROR_NONE;
4874 camera_cli_s *pc = (camera_cli_s *)camera;
4875 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
4879 if (!pc || !pc->cb_info || !min || !max) {
4880 LOGE("NULL pointer %p %p %p", pc, min, max);
4881 return CAMERA_ERROR_INVALID_PARAMETER;
4886 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4888 if (ret == CAMERA_ERROR_NONE) {
4889 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
4890 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
4895 LOGD("ret : 0x%x", ret);
4901 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
4903 int ret = CAMERA_ERROR_NONE;
4904 camera_cli_s *pc = (camera_cli_s *)camera;
4905 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
4908 if (!pc || !pc->cb_info || !mode) {
4909 LOGE("NULL pointer %p %p", pc, mode);
4910 return CAMERA_ERROR_INVALID_PARAMETER;
4915 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4917 if (ret == CAMERA_ERROR_NONE) {
4918 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
4919 *mode = (camera_attr_af_mode_e)get_mode;
4922 LOGD("ret : 0x%x", ret);
4928 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
4930 int ret = CAMERA_ERROR_NONE;
4931 camera_cli_s *pc = (camera_cli_s *)camera;
4932 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
4935 if (!pc || !pc->cb_info || !mode) {
4936 LOGE("NULL pointer %p %p", pc, mode);
4937 return CAMERA_ERROR_INVALID_PARAMETER;
4942 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4944 if (ret == CAMERA_ERROR_NONE) {
4945 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
4946 *mode = (camera_attr_exposure_mode_e)get_mode;
4949 LOGD("ret : 0x%x", ret);
4955 int camera_attr_get_exposure(camera_h camera, int *value)
4957 int ret = CAMERA_ERROR_NONE;
4958 camera_cli_s *pc = (camera_cli_s *)camera;
4959 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
4962 if (!pc || !pc->cb_info || !value) {
4963 LOGE("NULL pointer %p %p", pc, value);
4964 return CAMERA_ERROR_INVALID_PARAMETER;
4969 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4971 if (ret == CAMERA_ERROR_NONE) {
4972 muse_camera_msg_get(get_value, pc->cb_info->recv_msg);
4976 LOGD("ret : 0x%x", ret);
4982 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
4984 int ret = CAMERA_ERROR_NONE;
4985 camera_cli_s *pc = (camera_cli_s *)camera;
4986 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
4990 if (!pc || !pc->cb_info || !min || !max) {
4991 LOGE("NULL pointer %p %p %p", pc, min, max);
4992 return CAMERA_ERROR_INVALID_PARAMETER;
4997 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4999 if (ret == CAMERA_ERROR_NONE) {
5000 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
5001 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
5006 LOGD("ret : 0x%x", ret);
5012 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5014 int ret = CAMERA_ERROR_NONE;
5015 camera_cli_s *pc = (camera_cli_s *)camera;
5016 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5019 if (!pc || !pc->cb_info || !iso) {
5020 LOGE("NULL pointer %p %p", pc, iso);
5021 return CAMERA_ERROR_INVALID_PARAMETER;
5026 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5028 if (ret == CAMERA_ERROR_NONE) {
5029 muse_camera_msg_get(get_iso, pc->cb_info->recv_msg);
5030 *iso = (camera_attr_iso_e)get_iso;
5033 LOGD("ret : 0x%x", ret);
5039 int camera_attr_get_brightness(camera_h camera, int *level)
5041 int ret = CAMERA_ERROR_NONE;
5042 camera_cli_s *pc = (camera_cli_s *)camera;
5043 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5046 if (!pc || !pc->cb_info || !level) {
5047 LOGE("NULL pointer %p %p", pc, level);
5048 return CAMERA_ERROR_INVALID_PARAMETER;
5053 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5055 if (ret == CAMERA_ERROR_NONE) {
5056 muse_camera_msg_get(get_level, pc->cb_info->recv_msg);
5060 LOGD("ret : 0x%x", ret);
5066 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5068 int ret = CAMERA_ERROR_NONE;
5069 camera_cli_s *pc = (camera_cli_s *)camera;
5070 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5074 if (!pc || !pc->cb_info || !min || !max) {
5075 LOGE("NULL pointer %p %p %p", pc, min, max);
5076 return CAMERA_ERROR_INVALID_PARAMETER;
5081 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5083 if (ret == CAMERA_ERROR_NONE) {
5084 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
5085 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
5090 LOGD("ret : 0x%x", ret);
5096 int camera_attr_get_contrast(camera_h camera, int *level)
5098 int ret = CAMERA_ERROR_NONE;
5099 camera_cli_s *pc = (camera_cli_s *)camera;
5100 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5103 if (!pc || !pc->cb_info || !level) {
5104 LOGE("NULL pointer %p %p", pc, level);
5105 return CAMERA_ERROR_INVALID_PARAMETER;
5110 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5112 if (ret == CAMERA_ERROR_NONE) {
5113 muse_camera_msg_get(get_level, pc->cb_info->recv_msg);
5117 LOGD("ret : 0x%x", ret);
5123 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5125 int ret = CAMERA_ERROR_NONE;
5126 camera_cli_s *pc = (camera_cli_s *)camera;
5127 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5131 if (!pc || !pc->cb_info || !min || !max) {
5132 LOGE("NULL pointer %p %p %p", pc, min, max);
5133 return CAMERA_ERROR_INVALID_PARAMETER;
5138 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5140 if (ret == CAMERA_ERROR_NONE) {
5141 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
5142 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
5147 LOGD("ret : 0x%x", ret);
5153 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5155 int ret = CAMERA_ERROR_NONE;
5156 camera_cli_s *pc = (camera_cli_s *)camera;
5157 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5160 if (!pc || !pc->cb_info || !wb) {
5161 LOGE("NULL pointer %p %p", pc, wb);
5162 return CAMERA_ERROR_INVALID_PARAMETER;
5167 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5169 if (ret == CAMERA_ERROR_NONE) {
5170 muse_camera_msg_get(get_wb, pc->cb_info->recv_msg);
5171 *wb = (camera_attr_whitebalance_e)get_wb;
5174 LOGD("ret : 0x%x", ret);
5180 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5182 int ret = CAMERA_ERROR_NONE;
5183 camera_cli_s *pc = (camera_cli_s *)camera;
5184 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5187 if (!pc || !pc->cb_info || !effect) {
5188 LOGE("NULL pointer %p %p", pc, effect);
5189 return CAMERA_ERROR_INVALID_PARAMETER;
5194 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5196 if (ret == CAMERA_ERROR_NONE) {
5197 muse_camera_msg_get(get_effect, pc->cb_info->recv_msg);
5198 *effect = (camera_attr_effect_mode_e)get_effect;
5201 LOGD("ret : 0x%x", ret);
5207 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5209 int ret = CAMERA_ERROR_NONE;
5210 camera_cli_s *pc = (camera_cli_s *)camera;
5211 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5214 if (!pc || !pc->cb_info || !mode) {
5215 LOGE("NULL pointer %p %p", pc, mode);
5216 return CAMERA_ERROR_INVALID_PARAMETER;
5221 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5223 if (ret == CAMERA_ERROR_NONE) {
5224 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
5225 *mode = (camera_attr_scene_mode_e)get_mode;
5228 LOGD("ret : 0x%x", ret);
5234 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5236 int ret = CAMERA_ERROR_NONE;
5237 camera_cli_s *pc = (camera_cli_s *)camera;
5238 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5239 int get_enabled = 0;
5241 if (!pc || !pc->cb_info || !enable) {
5242 LOGE("NULL pointer %p %p", pc, enable);
5243 return CAMERA_ERROR_INVALID_PARAMETER;
5248 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5250 if (ret == CAMERA_ERROR_NONE) {
5251 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
5252 *enable = (bool)get_enabled;
5255 LOGD("ret : 0x%x", ret);
5261 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5263 int ret = CAMERA_ERROR_NONE;
5264 camera_cli_s *pc = (camera_cli_s *)camera;
5265 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5266 char get_description[MUSE_CAMERA_MSG_MAX_LENGTH] = {0, };
5268 if (!pc || !pc->cb_info || !description) {
5269 LOGE("NULL pointer %p %p", pc, description);
5270 return CAMERA_ERROR_INVALID_PARAMETER;
5275 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5277 if (ret == CAMERA_ERROR_NONE) {
5278 muse_camera_msg_get_string(get_description, pc->cb_info->recv_msg);
5279 *description = strdup(get_description);
5282 LOGD("ret : 0x%x", ret);
5288 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5290 int ret = CAMERA_ERROR_NONE;
5291 camera_cli_s *pc = (camera_cli_s *)camera;
5292 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5293 int get_orientation = 0;
5295 if (!pc || !pc->cb_info || !orientation) {
5296 LOGE("NULL pointer %p %p", pc, orientation);
5297 return CAMERA_ERROR_INVALID_PARAMETER;
5302 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5304 if (ret == CAMERA_ERROR_NONE) {
5305 muse_camera_msg_get(get_orientation, pc->cb_info->recv_msg);
5306 *orientation = (camera_attr_tag_orientation_e)get_orientation;
5309 LOGD("ret : 0x%x", ret);
5315 int camera_attr_get_tag_software(camera_h camera, char **software)
5317 int ret = CAMERA_ERROR_NONE;
5318 camera_cli_s *pc = (camera_cli_s *)camera;
5319 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5320 char get_software[MUSE_CAMERA_MSG_MAX_LENGTH] = {0, };
5322 if (!pc || !pc->cb_info || !software) {
5323 LOGE("NULL pointer %p %p", pc, software);
5324 return CAMERA_ERROR_INVALID_PARAMETER;
5329 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5331 if (ret == CAMERA_ERROR_NONE) {
5332 muse_camera_msg_get_string(get_software, pc->cb_info->recv_msg);
5333 *software = strdup(get_software);
5336 LOGD("ret : 0x%x", ret);
5342 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5344 int ret = CAMERA_ERROR_NONE;
5345 camera_cli_s *pc = (camera_cli_s *)camera;
5346 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5347 double get_geotag[3] = {0.0, };
5349 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5350 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5351 return CAMERA_ERROR_INVALID_PARAMETER;
5356 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5358 if (ret == CAMERA_ERROR_NONE) {
5359 muse_camera_msg_get_array(get_geotag, pc->cb_info->recv_msg);
5360 *latitude = get_geotag[0];
5361 *longitude = get_geotag[1];
5362 *altitude = get_geotag[2];
5365 LOGD("ret : 0x%x", ret);
5371 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5373 int ret = CAMERA_ERROR_NONE;
5374 camera_cli_s *pc = (camera_cli_s *)camera;
5375 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5378 if (!pc || !pc->cb_info || !mode) {
5379 LOGE("NULL pointer %p %p", pc, mode);
5380 return CAMERA_ERROR_INVALID_PARAMETER;
5385 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5387 if (ret == CAMERA_ERROR_NONE) {
5388 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
5389 *mode = (camera_attr_flash_mode_e)get_mode;
5392 LOGD("ret : 0x%x", ret);
5398 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5400 int ret = CAMERA_ERROR_NONE;
5401 int get_flash_state = 0;
5404 LOGE("NULL pointer");
5405 return CAMERA_ERROR_INVALID_PARAMETER;
5408 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5409 (int)device, "get_flash_state", &get_flash_state);
5411 if (ret == CAMERA_ERROR_NONE) {
5412 *state = (camera_flash_state_e)get_flash_state;
5413 LOGD("flash state %d", *state);
5415 LOGE("failed 0x%x", ret);
5422 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5424 int ret = CAMERA_ERROR_NONE;
5425 camera_cli_s *pc = (camera_cli_s *)camera;
5426 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5428 if (!pc || !pc->cb_info || !foreach_cb) {
5429 LOGE("NULL pointer %p %p", pc, foreach_cb);
5430 return CAMERA_ERROR_INVALID_PARAMETER;
5435 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5436 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5438 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5440 LOGD("ret : 0x%x", ret);
5446 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5448 int ret = CAMERA_ERROR_NONE;
5449 camera_cli_s *pc = (camera_cli_s *)camera;
5450 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5452 if (!pc || !pc->cb_info || !foreach_cb) {
5453 LOGE("NULL pointer %p %p", pc, foreach_cb);
5454 return CAMERA_ERROR_INVALID_PARAMETER;
5459 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5460 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5462 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5464 LOGD("ret : 0x%x", ret);
5470 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5472 int ret = CAMERA_ERROR_NONE;
5473 camera_cli_s *pc = (camera_cli_s *)camera;
5474 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5476 if (!pc || !pc->cb_info || !foreach_cb) {
5477 LOGE("NULL pointer %p %p", pc, foreach_cb);
5478 return CAMERA_ERROR_INVALID_PARAMETER;
5483 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5484 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5486 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5488 LOGD("ret : 0x%x", ret);
5494 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5496 int ret = CAMERA_ERROR_NONE;
5497 camera_cli_s *pc = (camera_cli_s *)camera;
5498 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5500 if (!pc || !pc->cb_info || !foreach_cb) {
5501 LOGE("NULL pointer %p %p", pc, foreach_cb);
5502 return CAMERA_ERROR_INVALID_PARAMETER;
5507 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5508 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5510 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5512 LOGD("ret : 0x%x", ret);
5518 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5520 int ret = CAMERA_ERROR_NONE;
5521 camera_cli_s *pc = (camera_cli_s *)camera;
5522 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5524 if (!pc || !pc->cb_info || !foreach_cb) {
5525 LOGE("NULL pointer %p %p", pc, foreach_cb);
5526 return CAMERA_ERROR_INVALID_PARAMETER;
5531 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5532 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5534 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5536 LOGD("ret : 0x%x", ret);
5542 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5544 int ret = CAMERA_ERROR_NONE;
5545 camera_cli_s *pc = (camera_cli_s *)camera;
5546 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5548 if (!pc || !pc->cb_info || !foreach_cb) {
5549 LOGE("NULL pointer %p %p", pc, foreach_cb);
5550 return CAMERA_ERROR_INVALID_PARAMETER;
5555 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5556 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5558 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5560 LOGD("ret : 0x%x", ret);
5566 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5568 int ret = CAMERA_ERROR_NONE;
5569 camera_cli_s *pc = (camera_cli_s *)camera;
5570 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5572 if (!pc || !pc->cb_info || !foreach_cb) {
5573 LOGE("NULL pointer %p %p", pc, foreach_cb);
5574 return CAMERA_ERROR_INVALID_PARAMETER;
5579 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5580 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5582 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5584 LOGD("ret : 0x%x", ret);
5590 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5592 int ret = CAMERA_ERROR_NONE;
5593 camera_cli_s *pc = (camera_cli_s *)camera;
5594 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5596 if (!pc || !pc->cb_info || !foreach_cb) {
5597 LOGE("NULL pointer %p %p", pc, foreach_cb);
5598 return CAMERA_ERROR_INVALID_PARAMETER;
5603 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5604 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5606 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5608 LOGD("Enter, handle :%x", pc->remote_handle);
5614 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)
5616 int ret = CAMERA_ERROR_NONE;
5617 camera_cli_s *pc = (camera_cli_s *)camera;
5618 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5619 camera_msg_param param;
5622 if (!pc || !pc->cb_info || !foreach_cb) {
5623 LOGE("NULL pointer %p %p", pc, foreach_cb);
5624 return CAMERA_ERROR_INVALID_PARAMETER;
5629 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5630 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5632 value = (width << 16) | height;
5633 CAMERA_MSG_PARAM_SET(param, INT, value);
5635 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5637 LOGD("ret : 0x%x", ret);
5643 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5645 int ret = CAMERA_ERROR_NONE;
5646 camera_cli_s *pc = (camera_cli_s *)camera;
5647 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5649 if (!pc || !pc->cb_info || !foreach_cb) {
5650 LOGE("NULL pointer %p %p", pc, foreach_cb);
5651 return CAMERA_ERROR_INVALID_PARAMETER;
5656 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5657 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5659 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5661 LOGD("ret : 0x%x", ret);
5667 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5669 int ret = CAMERA_ERROR_NONE;
5670 camera_cli_s *pc = (camera_cli_s *)camera;
5671 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5673 if (!pc || !pc->cb_info || !foreach_cb) {
5674 LOGE("NULL pointer %p %p", pc, foreach_cb);
5675 return CAMERA_ERROR_INVALID_PARAMETER;
5680 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5681 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5683 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5685 LOGD("ret : 0x%x", ret);
5691 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5693 int ret = CAMERA_ERROR_NONE;
5694 camera_cli_s *pc = (camera_cli_s *)camera;
5695 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5696 camera_msg_param param;
5697 int set_rotation = (int)rotation;
5699 if (!pc || !pc->cb_info) {
5700 LOGE("NULL handle");
5701 return CAMERA_ERROR_INVALID_PARAMETER;
5706 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5708 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5710 LOGD("ret : 0x%x", ret);
5716 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5718 int ret = CAMERA_ERROR_NONE;
5719 camera_cli_s *pc = (camera_cli_s *)camera;
5720 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5721 int get_rotation = 0;
5723 if (!pc || !pc->cb_info || !rotation) {
5724 LOGE("NULL pointer %p %p", pc, rotation);
5725 return CAMERA_ERROR_INVALID_PARAMETER;
5730 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5732 if (ret == CAMERA_ERROR_NONE) {
5733 muse_camera_msg_get(get_rotation, pc->cb_info->recv_msg);
5734 *rotation = (camera_rotation_e)get_rotation;
5737 LOGD("ret : 0x%x", ret);
5743 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5745 int ret = CAMERA_ERROR_NONE;
5746 camera_cli_s *pc = (camera_cli_s *)camera;
5747 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5748 camera_msg_param param;
5749 int set_flip = (int)flip;
5751 if (!pc || !pc->cb_info) {
5752 LOGE("NULL handle");
5753 return CAMERA_ERROR_INVALID_PARAMETER;
5758 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5760 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5762 LOGD("ret : 0x%x", ret);
5768 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5770 int ret = CAMERA_ERROR_NONE;
5771 camera_cli_s *pc = (camera_cli_s *)camera;
5772 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5775 if (!pc || !pc->cb_info || !flip) {
5776 LOGE("NULL pointer %p %p", pc, flip);
5777 return CAMERA_ERROR_INVALID_PARAMETER;
5782 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5784 if (ret == CAMERA_ERROR_NONE) {
5785 muse_camera_msg_get(get_flip, pc->cb_info->recv_msg);
5786 *flip = (camera_flip_e)get_flip;
5789 LOGD("ret : 0x%x", ret);
5794 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5796 int ret = CAMERA_ERROR_NONE;
5797 camera_cli_s *pc = (camera_cli_s *)camera;
5798 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5799 camera_msg_param param;
5800 int set_mode = (int)mode;
5802 if (!pc || !pc->cb_info) {
5803 LOGE("NULL handle");
5804 return CAMERA_ERROR_INVALID_PARAMETER;
5809 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5811 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5813 LOGD("ret : 0x%x", ret);
5819 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5821 int ret = CAMERA_ERROR_NONE;
5822 camera_cli_s *pc = (camera_cli_s *)camera;
5823 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5826 if (!pc || !pc->cb_info || !mode) {
5827 LOGE("NULL pointer %p %p", pc, mode);
5828 return CAMERA_ERROR_INVALID_PARAMETER;
5833 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5835 if (ret == CAMERA_ERROR_NONE) {
5836 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
5837 *mode = (camera_attr_hdr_mode_e)get_mode;
5840 LOGD("ret : 0x%x", ret);
5846 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5848 int ret = CAMERA_ERROR_NONE;
5849 camera_cli_s *pc = (camera_cli_s *)camera;
5850 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
5852 if (!pc || !pc->cb_info) {
5853 LOGE("NULL handle");
5854 return CAMERA_ERROR_INVALID_PARAMETER;
5859 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5862 LOGE("error is occurred 0x%x", ret);
5866 LOGD("ret : %d", ret);
5872 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5874 int ret = CAMERA_ERROR_NONE;
5875 camera_cli_s *pc = (camera_cli_s *)camera;
5876 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5878 if (!pc || !pc->cb_info) {
5879 LOGE("NULL handle");
5880 return CAMERA_ERROR_INVALID_PARAMETER;
5885 if (!camera_attr_is_supported_hdr_capture(camera)) {
5886 LOGE("HDR not supported");
5887 return CAMERA_ERROR_NOT_SUPPORTED;
5891 LOGE("NULL callback");
5892 return CAMERA_ERROR_INVALID_PARAMETER;
5895 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5896 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5898 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5900 LOGD("ret : 0x%x", ret);
5906 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5908 int ret = CAMERA_ERROR_NONE;
5909 camera_cli_s *pc = (camera_cli_s *)camera;
5910 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5912 if (!pc || !pc->cb_info) {
5913 LOGE("NULL handle");
5914 return CAMERA_ERROR_INVALID_PARAMETER;
5919 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5920 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5922 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5924 LOGD("ret : 0x%x", ret);
5930 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
5932 int ret = CAMERA_ERROR_NONE;
5933 camera_cli_s *pc = (camera_cli_s *)camera;
5934 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
5935 camera_msg_param param;
5936 int set_enable = (int)enable;
5938 if (!pc || !pc->cb_info) {
5939 LOGE("NULL handle");
5940 return CAMERA_ERROR_INVALID_PARAMETER;
5945 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
5947 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5949 LOGD("ret : 0x%x", ret);
5955 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
5957 int ret = CAMERA_ERROR_NONE;
5958 camera_cli_s *pc = (camera_cli_s *)camera;
5959 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
5960 int get_enabled = 0;
5962 if (!pc || !pc->cb_info || !enabled) {
5963 LOGE("NULL pointer %p %p", pc, enabled);
5964 return CAMERA_ERROR_INVALID_PARAMETER;
5969 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5971 if (ret == CAMERA_ERROR_NONE) {
5972 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
5973 *enabled = (bool)get_enabled;
5976 LOGD("ret : 0x%x", ret);
5982 bool camera_attr_is_supported_anti_shake(camera_h camera)
5984 int ret = CAMERA_ERROR_NONE;
5985 camera_cli_s *pc = (camera_cli_s *)camera;
5986 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
5988 if (!pc || !pc->cb_info) {
5989 LOGE("NULL handle");
5990 return CAMERA_ERROR_INVALID_PARAMETER;
5995 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5998 LOGE("error is occurred 0x%x", ret);
6002 LOGD("ret : %d", ret);
6008 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6010 int ret = CAMERA_ERROR_NONE;
6011 camera_cli_s *pc = (camera_cli_s *)camera;
6012 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6013 camera_msg_param param;
6014 int set_enable = (int)enable;
6016 if (!pc || !pc->cb_info) {
6017 LOGE("NULL handle");
6018 return CAMERA_ERROR_INVALID_PARAMETER;
6023 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6025 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6027 LOGD("ret : 0x%x", ret);
6033 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6035 int ret = CAMERA_ERROR_NONE;
6036 camera_cli_s *pc = (camera_cli_s *)camera;
6037 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6038 int get_enabled = 0;
6040 if (!pc || !pc->cb_info || !enabled) {
6041 LOGE("NULL pointer %p %p", pc, enabled);
6042 return CAMERA_ERROR_INVALID_PARAMETER;
6047 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6049 if (ret == CAMERA_ERROR_NONE) {
6050 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
6051 *enabled = (bool)get_enabled;
6054 LOGD("ret : 0x%x", ret);
6060 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6062 int ret = CAMERA_ERROR_NONE;
6063 camera_cli_s *pc = (camera_cli_s *)camera;
6064 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6066 if (!pc || !pc->cb_info) {
6067 LOGE("NULL handle");
6068 return CAMERA_ERROR_INVALID_PARAMETER;
6073 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6076 LOGE("error is occurred 0x%x", ret);
6080 LOGD("ret : %d", ret);
6086 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6088 int ret = CAMERA_ERROR_NONE;
6089 camera_cli_s *pc = (camera_cli_s *)camera;
6090 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6091 camera_msg_param param;
6092 int set_enable = (int)enable;
6094 if (!pc || !pc->cb_info) {
6095 LOGE("NULL handle");
6096 return CAMERA_ERROR_INVALID_PARAMETER;
6101 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6103 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6105 LOGD("ret : 0x%x", ret);
6111 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6113 int ret = CAMERA_ERROR_NONE;
6114 camera_cli_s *pc = (camera_cli_s *)camera;
6115 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6116 int get_enabled = 0;
6118 if (!pc || !pc->cb_info || !enabled) {
6119 LOGE("NULL pointer %p %p", pc, enabled);
6120 return CAMERA_ERROR_INVALID_PARAMETER;
6125 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6127 if (ret == CAMERA_ERROR_NONE) {
6128 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
6129 *enabled = (bool)get_enabled;
6132 LOGD("ret : 0x%x", ret);
6138 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6140 int ret = CAMERA_ERROR_NONE;
6141 camera_cli_s *pc = (camera_cli_s *)camera;
6142 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6144 if (!pc || !pc->cb_info) {
6145 LOGE("NULL handle");
6146 return CAMERA_ERROR_INVALID_PARAMETER;
6151 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6154 LOGE("error is occurred 0x%x", ret);
6158 LOGD("ret : %d", ret);
6164 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6166 int ret = CAMERA_ERROR_NONE;
6167 camera_cli_s *pc = (camera_cli_s *)camera;
6168 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6169 camera_msg_param param;
6170 int set_disable = (int)disable;
6172 if (!pc || !pc->cb_info) {
6173 LOGE("NULL handle");
6174 return CAMERA_ERROR_INVALID_PARAMETER;
6179 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6181 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6183 LOGD("ret : 0x%x", ret);
6189 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6191 int ret = CAMERA_ERROR_NONE;
6192 camera_cli_s *pc = (camera_cli_s *)camera;
6193 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6194 camera_msg_param param;
6195 int set_move_type = (int)move_type;
6198 if (!pc || !pc->cb_info) {
6199 LOGE("NULL handle");
6200 return CAMERA_ERROR_INVALID_PARAMETER;
6205 value = (set_move_type << 16) | pan_step;
6206 CAMERA_MSG_PARAM_SET(param, INT, value);
6208 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6210 LOGD("ret : 0x%x", ret);
6216 int camera_attr_get_pan(camera_h camera, int *pan_step)
6218 int ret = CAMERA_ERROR_NONE;
6219 camera_cli_s *pc = (camera_cli_s *)camera;
6220 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6221 int get_pan_step = 0;
6223 if (!pc || !pc->cb_info || !pan_step) {
6224 LOGE("NULL pointer %p %p", pc, pan_step);
6225 return CAMERA_ERROR_INVALID_PARAMETER;
6230 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6232 if (ret == CAMERA_ERROR_NONE) {
6233 muse_camera_msg_get(get_pan_step, pc->cb_info->recv_msg);
6234 *pan_step = get_pan_step;
6237 LOGD("ret : 0x%x", ret);
6243 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6245 int ret = CAMERA_ERROR_NONE;
6246 camera_cli_s *pc = (camera_cli_s *)camera;
6247 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6251 if (!pc || !pc->cb_info || !min || !max) {
6252 LOGE("NULL pointer %p %p", pc, min, max);
6253 return CAMERA_ERROR_INVALID_PARAMETER;
6258 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6260 if (ret == CAMERA_ERROR_NONE) {
6261 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
6262 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
6267 LOGD("ret : 0x%x", ret);
6273 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6275 int ret = CAMERA_ERROR_NONE;
6276 camera_cli_s *pc = (camera_cli_s *)camera;
6277 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6278 camera_msg_param param;
6279 int set_move_type = (int)move_type;
6282 if (!pc || !pc->cb_info) {
6283 LOGE("NULL handle");
6284 return CAMERA_ERROR_INVALID_PARAMETER;
6289 value = (set_move_type << 16) | tilt_step;
6290 CAMERA_MSG_PARAM_SET(param, INT, value);
6292 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6294 LOGD("ret : 0x%x", ret);
6300 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6302 int ret = CAMERA_ERROR_NONE;
6303 camera_cli_s *pc = (camera_cli_s *)camera;
6304 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6305 int get_tilt_step = 0;
6307 if (!pc || !pc->cb_info || !tilt_step) {
6308 LOGE("NULL pointer %p %p", pc, tilt_step);
6309 return CAMERA_ERROR_INVALID_PARAMETER;
6314 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6316 if (ret == CAMERA_ERROR_NONE) {
6317 muse_camera_msg_get(get_tilt_step, pc->cb_info->recv_msg);
6318 *tilt_step = get_tilt_step;
6321 LOGD("ret : 0x%x", ret);
6327 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6329 int ret = CAMERA_ERROR_NONE;
6330 camera_cli_s *pc = (camera_cli_s *)camera;
6331 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6335 if (!pc || !pc->cb_info || !min || !max) {
6336 LOGE("NULL pointer %p %p %p", pc, min, max);
6337 return CAMERA_ERROR_INVALID_PARAMETER;
6342 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6344 if (ret == CAMERA_ERROR_NONE) {
6345 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
6346 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
6351 LOGD("ret : 0x%x", ret);
6357 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6359 int ret = CAMERA_ERROR_NONE;
6360 camera_cli_s *pc = (camera_cli_s *)camera;
6361 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6362 camera_msg_param param;
6363 int set_ptz_type = (int)ptz_type;
6365 if (!pc || !pc->cb_info) {
6366 LOGE("NULL handle");
6367 return CAMERA_ERROR_INVALID_PARAMETER;
6372 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6374 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6376 LOGD("ret : 0x%x", ret);
6382 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6384 int ret = CAMERA_ERROR_NONE;
6385 camera_cli_s *pc = (camera_cli_s *)camera;
6386 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6388 if (!pc || !pc->cb_info || !foreach_cb) {
6389 LOGE("NULL pointer %p %p", pc, foreach_cb);
6390 return CAMERA_ERROR_INVALID_PARAMETER;
6395 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6396 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6398 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6400 LOGD("ret : 0x%x", ret);
6406 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6408 int ret = CAMERA_ERROR_NONE;
6409 camera_cli_s *pc = (camera_cli_s *)camera;
6410 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6411 int set_display_roi_area[4] = {x, y, width, height};
6416 if (!pc || !pc->cb_info) {
6417 LOGE("NULL handle");
6418 return CAMERA_ERROR_INVALID_PARAMETER;
6423 #ifdef TIZEN_FEATURE_EVAS_RENDERER
6424 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6425 g_mutex_lock(&pc->cb_info->evas_mutex);
6427 ret = mm_evas_renderer_set_roi_area(pc->cb_info->evas_info, x, y, width, height);
6429 g_mutex_unlock(&pc->cb_info->evas_mutex);
6431 if (ret != MM_ERROR_NONE) {
6432 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6433 return CAMERA_ERROR_INVALID_OPERATION;
6436 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
6438 length = sizeof(set_display_roi_area) / sizeof(int) + \
6439 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6441 msg = muse_core_msg_json_factory_new(api,
6442 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6445 LOGE("msg creation failed: api %d", api);
6446 return CAMERA_ERROR_OUT_OF_MEMORY;
6449 if (pc->cb_info->is_server_connected)
6450 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
6453 LOGE("message send failed");
6454 ret = CAMERA_ERROR_INVALID_OPERATION;
6456 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6459 muse_core_msg_json_factory_free(msg);
6461 LOGD("ret : 0x%x", ret);
6467 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6469 camera_cli_s *pc = (camera_cli_s *)camera;
6470 int ret = CAMERA_ERROR_NONE;
6471 int get_display_roi_area[4] = {0,};
6472 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6474 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6475 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6476 return CAMERA_ERROR_INVALID_PARAMETER;
6481 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6483 if (ret == CAMERA_ERROR_NONE) {
6484 muse_camera_msg_get_array(get_display_roi_area, pc->cb_info->recv_msg);
6485 *x = get_display_roi_area[0];
6486 *y = get_display_roi_area[1];
6487 *width = get_display_roi_area[2];
6488 *height = get_display_roi_area[3];
6491 LOGD("ret : 0x%x", ret);
6497 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6499 int ret = CAMERA_ERROR_NONE;
6500 int get_device_state = 0;
6503 LOGE("NULL pointer");
6504 return CAMERA_ERROR_INVALID_PARAMETER;
6507 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6508 (int)device, "get_device_state", &get_device_state);
6510 if (ret == CAMERA_ERROR_NONE) {
6511 *state = (camera_device_state_e)get_device_state;
6512 LOGD("device state %d", *state);
6514 LOGE("failed 0x%x", ret);
6521 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6523 int ret = CAMERA_ERROR_NONE;
6524 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6525 camera_cb_info *info = NULL;
6527 if (!callback || !cb_id) {
6528 LOGE("invalid pointer %p %p", callback, cb_id);
6529 return CAMERA_ERROR_INVALID_PARAMETER;
6532 /* check camera support */
6533 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6534 if (ret != CAMERA_ERROR_NONE) {
6535 LOGE("get device state failed");
6539 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6541 info = g_new0(camera_cb_info, 1);
6543 LOGE("info failed");
6544 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6548 info->id = ++g_cam_dev_state_changed_cb_id;
6549 info->callback = (void *)callback;
6553 /* subscribe dbus signal for camera state change */
6554 if (!g_cam_dev_state_changed_cb_conn) {
6555 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6556 if (!g_cam_dev_state_changed_cb_conn) {
6557 LOGE("failed to get gdbus connection");
6558 ret = CAMERA_ERROR_INVALID_OPERATION;
6562 LOGD("subscribe signal %s - %s - %s",
6563 MM_CAMCORDER_DBUS_OBJECT,
6564 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6565 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6567 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6568 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6569 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6570 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6571 LOGE("failed to get gdbus connection");
6572 ret = CAMERA_ERROR_INVALID_OPERATION;
6576 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6579 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6581 LOGD("callback id %d", info->id);
6584 if (ret != CAMERA_ERROR_NONE) {
6590 if (g_cam_dev_state_changed_cb_conn) {
6591 g_object_unref(g_cam_dev_state_changed_cb_conn);
6592 g_cam_dev_state_changed_cb_conn = NULL;
6596 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6602 int camera_remove_device_state_changed_cb(int cb_id)
6604 int ret = CAMERA_ERROR_NONE;
6605 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6606 GList *tmp_list = NULL;
6607 camera_cb_info *info = NULL;
6609 /* check camera support */
6610 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6611 if (ret != CAMERA_ERROR_NONE) {
6612 LOGE("get device state failed");
6616 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6618 if (!g_cam_dev_state_changed_cb_list) {
6619 LOGE("there is no callback info");
6620 ret = CAMERA_ERROR_INVALID_OPERATION;
6624 tmp_list = g_cam_dev_state_changed_cb_list;
6627 info = tmp_list->data;
6628 tmp_list = tmp_list->next;
6635 if (info->id == cb_id) {
6636 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6641 if (!g_cam_dev_state_changed_cb_list) {
6642 /* no remained callback */
6643 if (g_cam_dev_state_changed_cb_conn) {
6644 /* unsubscribe signal */
6645 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6646 g_cam_dev_state_changed_cb_subscribe_id = 0;
6648 /* unref connection */
6649 g_object_unref(g_cam_dev_state_changed_cb_conn);
6650 g_cam_dev_state_changed_cb_conn = NULL;
6654 LOGD("id %d callback removed", cb_id);
6655 ret = CAMERA_ERROR_NONE;
6661 LOGE("id %d callback not found", cb_id);
6662 ret = CAMERA_ERROR_INVALID_PARAMETER;
6665 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);