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 media_packet_h pkt_evas = NULL;
1093 muse_camera_msg_get(tbm_key, recv_msg);
1094 muse_camera_msg_get(num_buffer_key, recv_msg);
1095 muse_camera_msg_get_array(buffer_key, recv_msg);
1096 muse_camera_msg_get(data_key, recv_msg);
1098 memset(&frame, 0x0, sizeof(camera_preview_data_s));
1101 LOGE("invalid key %d", tbm_key);
1105 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1108 /* import tbm data_bo and get virtual address */
1109 if (!_camera_import_tbm_key(cb_info->bufmgr, data_key, &data_bo, &data_bo_handle)) {
1110 LOGE("failed to import data key %d", data_key);
1111 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1116 /* import tbm bo and get virtual address */
1117 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
1118 LOGE("failed to import key %d", tbm_key);
1119 _camera_release_imported_bo(&data_bo);
1120 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1124 buf_pos = (unsigned char *)bo_handle.ptr;
1126 /* get stream info */
1127 stream = (camera_stream_data_s *)buf_pos;
1129 for (i = 0 ; i < num_buffer_key ; i++) {
1130 /* import buffer bo and get virtual address */
1131 if (!_camera_import_tbm_key(cb_info->bufmgr, buffer_key[i], &buffer_bo[i], &buffer_bo_handle[i])) {
1132 LOGE("failed to import buffer key %d", buffer_key[i]);
1134 /* release imported bo */
1135 _camera_release_imported_bo(&data_bo);
1136 _camera_release_imported_bo(&bo);
1138 for (i -= 1 ; i >= 0 ; i--)
1139 _camera_release_imported_bo(&buffer_bo[i]);
1141 /* send return buffer */
1142 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1148 /* call preview callback */
1149 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
1150 _camera_preview_frame_create(stream, num_buffer_key, buffer_bo_handle, &data_bo_handle, &frame);
1152 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
1153 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
1156 if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
1157 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1158 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
1160 if (ret == CAMERA_ERROR_NONE) {
1161 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt_evas);
1162 if (ret != CAMERA_ERROR_NONE) {
1163 LOGE("create pkt for evas failed");
1164 _camera_media_packet_data_release(mp_data, cb_info);
1168 #else /* TIZEN_FEATURE_EVAS_RENDERER */
1169 LOGW("evas renderer is not supported");
1170 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1173 /* call media packet callback */
1174 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
1175 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
1177 if (ret == CAMERA_ERROR_NONE) {
1178 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt);
1180 if (ret == CAMERA_ERROR_NONE) {
1181 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
1182 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
1184 _camera_media_packet_data_release(mp_data, cb_info);
1190 /* call evas renderer */
1192 g_mutex_lock(&cb_info->evas_mutex);
1193 if (cb_info->run_evas_render) {
1194 mm_evas_renderer_write(pkt_evas, cb_info->evas_info);
1196 LOGW("evas renderer is stopped, skip this buffer...");
1197 media_packet_destroy(pkt_evas);
1200 g_mutex_unlock(&cb_info->evas_mutex);
1203 /* send message for preview callback return */
1204 if (!CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS))
1205 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info, NULL, 0);
1207 if (mp_data == NULL) {
1208 /* release imported bo */
1209 for (i = 0 ; i < num_buffer_key ; i++)
1210 _camera_release_imported_bo(&buffer_bo[i]);
1212 /* unmap and unref tbm bo */
1213 _camera_release_imported_bo(&data_bo);
1214 _camera_release_imported_bo(&bo);
1217 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1219 /*LOGD("return buffer Done");*/
1223 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1227 muse_camera_msg_get(percent, recv_msg);
1229 LOGD("HDR progress - %d \%", percent);
1231 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1234 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1240 muse_camera_msg_get(policy, recv_msg);
1241 muse_camera_msg_get(previous, recv_msg);
1242 muse_camera_msg_get(current, recv_msg);
1244 LOGW("INTERRUPTED - policy %d, state previous %d, current %d",
1245 policy, previous, current);
1247 if (policy == CAMERA_POLICY_SOUND)
1248 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND is deprecated and will be removed from next release.");
1249 else if (policy == CAMERA_POLICY_SOUND_BY_CALL)
1250 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_CALL is deprecated and will be removed from next release.");
1251 else if (policy == CAMERA_POLICY_SOUND_BY_ALARM)
1252 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_ALARM is deprecated and will be removed from next release.");
1254 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1255 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1258 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1261 camera_detected_face_s *faces = NULL;
1263 muse_camera_msg_get(count, recv_msg);
1264 muse_camera_msg_get(tbm_key, recv_msg);
1266 if (count > 0 && tbm_key > 0) {
1267 LOGD("FACE_DETECTION - count %d, tbm_key %d", count, tbm_key);
1269 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle))
1273 faces = bo_handle.ptr;
1275 ((camera_face_detected_cb)cb_info->user_cb[event])(faces, count, cb_info->user_data[event]);
1281 for (i = 0 ; i < count ; i++) {
1282 LOGD("id[%2d] - score %d, position (%d,%d,%dx%d)",
1283 i, faces[i].score, faces[i].x, faces[i].y, faces[i].width, faces[i].height);
1289 _camera_release_imported_bo(&bo);
1292 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1293 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1295 /*LOGD("return buffer done");*/
1297 LOGE("invalid message - count %d, key %d", count, tbm_key);
1301 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1304 int current_state = 0;
1306 muse_camera_msg_get(error, recv_msg);
1307 muse_camera_msg_get(current_state, recv_msg);
1309 LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
1311 if (error == CAMERA_ERROR_SOUND_POLICY)
1312 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
1313 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_CALL)
1314 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
1315 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_ALARM)
1316 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
1318 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1319 (camera_state_e)current_state, cb_info->user_data[event]);
1322 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1324 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1325 muse_camera_msg_get(param1, recv_msg);
1326 muse_camera_msg_get(param2, recv_msg);
1328 /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/
1330 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1331 cb_info->user_cb[event] = NULL;
1332 cb_info->user_data[event] = NULL;
1333 LOGW("stop foreach callback for event %d", event);
1336 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1338 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1340 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1342 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1344 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1346 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1348 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1350 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1352 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1354 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1356 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1358 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1360 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1362 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1364 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1365 muse_camera_msg_get(param1, recv_msg);
1367 /*LOGD("event %d SUPPORTED %d ", event, param1);*/
1369 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1370 cb_info->user_cb[event] = NULL;
1371 cb_info->user_data[event] = NULL;
1372 LOGW("stop foreach callback for event %d", event);
1375 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1377 camera_image_data_s *rImage = NULL;
1378 camera_image_data_s *rPostview = NULL;
1379 camera_image_data_s *rThumbnail = NULL;
1380 unsigned char *buf_pos = NULL;
1381 int tbm_key_main = 0;
1382 int tbm_key_post = 0;
1383 int tbm_key_thumb = 0;
1384 tbm_bo bo_main = NULL;
1385 tbm_bo bo_post = NULL;
1386 tbm_bo bo_thumb = NULL;
1387 tbm_bo_handle bo_main_handle = {NULL, };
1388 tbm_bo_handle bo_post_handle = {NULL, };
1389 tbm_bo_handle bo_thumb_handle = {NULL, };
1391 muse_camera_msg_get(tbm_key_main, recv_msg);
1392 muse_camera_msg_get(tbm_key_post, recv_msg);
1393 muse_camera_msg_get(tbm_key_thumb, recv_msg);
1396 LOGD("camera capture callback came in. tbm_key_main %d, tbm_key_post %d, tbm_key_thumb %d",
1397 tbm_key_main, tbm_key_post, tbm_key_thumb);
1400 if (tbm_key_main <= 0) {
1401 LOGE("invalid key %d", tbm_key_main);
1405 /* import tbm bo and get virtual address */
1406 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_main, &bo_main, &bo_main_handle))
1409 buf_pos = (unsigned char *)bo_main_handle.ptr;
1410 rImage = (camera_image_data_s *)buf_pos;
1411 rImage->data = buf_pos + sizeof(camera_image_data_s);
1413 LOGD("image info %dx%d, size : %d", rImage->width, rImage->height, rImage->size);
1415 if (tbm_key_post > 0) {
1416 /* import tbm bo and get virtual address */
1417 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_post, &bo_post, &bo_post_handle))
1420 buf_pos = (unsigned char *)bo_post_handle.ptr;
1421 rPostview = (camera_image_data_s *)buf_pos;
1422 LOGD("rPostview->size : %d", rPostview->size);
1423 rPostview->data = buf_pos + sizeof(camera_image_data_s);
1426 if (tbm_key_thumb > 0) {
1427 /* import tbm bo and get virtual address */
1428 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_thumb, &bo_thumb, &bo_thumb_handle))
1431 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
1433 rThumbnail = (camera_image_data_s *)buf_pos;
1434 LOGD("rThumbnail->size : %d", rThumbnail->size);
1435 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
1438 ((camera_capturing_cb)cb_info->user_cb[event])(rImage, rPostview, rThumbnail, cb_info->user_data[event]);
1440 /* unmap and unref tbm bo */
1441 _camera_release_imported_bo(&bo_main);
1444 tbm_key = tbm_key_main;
1446 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1448 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1450 if (tbm_key_post > 0) {
1451 /* unmap and unref tbm bo */
1452 _camera_release_imported_bo(&bo_post);
1455 param.value.value_INT = tbm_key_post;
1456 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1459 if (tbm_key_thumb > 0) {
1460 /* unmap and unref tbm bo */
1461 _camera_release_imported_bo(&bo_thumb);
1464 param.value.value_INT = tbm_key_thumb;
1465 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1468 LOGD("return buffer done");
1471 case MUSE_CAMERA_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR:
1474 LOGW("Unknown event : %d", event);
1481 static bool _camera_idle_event_callback(void *data)
1483 camera_cb_info_s *cb_info = NULL;
1484 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1486 if (cam_idle_event == NULL) {
1487 LOGE("cam_idle_event is NULL");
1492 g_mutex_lock(&cam_idle_event->event_mutex);
1494 cb_info = cam_idle_event->cb_info;
1495 if (cb_info == NULL) {
1496 LOGW("camera cb_info is NULL. event %d", cam_idle_event->event);
1497 goto IDLE_EVENT_CALLBACK_DONE;
1500 /* remove event from list */
1501 g_mutex_lock(&cb_info->idle_event_mutex);
1503 if (cb_info->idle_event_list)
1504 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1506 /*LOGD("remove camera idle event %p, %p", cam_idle_event, cb_info->idle_event_list);*/
1507 g_mutex_unlock(&cb_info->idle_event_mutex);
1510 _camera_client_user_callback(cam_idle_event->cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
1512 /* send signal for waiting thread */
1513 g_cond_signal(&cb_info->idle_event_cond);
1515 IDLE_EVENT_CALLBACK_DONE:
1516 /* unlock and release event */
1517 g_mutex_unlock(&cam_idle_event->event_mutex);
1518 g_mutex_clear(&cam_idle_event->event_mutex);
1520 g_free(cam_idle_event);
1521 cam_idle_event = NULL;
1526 static void *_camera_msg_handler_func(gpointer data)
1530 camera_message_s *cam_msg = NULL;
1531 camera_idle_event_s *cam_idle_event = NULL;
1532 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1533 camera_cb_info_s *cb_info = NULL;
1535 if (!handler_info || !handler_info->cb_info) {
1536 LOGE("NULL handler %p", handler_info);
1540 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1541 type = handler_info->type;
1543 LOGD("t:%d start", type);
1545 g_mutex_lock(&handler_info->mutex);
1547 while (g_atomic_int_get(&handler_info->running)) {
1548 if (g_queue_is_empty(handler_info->queue)) {
1549 /*LOGD("t:%d signal wait...", type);*/
1550 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1551 /*LOGD("t:%d signal received", type);*/
1553 if (g_atomic_int_get(&handler_info->running) == 0) {
1554 LOGD("t:%d stop event thread", type);
1559 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1561 g_mutex_unlock(&handler_info->mutex);
1563 if (cam_msg == NULL) {
1564 LOGE("t:%d NULL message", type);
1565 g_mutex_lock(&handler_info->mutex);
1571 if (api < MUSE_CAMERA_API_MAX) {
1574 g_mutex_lock(&cb_info->api_mutex[api]);
1576 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1577 cb_info->api_ret[api] = ret;
1578 cb_info->api_activating[api] = 1;
1580 /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
1582 g_cond_signal(&cb_info->api_cond[api]);
1584 LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1587 g_mutex_unlock(&cb_info->api_mutex[api]);
1588 } else if (api == MUSE_CAMERA_CB_EVENT) {
1589 switch (cam_msg->event_class) {
1590 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1591 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event);
1593 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1594 cam_idle_event = g_new0(camera_idle_event_s, 1);
1595 if (cam_idle_event == NULL) {
1596 LOGE("t:%d cam_idle_event alloc failed", type);
1600 cam_idle_event->event = cam_msg->event;
1601 cam_idle_event->cb_info = cb_info;
1602 g_mutex_init(&cam_idle_event->event_mutex);
1603 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg) - 1);
1605 /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, cam_msg->event, cam_idle_event);*/
1607 g_mutex_lock(&cb_info->idle_event_mutex);
1608 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1609 g_mutex_unlock(&cb_info->idle_event_mutex);
1611 g_idle_add_full(G_PRIORITY_DEFAULT,
1612 (GSourceFunc)_camera_idle_event_callback,
1613 (gpointer)cam_idle_event,
1617 LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
1621 LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1627 g_mutex_lock(&handler_info->mutex);
1630 /* remove remained event */
1631 while (!g_queue_is_empty(handler_info->queue)) {
1632 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1634 LOGD("t:%d remove camera message %p", type, cam_msg);
1638 LOGW("t:%d NULL camera message", type);
1642 g_mutex_unlock(&handler_info->mutex);
1644 LOGD("t:%d return", type);
1650 static void _camera_remove_idle_event_all(camera_cb_info_s *cb_info)
1652 camera_idle_event_s *cam_idle_event = NULL;
1653 gboolean ret = TRUE;
1655 gint64 end_time = 0;
1657 if (cb_info == NULL) {
1658 LOGE("cb_info is NULL");
1662 g_mutex_lock(&cb_info->idle_event_mutex);
1664 if (cb_info->idle_event_list == NULL) {
1665 LOGD("No remained idle event");
1666 g_mutex_unlock(&cb_info->idle_event_mutex);
1670 list = cb_info->idle_event_list;
1673 cam_idle_event = list->data;
1674 list = g_list_next(list);
1676 if (!cam_idle_event) {
1677 LOGW("Fail to remove idle event. The event is NULL");
1681 if (g_mutex_trylock(&cam_idle_event->event_mutex)) {
1682 ret = g_idle_remove_by_data(cam_idle_event);
1684 LOGD("remove idle event [%p], ret[%d]", cam_idle_event, ret);
1687 cam_idle_event->cb_info = NULL;
1688 LOGW("idle event %p will be called later", cam_idle_event);
1691 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1693 g_mutex_unlock(&cam_idle_event->event_mutex);
1696 g_mutex_clear(&cam_idle_event->event_mutex);
1698 g_free(cam_idle_event);
1699 cam_idle_event = NULL;
1701 LOGD("remove idle event done");
1707 LOGW("event lock failed. it's being called...");
1709 end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
1711 if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
1712 LOGW("signal received");
1717 g_list_free(cb_info->idle_event_list);
1718 cb_info->idle_event_list = NULL;
1720 g_mutex_unlock(&cb_info->idle_event_mutex);
1726 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg)
1728 camera_message_s *cam_msg = NULL;
1730 if (!cb_info || !msg) {
1731 LOGE("NULL pointer %p %p", cb_info, msg);
1735 cam_msg = g_new0(camera_message_s, 1);
1737 LOGE("failed to alloc cam_msg for [%s]", msg);
1742 cam_msg->event = event;
1743 cam_msg->event_class = event_class;
1745 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1747 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1749 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1750 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1751 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1752 g_cond_signal(&cb_info->preview_cb_info.cond);
1753 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1754 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1755 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1756 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1757 g_cond_signal(&cb_info->capture_cb_info.cond);
1758 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1760 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1761 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1762 g_cond_signal(&cb_info->msg_handler_info.cond);
1763 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1772 static void *_camera_msg_recv_func(gpointer data)
1779 int event_class = 0;
1783 char *error_msg = NULL;
1784 char *recv_msg = NULL;
1785 char **parse_str = NULL;
1786 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
1789 LOGE("cb_info NULL");
1795 parse_str = (char **)malloc(sizeof(char *) * CAMERA_PARSE_STRING_SIZE);
1796 if (parse_str == NULL) {
1797 LOGE("parse_str malloc failed");
1801 for (i = 0 ; i < CAMERA_PARSE_STRING_SIZE ; i++) {
1802 parse_str[i] = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
1803 if (parse_str[i] == NULL) {
1804 LOGE("parse_str[%d] malloc failed", i);
1805 goto CB_HANDLER_EXIT;
1809 recv_msg = cb_info->recv_msg;
1811 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
1812 ret = muse_core_ipc_recv_msg(cb_info->fd, recv_msg);
1814 cb_info->is_server_connected = FALSE;
1815 LOGE("receive msg failed - server disconnected");
1819 recv_msg[ret] = '\0';
1825 /*LOGD("recvMSg : %s, length : %d", recv_msg, ret);*/
1827 /* Need to split the combined entering msgs.
1828 This module supports up to 200 combined msgs. */
1829 for (str_pos = 0; str_pos < ret; str_pos++) {
1830 if (recv_msg[str_pos] == '}') {
1831 strncpy(parse_str[num_token], recv_msg + prev_pos, str_pos - prev_pos + 1);
1832 /*LOGD("splitted msg : [%s], Index : %d", parse_str[num_token], num_token);*/
1833 prev_pos = str_pos + 1;
1838 /*LOGD("num_token : %d", num_token);*/
1840 /* Re-construct to the useful single msg. */
1841 for (i = 0; i < num_token; i++) {
1842 if (i >= CAMERA_PARSE_STRING_SIZE) {
1843 LOGE("invalid token index %d", i);
1852 if (!muse_camera_msg_get(api, parse_str[i])) {
1853 LOGE("failed to get camera api");
1857 if (api == MUSE_CAMERA_CB_EVENT) {
1858 if (!muse_camera_msg_get(event, parse_str[i]) ||
1859 !muse_camera_msg_get(event_class, parse_str[i])) {
1860 LOGE("failed to get camera event or event_class [%s]", parse_str[i]);
1864 if (!muse_camera_msg_get(api_class, parse_str[i])) {
1865 LOGE("failed to get camera api_class [%s]", parse_str[i]);
1870 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1871 if (api >= MUSE_CAMERA_API_MAX) {
1872 LOGE("invalid api %d", api);
1876 g_mutex_lock(&cb_info->api_mutex[api]);
1878 if (!muse_camera_msg_get(ret, parse_str[i])) {
1879 LOGE("failed to get camera ret");
1880 g_mutex_unlock(&cb_info->api_mutex[api]);
1884 cb_info->api_ret[api] = ret;
1885 cb_info->api_activating[api] = 1;
1887 if (api == MUSE_CAMERA_API_CREATE) {
1888 if (ret != CAMERA_ERROR_NONE) {
1889 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1890 LOGE("camera create error 0x%x. close client cb handler", ret);
1892 } else if (api == MUSE_CAMERA_API_DESTROY) {
1893 if (ret == CAMERA_ERROR_NONE) {
1894 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1895 LOGD("camera destroy done. close client cb handler");
1897 } else if (api == MUSE_CAMERA_API_GET_FLASH_STATE ||
1898 api == MUSE_CAMERA_API_GET_DEVICE_STATE) {
1899 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1900 LOGD("get flash or device state done. close client cb handler");
1903 g_cond_signal(&cb_info->api_cond[api]);
1904 g_mutex_unlock(&cb_info->api_mutex[api]);
1905 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
1906 __camera_add_msg_to_queue(cb_info, api, event, event_class, parse_str[i]);
1908 LOGW("unknown camera api %d, class %d", api, api_class);
1914 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
1916 if (!cb_info->is_server_connected) {
1917 /* send error msg for server disconnection */
1918 error_msg = muse_core_msg_json_factory_new(MUSE_CAMERA_CB_EVENT,
1919 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
1920 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
1923 LOGE("error_msg failed");
1924 goto CB_HANDLER_EXIT;
1927 __camera_add_msg_to_queue(cb_info,
1928 MUSE_CAMERA_CB_EVENT,
1929 MUSE_CAMERA_EVENT_TYPE_ERROR,
1930 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
1933 muse_core_msg_json_factory_free(error_msg);
1936 LOGE("add error msg for service disconnection done");
1941 for (i = 0 ; i < CAMERA_PARSE_STRING_SIZE ; i++) {
1944 parse_str[i] = NULL;
1956 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
1957 int type, const char *thread_name, camera_cb_info_s *cb_info)
1959 if (!handler_info || !thread_name || !cb_info) {
1960 LOGE("t:%d NULL %p %p %p",
1961 type, handler_info, thread_name, cb_info);
1967 handler_info->type = type;
1968 handler_info->queue = g_queue_new();
1969 if (handler_info->queue == NULL) {
1970 LOGE("t:%d queue failed", type);
1974 g_mutex_init(&handler_info->mutex);
1975 g_cond_init(&handler_info->cond);
1977 handler_info->cb_info = (void *)cb_info;
1978 g_atomic_int_set(&handler_info->running, 1);
1980 handler_info->thread = g_thread_try_new(thread_name,
1981 _camera_msg_handler_func, (gpointer)handler_info, NULL);
1982 if (handler_info->thread == NULL) {
1983 LOGE("t:%d thread failed", type);
1985 g_mutex_clear(&handler_info->mutex);
1986 g_cond_clear(&handler_info->cond);
1987 g_queue_free(handler_info->queue);
1988 handler_info->queue = NULL;
1993 LOGD("t:%d done", type);
1999 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2003 if (!handler_info) {
2004 LOGE("NULL handler");
2008 if (!handler_info->thread) {
2009 LOGW("thread is not created");
2013 type = handler_info->type;
2015 LOGD("t:%d thread %p", type, handler_info->thread);
2017 g_mutex_lock(&handler_info->mutex);
2018 g_atomic_int_set(&handler_info->running, 0);
2019 g_cond_signal(&handler_info->cond);
2020 g_mutex_unlock(&handler_info->mutex);
2022 g_thread_join(handler_info->thread);
2023 g_thread_unref(handler_info->thread);
2024 handler_info->thread = NULL;
2026 g_mutex_clear(&handler_info->mutex);
2027 g_cond_clear(&handler_info->cond);
2028 g_queue_free(handler_info->queue);
2029 handler_info->queue = NULL;
2031 LOGD("t:%d done", type);
2037 static camera_cb_info_s *_camera_client_callback_new(gint sockfd, bool need_msg_handler_thread)
2039 camera_cb_info_s *cb_info = NULL;
2042 g_return_val_if_fail(sockfd > 0, NULL);
2044 cb_info = g_new0(camera_cb_info_s, 1);
2045 if (cb_info == NULL) {
2046 LOGE("cb_info failed");
2050 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2051 g_mutex_init(&cb_info->api_mutex[i]);
2052 g_cond_init(&cb_info->api_cond[i]);
2055 g_mutex_init(&cb_info->idle_event_mutex);
2056 g_cond_init(&cb_info->idle_event_cond);
2057 g_mutex_init(&cb_info->mp_data_mutex);
2058 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2059 g_mutex_init(&cb_info->evas_mutex);
2060 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2062 if (need_msg_handler_thread) {
2063 /* message handler thread */
2064 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2065 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2066 LOGE("msg_handler_info failed");
2070 /* message handler thread for preview callback */
2071 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2072 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2073 LOGE("preview_cb_info failed");
2077 /* message handler thread for capture callback */
2078 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2079 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2080 LOGE("capture_cb_info failed");
2085 cb_info->fd = sockfd;
2086 cb_info->preview_cb_flag = 0;
2087 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2088 cb_info->evas_info = NULL;
2089 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2091 /* message receive thread */
2092 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2093 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2094 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2095 if (cb_info->msg_recv_thread == NULL) {
2096 LOGE("message receive thread creation failed");
2100 cb_info->is_server_connected = TRUE;
2106 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2107 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2108 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2110 g_mutex_clear(&cb_info->idle_event_mutex);
2111 g_cond_clear(&cb_info->idle_event_cond);
2112 g_mutex_clear(&cb_info->mp_data_mutex);
2113 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2114 g_mutex_clear(&cb_info->evas_mutex);
2115 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2117 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2118 g_mutex_clear(&cb_info->api_mutex[i]);
2119 g_cond_clear(&cb_info->api_cond[i]);
2129 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2133 g_return_if_fail(cb_info != NULL);
2135 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2137 g_thread_join(cb_info->msg_recv_thread);
2138 g_thread_unref(cb_info->msg_recv_thread);
2139 cb_info->msg_recv_thread = NULL;
2141 LOGD("msg_recv thread removed");
2143 /* destroy msg handler threads */
2144 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2145 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2146 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2148 g_mutex_clear(&cb_info->idle_event_mutex);
2149 g_cond_clear(&cb_info->idle_event_cond);
2150 g_mutex_clear(&cb_info->mp_data_mutex);
2151 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2152 g_mutex_clear(&cb_info->evas_mutex);
2153 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2155 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2156 g_mutex_clear(&cb_info->api_mutex[i]);
2157 g_cond_clear(&cb_info->api_cond[i]);
2160 if (cb_info->fd > -1) {
2161 muse_core_connection_close(cb_info->fd);
2165 if (cb_info->bufmgr) {
2166 tbm_bufmgr_deinit(cb_info->bufmgr);
2167 cb_info->bufmgr = NULL;
2169 if (cb_info->pkt_fmt) {
2170 media_format_unref(cb_info->pkt_fmt);
2171 cb_info->pkt_fmt = NULL;
2174 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2175 if (cb_info->evas_info)
2176 mm_evas_renderer_destroy(&cb_info->evas_info);
2177 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2179 cb_info->preview_cb_flag = 0;
2188 int _camera_start_evas_rendering(camera_h camera)
2190 int ret = CAMERA_ERROR_NONE;
2191 camera_cli_s *pc = (camera_cli_s *)camera;
2193 if (!pc || !pc->cb_info) {
2194 LOGE("NULL handle");
2195 return CAMERA_ERROR_INVALID_PARAMETER;
2200 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2201 LOGE("EVAS surface is not set");
2202 return CAMERA_ERROR_NONE;
2205 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2206 g_mutex_lock(&pc->cb_info->evas_mutex);
2208 /* set evas render flag as RUN */
2209 pc->cb_info->run_evas_render = true;
2210 ret = CAMERA_ERROR_NONE;
2212 g_mutex_unlock(&pc->cb_info->evas_mutex);
2213 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2214 LOGW("evas renderer is not supported");
2215 ret = CAMERA_ERROR_NOT_SUPPORTED;
2216 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2222 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2224 int ret = CAMERA_ERROR_NONE;
2225 camera_cli_s *pc = (camera_cli_s *)camera;
2227 if (!pc || !pc->cb_info) {
2228 LOGE("NULL handle");
2229 return CAMERA_ERROR_INVALID_PARAMETER;
2232 LOGD("stop - keep screen %d", keep_screen);
2234 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2235 LOGE("EVAS surface is not set");
2236 return CAMERA_ERROR_NONE;
2239 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2240 g_mutex_lock(&pc->cb_info->evas_mutex);
2242 /* set evas render flag as STOP and release buffers */
2243 pc->cb_info->run_evas_render = false;
2245 ret = mm_evas_renderer_retrieve_all_packets(pc->cb_info->evas_info, keep_screen);
2246 if (ret != MM_ERROR_NONE) {
2247 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2248 ret = CAMERA_ERROR_INVALID_OPERATION;
2251 g_mutex_unlock(&pc->cb_info->evas_mutex);
2252 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2253 LOGW("evas renderer is not supported");
2254 ret = CAMERA_ERROR_NOT_SUPPORTED;
2255 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2261 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2263 int ret = CAMERA_ERROR_NONE;
2267 camera_cli_s *pc = NULL;
2269 /* create muse connection */
2270 if (!key || !value) {
2271 LOGE("NULL pointer");
2272 return CAMERA_ERROR_INVALID_PARAMETER;
2275 sock_fd = muse_core_client_new();
2277 LOGE("muse_core_client_new failed");
2278 return CAMERA_ERROR_INVALID_OPERATION;
2281 msg = muse_core_msg_json_factory_new(api,
2282 MUSE_TYPE_INT, "module", MUSE_CAMERA,
2283 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2287 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2291 send_ret = muse_core_ipc_send_msg(sock_fd, msg);
2293 muse_core_msg_json_factory_free(msg);
2297 LOGE("send msg failed");
2298 ret = CAMERA_ERROR_INVALID_OPERATION;
2302 pc = g_new0(camera_cli_s, 1);
2304 LOGE("handle alloc failed");
2305 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2309 pc->cb_info = _camera_client_callback_new(sock_fd, false);
2311 LOGE("cb_info alloc failed");
2312 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2318 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2320 if (ret == CAMERA_ERROR_NONE)
2321 muse_core_msg_json_deserialize(key, pc->cb_info->recv_msg, NULL, value, NULL, MUSE_TYPE_ANY);
2323 LOGD("api %d - value %d", api, *value);
2326 /* release resources */
2329 _camera_client_callback_destroy(pc->cb_info);
2338 muse_core_connection_close(sock_fd);
2346 int camera_create(camera_device_e device, camera_h *camera)
2349 char *send_msg = NULL;
2351 int ret = CAMERA_ERROR_NONE;
2353 camera_cli_s *pc = NULL;
2354 tbm_bufmgr bufmgr = NULL;
2356 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2357 muse_core_api_module_e muse_module = MUSE_CAMERA;
2358 int device_type = (int)device;
2361 LOGE("NULL pointer");
2362 return CAMERA_ERROR_INVALID_PARAMETER;
2365 sock_fd = muse_core_client_new();
2367 LOGE("muse_core_client_new failed - returned fd %d", sock_fd);
2368 ret = CAMERA_ERROR_INVALID_OPERATION;
2374 send_msg = muse_core_msg_json_factory_new(api,
2375 MUSE_TYPE_INT, "module", muse_module,
2376 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2377 MUSE_TYPE_INT, "pid", pid,
2382 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2386 send_ret = muse_core_ipc_send_msg(sock_fd, send_msg);
2388 muse_core_msg_json_factory_free(send_msg);
2392 LOGE("send msg failed %d", errno);
2393 ret = CAMERA_ERROR_INVALID_OPERATION;
2397 pc = g_new0(camera_cli_s, 1);
2399 LOGE("camera_cli_s alloc failed");
2400 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2404 bufmgr = tbm_bufmgr_init(-1);
2405 if (bufmgr == NULL) {
2406 LOGE("get tbm bufmgr failed");
2407 ret = CAMERA_ERROR_INVALID_OPERATION;
2411 pc->cb_info = _camera_client_callback_new(sock_fd, true);
2412 if (pc->cb_info == NULL) {
2413 LOGE("cb_info alloc failed");
2414 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2420 LOGD("cb info : %d", pc->cb_info->fd);
2422 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2423 if (ret == CAMERA_ERROR_NONE) {
2424 intptr_t handle = 0;
2425 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2427 LOGE("Receiving Handle Failed!!");
2428 ret = CAMERA_ERROR_INVALID_OPERATION;
2432 pc->remote_handle = handle;
2433 pc->cb_info->bufmgr = bufmgr;
2435 ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL);
2436 if (ret != CAMERA_ERROR_NONE) {
2437 LOGE("init display failed 0x%x", ret);
2441 LOGD("camera create 0x%x", pc->remote_handle);
2442 *camera = (camera_h)pc;
2451 tbm_bufmgr_deinit(bufmgr);
2456 muse_core_connection_close(sock_fd);
2462 _camera_client_callback_destroy(pc->cb_info);
2469 LOGE("camera create error : 0x%x", ret);
2475 int camera_change_device(camera_h camera, camera_device_e device)
2477 int ret = CAMERA_ERROR_NONE;
2478 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2479 camera_cli_s *pc = (camera_cli_s *)camera;
2480 camera_msg_param param;
2482 if (!pc || !pc->cb_info) {
2483 LOGE("NULL handle");
2484 return CAMERA_ERROR_INVALID_PARAMETER;
2487 CAMERA_MSG_PARAM_SET(param, INT, device);
2489 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2495 int camera_destroy(camera_h camera)
2497 int ret = CAMERA_ERROR_NONE;
2498 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2499 camera_cli_s *pc = (camera_cli_s *)camera;
2501 if (!pc || !pc->cb_info) {
2502 LOGE("NULL handle");
2503 return CAMERA_ERROR_INVALID_PARAMETER;
2508 if (pc->cb_info->is_server_connected)
2509 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2511 LOGW("server disconnected. release resource without send message.");
2513 if (ret == CAMERA_ERROR_NONE) {
2514 _camera_remove_idle_event_all(pc->cb_info);
2515 _camera_client_callback_destroy(pc->cb_info);
2525 int camera_start_preview(camera_h camera)
2527 int ret = CAMERA_ERROR_NONE;
2528 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2529 camera_cli_s *pc = (camera_cli_s *)camera;
2531 if (!pc || !pc->cb_info) {
2532 LOGE("NULL handle");
2533 return CAMERA_ERROR_INVALID_PARAMETER;
2538 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT_LONG);
2539 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2540 ret = _camera_start_evas_rendering(camera);
2541 if (ret != CAMERA_ERROR_NONE) {
2542 LOGE("stop preview because of error");
2543 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, pc->cb_info, NULL, 0);
2547 LOGD("ret : 0x%x", ret);
2553 int camera_stop_preview(camera_h camera)
2555 int ret = CAMERA_ERROR_NONE;
2556 camera_cli_s *pc = (camera_cli_s *)camera;
2557 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2558 camera_state_e current_state = CAMERA_STATE_NONE;
2560 if (!pc || !pc->cb_info) {
2561 LOGE("NULL handle");
2562 return CAMERA_ERROR_INVALID_PARAMETER;
2567 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2568 ret = camera_get_state(camera, ¤t_state);
2569 if (ret != CAMERA_ERROR_NONE) {
2570 LOGE("failed to get current state 0x%x", ret);
2574 if (current_state == CAMERA_STATE_PREVIEW) {
2575 ret = _camera_stop_evas_rendering(camera, false);
2576 if (ret != CAMERA_ERROR_NONE)
2581 /* send stop preview message */
2582 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2584 if (ret != CAMERA_ERROR_NONE &&
2585 current_state == CAMERA_STATE_PREVIEW) {
2586 LOGW("restart evas rendering");
2587 _camera_start_evas_rendering(camera);
2590 LOGD("ret : 0x%x", ret);
2596 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2598 int ret = CAMERA_ERROR_NONE;
2599 camera_cli_s *pc = (camera_cli_s *)camera;
2600 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2602 if (!pc || !pc->cb_info) {
2603 LOGE("NULL handle");
2604 return CAMERA_ERROR_INVALID_PARAMETER;
2609 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2610 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2612 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2613 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2615 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2617 LOGD("ret : 0x%x", ret);
2623 bool camera_is_supported_continuous_capture(camera_h camera)
2625 int ret = CAMERA_ERROR_NONE;
2626 camera_cli_s *pc = (camera_cli_s *)camera;
2627 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2629 if (!pc || !pc->cb_info) {
2630 LOGE("NULL handle");
2631 return CAMERA_ERROR_INVALID_PARAMETER;
2636 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2639 LOGE("error is occurred 0x%x", ret);
2643 LOGD("ret : %d", ret);
2649 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)
2651 int ret = CAMERA_ERROR_NONE;
2652 camera_cli_s *pc = (camera_cli_s *)camera;
2653 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2654 camera_msg_param param;
2657 if (!pc || !pc->cb_info) {
2658 LOGE("NULL handle");
2659 return CAMERA_ERROR_INVALID_PARAMETER;
2664 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2665 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2666 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2668 value = (count << 16) | interval;
2669 CAMERA_MSG_PARAM_SET(param, INT, value);
2671 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2673 LOGD("ret : 0x%x", ret);
2679 int camera_stop_continuous_capture(camera_h camera)
2681 int ret = CAMERA_ERROR_NONE;
2682 camera_cli_s *pc = (camera_cli_s *)camera;
2683 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2685 if (!pc || !pc->cb_info) {
2686 LOGE("NULL handle");
2687 return CAMERA_ERROR_INVALID_PARAMETER;
2692 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2694 LOGD("ret : 0x%x", ret);
2700 bool camera_is_supported_face_detection(camera_h camera)
2702 int ret = CAMERA_ERROR_NONE;
2703 camera_cli_s *pc = (camera_cli_s *)camera;
2704 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2706 if (!pc || !pc->cb_info) {
2707 LOGE("NULL handle");
2708 return CAMERA_ERROR_INVALID_PARAMETER;
2713 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2716 LOGE("error is occurred 0x%x", ret);
2720 LOGD("ret : %d", ret);
2726 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2728 int ret = CAMERA_ERROR_NONE;
2729 camera_cli_s *pc = (camera_cli_s *)camera;
2730 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2732 if (!pc || !pc->cb_info) {
2733 LOGE("NULL handle");
2734 return CAMERA_ERROR_INVALID_PARAMETER;
2739 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2742 LOGE("error is occurred 0x%x", ret);
2746 LOGD("ret : %d", ret);
2752 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2754 int ret = CAMERA_ERROR_NONE;
2755 camera_cli_s *pc = (camera_cli_s *)camera;
2756 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2758 if (!pc || !pc->cb_info) {
2759 LOGE("NULL handle");
2760 return CAMERA_ERROR_INVALID_PARAMETER;
2765 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2768 LOGE("error is occurred 0x%x", ret);
2772 LOGD("ret : %d", ret);
2777 int camera_get_device_count(camera_h camera, int *device_count)
2779 int ret = CAMERA_ERROR_NONE;
2780 camera_cli_s *pc = (camera_cli_s *)camera;
2781 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2782 int get_device_count = 0;
2784 if (!pc || !pc->cb_info) {
2785 LOGE("NULL handle");
2786 return CAMERA_ERROR_INVALID_PARAMETER;
2791 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2793 if (ret == CAMERA_ERROR_NONE) {
2794 muse_camera_msg_get(get_device_count, pc->cb_info->recv_msg);
2795 *device_count = get_device_count;
2798 LOGD("ret : 0x%x", ret);
2803 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2805 int ret = CAMERA_ERROR_NONE;
2806 camera_cli_s *pc = (camera_cli_s *)camera;
2807 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2809 if (!pc || !pc->cb_info) {
2810 LOGE("NULL handle");
2811 return CAMERA_ERROR_INVALID_PARAMETER;
2816 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2817 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2819 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2821 LOGD("ret : 0x%x", ret);
2826 int camera_stop_face_detection(camera_h camera)
2828 int ret = CAMERA_ERROR_NONE;
2829 camera_cli_s *pc = (camera_cli_s *)camera;
2830 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
2832 if (!pc || !pc->cb_info) {
2833 LOGE("NULL handle");
2834 return CAMERA_ERROR_INVALID_PARAMETER;
2839 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2841 LOGD("ret : 0x%x", ret);
2846 int camera_get_state(camera_h camera, camera_state_e *state)
2848 int ret = CAMERA_ERROR_NONE;
2849 camera_cli_s *pc = (camera_cli_s *)camera;
2850 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
2851 int get_state = CAMERA_STATE_NONE;
2853 if (!pc || !pc->cb_info || !state) {
2854 LOGE("NULL pointer %p %p", pc, state);
2855 return CAMERA_ERROR_INVALID_PARAMETER;
2860 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2862 if (ret == CAMERA_ERROR_NONE) {
2863 muse_camera_msg_get(get_state, pc->cb_info->recv_msg);
2864 *state = (camera_state_e)get_state;
2867 LOGD("ret : 0x%x", ret);
2872 int camera_start_focusing(camera_h camera, bool continuous)
2874 int ret = CAMERA_ERROR_NONE;
2875 camera_cli_s *pc = (camera_cli_s *)camera;
2876 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
2877 camera_msg_param param;
2878 int is_continuous = (int)continuous;
2880 if (!pc || !pc->cb_info) {
2881 LOGE("NULL handle");
2882 return CAMERA_ERROR_INVALID_PARAMETER;
2887 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
2889 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2891 LOGD("ret : 0x%x", ret);
2896 int camera_cancel_focusing(camera_h camera)
2898 int ret = CAMERA_ERROR_NONE;
2899 camera_cli_s *pc = (camera_cli_s *)camera;
2900 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
2902 if (!pc || !pc->cb_info) {
2903 LOGE("NULL handle");
2904 return CAMERA_ERROR_INVALID_PARAMETER;
2907 LOGD("Enter, remote_handle : %x", pc->remote_handle);
2909 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2911 LOGD("ret : 0x%x", ret);
2916 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
2918 int ret = CAMERA_ERROR_NONE;
2919 void *set_display_handle = NULL;
2920 Evas_Object *obj = NULL;
2921 const char *object_type = NULL;
2922 camera_cli_s *pc = (camera_cli_s *)camera;
2923 camera_cb_info_s *cb_info = NULL;
2924 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
2925 camera_state_e current_state = CAMERA_STATE_NONE;
2926 camera_msg_param param;
2930 if (!pc || !pc->cb_info) {
2931 LOGE("NULL handle");
2932 return CAMERA_ERROR_INVALID_PARAMETER;
2935 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
2936 LOGE("invalid type %d", type);
2937 return CAMERA_ERROR_INVALID_PARAMETER;
2940 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
2941 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
2942 return CAMERA_ERROR_INVALID_PARAMETER;
2945 cb_info = (camera_cb_info_s *)pc->cb_info;
2947 ret = camera_get_state(camera, ¤t_state);
2948 if (ret != CAMERA_ERROR_NONE) {
2949 LOGE("failed to get current state 0x%x", ret);
2953 if (current_state != CAMERA_STATE_CREATED) {
2954 LOGE("INVALID_STATE : current %d", current_state);
2955 return CAMERA_ERROR_INVALID_STATE;
2958 LOGD("Enter - display : %p", display);
2960 if (type == CAMERA_DISPLAY_TYPE_NONE) {
2961 set_display_handle = 0;
2962 LOGD("display type NONE");
2964 obj = (Evas_Object *)display;
2965 object_type = evas_object_type_get(obj);
2967 if (type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
2968 /* get wayland parent id */
2969 if (_camera_get_wl_info(obj, &pc->wl_info) != CAMERA_ERROR_NONE) {
2970 LOGE("failed to get wayland info");
2971 return CAMERA_ERROR_INVALID_OPERATION;
2974 set_display_handle = (void *)&pc->wl_info;
2975 LOGD("display type OVERLAY : handle %p", set_display_handle);
2976 } else if (type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
2977 /* evas object surface */
2978 set_display_handle = (void *)display;
2979 LOGD("display type EVAS : handle %p", set_display_handle);
2981 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2982 g_mutex_lock(&cb_info->evas_mutex);
2984 if (cb_info->evas_info) {
2985 LOGW("destroy existed evas renderer %p", cb_info->evas_info);
2986 ret = mm_evas_renderer_destroy(&cb_info->evas_info);
2987 if (ret != MM_ERROR_NONE) {
2988 LOGE("failed to destroy evas renderer %p", cb_info->evas_info);
2989 g_mutex_unlock(&cb_info->evas_mutex);
2990 return CAMERA_ERROR_INVALID_OPERATION;
2994 /* create evas renderer */
2995 ret = mm_evas_renderer_create(&cb_info->evas_info, (Evas_Object *)set_display_handle);
2996 if (ret == MM_ERROR_NONE) {
2997 camera_flip_e flip = CAMERA_FLIP_NONE;
2998 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
2999 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3006 camera_get_display_flip(camera, &flip);
3007 camera_get_display_mode(camera, &mode);
3008 camera_get_display_rotation(camera, &rotation);
3009 camera_is_display_visible(camera, &visible);
3010 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3012 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
3013 flip, mode, rotation, visible, x, y, width, height);
3015 ret = mm_evas_renderer_set_flip(cb_info->evas_info, flip);
3016 ret |= mm_evas_renderer_set_geometry(cb_info->evas_info, mode);
3017 ret |= mm_evas_renderer_set_rotation(cb_info->evas_info, rotation);
3018 ret |= mm_evas_renderer_set_visible(cb_info->evas_info, visible);
3020 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
3021 ret |= mm_evas_renderer_set_roi_area(cb_info->evas_info, x, y, width, height);
3024 g_mutex_unlock(&cb_info->evas_mutex);
3026 if (ret != MM_ERROR_NONE) {
3027 LOGE("mm_evas_renderer error 0x%x", ret);
3028 return CAMERA_ERROR_INVALID_OPERATION;
3030 #else /* TIZEN_FEATURE_EVAS_RENDERER */
3031 LOGE("EVAS surface is not supported");
3032 return CAMERA_ERROR_NOT_SUPPORTED;
3033 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3035 LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type);
3036 return CAMERA_ERROR_INVALID_PARAMETER;
3039 LOGE("failed to get evas object type from %p", obj);
3040 return CAMERA_ERROR_INVALID_PARAMETER;
3044 pc->display_handle = (intptr_t)set_display_handle;
3046 if (type == CAMERA_DISPLAY_TYPE_OVERLAY) {
3049 length = sizeof(camera_wl_info_s) / sizeof(int) + \
3050 (sizeof(camera_wl_info_s) % sizeof(int) ? 1 : 0);
3052 msg = muse_core_msg_json_factory_new(api,
3053 MUSE_TYPE_INT, "type", type,
3054 MUSE_TYPE_ARRAY, "wl_info", length, (int *)&pc->wl_info,
3057 LOGE("msg creation failed: api %d", api);
3058 return CAMERA_ERROR_OUT_OF_MEMORY;
3061 if (pc->cb_info->is_server_connected)
3062 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
3065 LOGE("message send failed");
3066 ret = CAMERA_ERROR_INVALID_OPERATION;
3068 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
3071 muse_core_msg_json_factory_free(msg);
3073 LOGD("wayland parent id : %d, window %d,%d,%dx%d",
3074 pc->wl_info.parent_id, pc->wl_info.window_x, pc->wl_info.window_y,
3075 pc->wl_info.window_width, pc->wl_info.window_height);
3077 CAMERA_MSG_PARAM_SET(param, INT, type);
3079 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3082 if (ret != CAMERA_ERROR_NONE)
3083 LOGE("set display error 0x%x", ret);
3084 else if (type == CAMERA_DISPLAY_TYPE_EVAS)
3085 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3091 int camera_set_preview_resolution(camera_h camera, int width, int height)
3093 int ret = CAMERA_ERROR_NONE;
3094 camera_cli_s *pc = (camera_cli_s *)camera;
3095 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3096 camera_msg_param param;
3099 if (!pc || !pc->cb_info) {
3100 LOGE("NULL handle");
3101 return CAMERA_ERROR_INVALID_PARAMETER;
3104 value = (width << 16) | height;
3105 CAMERA_MSG_PARAM_SET(param, INT, value);
3107 LOGD("%dx%d -> 0x%x", width, height, value);
3109 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3111 LOGD("ret : 0x%x", ret);
3117 int camera_set_capture_resolution(camera_h camera, int width, int height)
3119 int ret = CAMERA_ERROR_NONE;
3120 camera_cli_s *pc = (camera_cli_s *)camera;
3121 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3122 camera_msg_param param;
3125 if (!pc || !pc->cb_info) {
3126 LOGE("NULL handle");
3127 return CAMERA_ERROR_INVALID_PARAMETER;
3132 value = (width << 16) | height;
3133 CAMERA_MSG_PARAM_SET(param, INT, value);
3135 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3137 LOGD("ret : 0x%x", ret);
3143 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3145 int ret = CAMERA_ERROR_NONE;
3146 int set_format = (int)format;
3147 camera_cli_s *pc = (camera_cli_s *)camera;
3148 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3149 camera_msg_param param;
3151 if (!pc || !pc->cb_info) {
3152 LOGE("NULL handle");
3153 return CAMERA_ERROR_INVALID_PARAMETER;
3156 LOGD("Enter - format %d", set_format);
3158 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3160 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3162 LOGD("ret : 0x%x", ret);
3168 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3170 int ret = CAMERA_ERROR_NONE;
3171 int set_format = (int)format;
3172 camera_msg_param param;
3173 camera_cli_s *pc = (camera_cli_s *)camera;
3174 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3176 if (!pc || !pc->cb_info) {
3177 LOGE("NULL handle");
3178 return CAMERA_ERROR_INVALID_PARAMETER;
3181 LOGD("Enter - capture_format %d", set_format);
3183 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3185 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3187 LOGD("ret : 0x%x", ret);
3193 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3195 int ret = CAMERA_ERROR_NONE;
3196 camera_cli_s *pc = (camera_cli_s *)camera;
3197 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3201 if (!pc || !pc->cb_info || !width || !height) {
3202 LOGE("NULL pointer %p %p %p", pc, width, height);
3203 return CAMERA_ERROR_INVALID_PARAMETER;
3208 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3210 if (ret == CAMERA_ERROR_NONE) {
3211 muse_camera_msg_get(get_width, pc->cb_info->recv_msg);
3212 muse_camera_msg_get(get_height, pc->cb_info->recv_msg);
3214 *height = get_height;
3217 LOGD("ret : 0x%x", ret);
3223 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3225 int ret = CAMERA_ERROR_NONE;
3226 int set_rotation = (int)rotation;
3227 camera_cli_s *pc = (camera_cli_s *)camera;
3228 camera_msg_param param;
3230 if (!pc || !pc->cb_info) {
3231 LOGE("NULL handle");
3232 return CAMERA_ERROR_INVALID_PARAMETER;
3235 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3236 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3237 g_mutex_lock(&pc->cb_info->evas_mutex);
3239 ret = mm_evas_renderer_set_rotation(pc->cb_info->evas_info, rotation);
3241 g_mutex_unlock(&pc->cb_info->evas_mutex);
3243 if (ret != MM_ERROR_NONE) {
3244 LOGE("failed to set rotation for evas surface 0x%x", ret);
3245 return CAMERA_ERROR_INVALID_OPERATION;
3248 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3250 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3252 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3258 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3260 int ret = CAMERA_ERROR_NONE;
3261 int get_rotation = CAMERA_ROTATION_NONE;
3262 camera_cli_s *pc = (camera_cli_s *)camera;
3264 if (!pc || !pc->cb_info || !rotation) {
3265 LOGE("NULL pointer %p %p", pc, rotation);
3266 return CAMERA_ERROR_INVALID_PARAMETER;
3269 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3271 if (ret == CAMERA_ERROR_NONE) {
3272 muse_camera_msg_get(get_rotation, pc->cb_info->recv_msg);
3273 *rotation = (camera_rotation_e)get_rotation;
3280 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3282 int ret = CAMERA_ERROR_NONE;
3283 int set_flip = (int)flip;
3284 camera_cli_s *pc = (camera_cli_s *)camera;
3285 camera_msg_param param;
3287 if (!pc || !pc->cb_info) {
3288 LOGE("NULL handle");
3289 return CAMERA_ERROR_INVALID_PARAMETER;
3292 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3293 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3294 g_mutex_lock(&pc->cb_info->evas_mutex);
3296 ret = mm_evas_renderer_set_flip(pc->cb_info->evas_info, flip);
3298 g_mutex_unlock(&pc->cb_info->evas_mutex);
3300 if (ret != MM_ERROR_NONE) {
3301 LOGE("failed to set flip for evas surface 0x%x", ret);
3302 return CAMERA_ERROR_INVALID_OPERATION;
3305 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3307 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3309 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3315 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3317 int ret = CAMERA_ERROR_NONE;
3318 int get_flip = CAMERA_FLIP_NONE;
3319 camera_cli_s *pc = (camera_cli_s *)camera;
3321 if (!pc || !pc->cb_info || !flip) {
3322 LOGE("NULL pointer %p %p", pc, flip);
3323 return CAMERA_ERROR_INVALID_PARAMETER;
3326 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3328 if (ret == CAMERA_ERROR_NONE) {
3329 muse_camera_msg_get(get_flip, pc->cb_info->recv_msg);
3330 *flip = (camera_flip_e)get_flip;
3337 int camera_set_display_visible(camera_h camera, bool visible)
3339 int ret = CAMERA_ERROR_NONE;
3340 int set_visible = (int)visible;
3341 camera_cli_s *pc = (camera_cli_s *)camera;
3342 camera_msg_param param;
3344 if (!pc || !pc->cb_info) {
3345 LOGE("NULL handle");
3346 return CAMERA_ERROR_INVALID_PARAMETER;
3349 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3350 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3351 g_mutex_lock(&pc->cb_info->evas_mutex);
3353 ret = mm_evas_renderer_set_visible(pc->cb_info->evas_info, visible);
3355 g_mutex_unlock(&pc->cb_info->evas_mutex);
3357 if (ret != MM_ERROR_NONE) {
3358 LOGE("failed to set visible for evas surface 0x%x", ret);
3359 return CAMERA_ERROR_INVALID_OPERATION;
3362 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3364 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3366 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3372 int camera_is_display_visible(camera_h camera, bool *visible)
3374 int ret = CAMERA_ERROR_NONE;
3375 int get_visible = true;
3376 camera_cli_s *pc = (camera_cli_s *)camera;
3378 if (!pc || !pc->cb_info || !visible) {
3379 LOGE("NULL pointer %p %p", pc, visible);
3380 return CAMERA_ERROR_INVALID_PARAMETER;
3383 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3385 if (ret == CAMERA_ERROR_NONE) {
3386 muse_camera_msg_get(get_visible, pc->cb_info->recv_msg);
3387 *visible = (bool)get_visible;
3394 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3396 int ret = CAMERA_ERROR_NONE;
3397 int set_mode = (int)mode;
3398 camera_cli_s *pc = (camera_cli_s *)camera;
3399 camera_msg_param param;
3401 if (!pc || !pc->cb_info) {
3402 LOGE("NULL handle");
3403 return CAMERA_ERROR_INVALID_PARAMETER;
3406 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3407 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3408 g_mutex_lock(&pc->cb_info->evas_mutex);
3410 ret = mm_evas_renderer_set_geometry(pc->cb_info->evas_info, mode);
3412 g_mutex_unlock(&pc->cb_info->evas_mutex);
3414 if (ret != MM_ERROR_NONE) {
3415 LOGE("failed to set geometry for evas surface 0x%x", ret);
3416 return CAMERA_ERROR_INVALID_OPERATION;
3419 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3421 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3423 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3429 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3431 int ret = CAMERA_ERROR_NONE;
3432 int get_mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3433 camera_cli_s *pc = (camera_cli_s *)camera;
3435 if (!pc || !pc->cb_info || !mode) {
3436 LOGE("NULL pointer %p %p", pc, mode);
3437 return CAMERA_ERROR_INVALID_PARAMETER;
3440 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3442 if (ret == CAMERA_ERROR_NONE) {
3443 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
3444 *mode = (camera_display_mode_e)get_mode;
3451 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3453 int ret = CAMERA_ERROR_NONE;
3454 int set_hint = (int)hint;
3455 camera_cli_s *pc = (camera_cli_s *)camera;
3456 camera_msg_param param;
3458 if (!pc || !pc->cb_info) {
3459 LOGE("NULL handle");
3460 return CAMERA_ERROR_INVALID_PARAMETER;
3463 LOGD("Enter - hint %d", set_hint);
3465 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3467 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3473 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3475 int ret = CAMERA_ERROR_NONE;
3477 camera_cli_s *pc = (camera_cli_s *)camera;
3478 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3480 if (!pc || !pc->cb_info || !hint) {
3481 LOGE("NULL pointer %p %p", pc, hint);
3482 return CAMERA_ERROR_INVALID_PARAMETER;
3485 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3487 if (ret == CAMERA_ERROR_NONE) {
3488 muse_camera_msg_get(get_hint, pc->cb_info->recv_msg);
3489 *hint = (bool)get_hint;
3491 LOGD("display reuse hint %d", *hint);
3498 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3500 int ret = CAMERA_ERROR_NONE;
3501 camera_cli_s *pc = (camera_cli_s *)camera;
3502 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3506 if (!pc || !pc->cb_info || !width || !height) {
3507 LOGE("NULL pointer %p %p %p", pc, width, height);
3508 return CAMERA_ERROR_INVALID_PARAMETER;
3513 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3515 if (ret == CAMERA_ERROR_NONE) {
3516 muse_camera_msg_get(get_width, pc->cb_info->recv_msg);
3517 muse_camera_msg_get(get_height, pc->cb_info->recv_msg);
3519 *height = get_height;
3522 LOGD("ret : 0x%x", ret);
3528 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3530 int ret = CAMERA_ERROR_NONE;
3531 camera_cli_s *pc = (camera_cli_s *)camera;
3532 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3535 if (!pc || !pc->cb_info || !format) {
3536 LOGE("NULL pointer %p %p", pc, format);
3537 return CAMERA_ERROR_INVALID_PARAMETER;
3542 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3544 if (ret == CAMERA_ERROR_NONE) {
3545 muse_camera_msg_get(get_format, pc->cb_info->recv_msg);
3546 *format = (camera_pixel_format_e)get_format;
3549 LOGD("ret : 0x%x", ret);
3555 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3557 int ret = CAMERA_ERROR_NONE;
3558 camera_cli_s *pc = (camera_cli_s *)camera;
3559 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3562 if (!pc || !pc->cb_info || !format) {
3563 LOGE("NULL pointer %p %p", pc, format);
3564 return CAMERA_ERROR_INVALID_PARAMETER;
3569 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3571 if (ret == CAMERA_ERROR_NONE) {
3572 muse_camera_msg_get(get_format, pc->cb_info->recv_msg);
3573 *format = (camera_pixel_format_e)get_format;
3576 LOGD("ret : 0x%x", ret);
3582 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3584 int ret = CAMERA_ERROR_NONE;
3585 camera_cli_s *pc = (camera_cli_s *)camera;
3586 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3587 int get_facing_direction = 0;
3589 if (!pc || !pc->cb_info || !facing_direction) {
3590 LOGE("NULL pointer %p %p", pc, facing_direction);
3591 return CAMERA_ERROR_INVALID_PARAMETER;
3596 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3598 if (ret == CAMERA_ERROR_NONE) {
3599 muse_camera_msg_get(get_facing_direction, pc->cb_info->recv_msg);
3600 *facing_direction = (camera_facing_direction_e)get_facing_direction;
3603 LOGD("ret : 0x%x", ret);
3609 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3611 int ret = CAMERA_ERROR_NONE;
3612 camera_cli_s *pc = (camera_cli_s *)camera;
3613 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3615 if (!pc || !pc->cb_info || !callback) {
3616 LOGE("NULL pointer %p %p", pc, callback);
3617 return CAMERA_ERROR_INVALID_PARAMETER;
3622 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3624 if (ret == CAMERA_ERROR_NONE) {
3625 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3626 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3627 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3630 LOGD("ret : 0x%x", ret);
3636 int camera_unset_preview_cb(camera_h camera)
3638 int ret = CAMERA_ERROR_NONE;
3639 camera_cli_s *pc = (camera_cli_s *)camera;
3640 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3642 if (!pc || !pc->cb_info) {
3643 LOGE("NULL handle");
3644 return CAMERA_ERROR_INVALID_PARAMETER;
3649 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3650 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3652 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3654 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3656 LOGD("ret : 0x%x", ret);
3662 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3664 int ret = CAMERA_ERROR_NONE;
3665 camera_cli_s *pc = (camera_cli_s *)camera;
3666 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3668 if (!pc || !pc->cb_info) {
3669 LOGE("NULL handle");
3670 return CAMERA_ERROR_INVALID_PARAMETER;
3673 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3674 LOGE("NOT SUPPORTED");
3675 return CAMERA_ERROR_NOT_SUPPORTED;
3678 if (callback == NULL) {
3679 LOGE("NULL callback");
3680 return CAMERA_ERROR_INVALID_PARAMETER;
3685 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3687 if (ret == CAMERA_ERROR_NONE) {
3688 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3689 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3692 LOGD("ret : 0x%x", ret);
3698 int camera_unset_media_packet_preview_cb(camera_h camera)
3700 int ret = CAMERA_ERROR_NONE;
3701 camera_cli_s *pc = (camera_cli_s *)camera;
3702 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3704 if (!pc || !pc->cb_info) {
3705 LOGE("NULL handle");
3706 return CAMERA_ERROR_INVALID_PARAMETER;
3711 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3712 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3714 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3716 LOGD("ret : 0x%x", ret);
3722 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3724 int ret = CAMERA_ERROR_NONE;
3725 camera_cli_s *pc = (camera_cli_s *)camera;
3726 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3728 if (!pc || !pc->cb_info || !callback) {
3729 LOGE("NULL pointer %p %p", pc, callback);
3730 return CAMERA_ERROR_INVALID_PARAMETER;
3735 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3737 if (ret == CAMERA_ERROR_NONE) {
3738 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3739 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3742 LOGD("ret : 0x%x", ret);
3748 int camera_unset_state_changed_cb(camera_h camera)
3750 int ret = CAMERA_ERROR_NONE;
3751 camera_cli_s *pc = (camera_cli_s *)camera;
3752 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3754 if (!pc || !pc->cb_info) {
3755 LOGE("NULL handle");
3756 return CAMERA_ERROR_INVALID_PARAMETER;
3761 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3762 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3764 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3766 LOGD("ret : 0x%x", ret);
3772 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3774 int ret = CAMERA_ERROR_NONE;
3775 camera_cli_s *pc = (camera_cli_s *)camera;
3776 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3778 if (!pc || !pc->cb_info || !callback) {
3779 LOGE("NULL pointer %p %p", pc, callback);
3780 return CAMERA_ERROR_INVALID_PARAMETER;
3785 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3787 if (ret == CAMERA_ERROR_NONE) {
3788 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3789 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3792 LOGD("ret : 0x%x", ret);
3798 int camera_unset_interrupted_cb(camera_h camera)
3800 int ret = CAMERA_ERROR_NONE;
3801 camera_cli_s *pc = (camera_cli_s *)camera;
3802 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3804 if (!pc || !pc->cb_info) {
3805 LOGE("NULL handle");
3806 return CAMERA_ERROR_INVALID_PARAMETER;
3811 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3812 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3814 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3816 LOGD("ret : 0x%x", ret);
3822 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
3824 int ret = CAMERA_ERROR_NONE;
3825 camera_cli_s *pc = (camera_cli_s *)camera;
3826 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3828 if (!pc || !pc->cb_info || !callback) {
3829 LOGE("NULL pointer %p %p", pc, callback);
3830 return CAMERA_ERROR_INVALID_PARAMETER;
3835 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3837 if (ret == CAMERA_ERROR_NONE) {
3838 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3839 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3842 LOGD("ret : 0x%x", ret);
3848 int camera_unset_focus_changed_cb(camera_h camera)
3850 int ret = CAMERA_ERROR_NONE;
3851 camera_cli_s *pc = (camera_cli_s *)camera;
3852 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
3854 if (!pc || !pc->cb_info) {
3855 LOGE("NULL handle");
3856 return CAMERA_ERROR_INVALID_PARAMETER;
3861 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3862 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3864 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3866 LOGD("ret : 0x%x", ret);
3872 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
3874 int ret = CAMERA_ERROR_NONE;
3875 camera_cli_s *pc = (camera_cli_s *)camera;
3876 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
3878 if (!pc || !pc->cb_info || !callback) {
3879 LOGE("NULL pointer %p %p", pc, callback);
3880 return CAMERA_ERROR_INVALID_PARAMETER;
3885 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3887 if (ret == CAMERA_ERROR_NONE) {
3888 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
3889 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
3892 LOGD("ret : 0x%x", ret);
3898 int camera_unset_error_cb(camera_h camera)
3900 int ret = CAMERA_ERROR_NONE;
3901 camera_cli_s *pc = (camera_cli_s *)camera;
3902 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
3904 if (!pc || !pc->cb_info) {
3905 LOGE("NULL handle");
3906 return CAMERA_ERROR_INVALID_PARAMETER;
3911 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
3912 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
3914 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3916 LOGD("ret : 0x%x", ret);
3922 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
3924 int ret = CAMERA_ERROR_NONE;
3925 camera_cli_s *pc = (camera_cli_s *)camera;
3926 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
3928 if (!pc || !pc->cb_info || !foreach_cb) {
3929 LOGE("NULL pointer %p %p", pc, foreach_cb);
3930 return CAMERA_ERROR_INVALID_PARAMETER;
3935 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
3936 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
3938 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3940 LOGD("ret : 0x%x", ret);
3946 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
3948 int ret = CAMERA_ERROR_NONE;
3949 camera_cli_s *pc = (camera_cli_s *)camera;
3950 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
3952 if (!pc || !pc->cb_info || !foreach_cb) {
3953 LOGE("NULL pointer %p %p", pc, foreach_cb);
3954 return CAMERA_ERROR_INVALID_PARAMETER;
3959 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
3960 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
3962 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3964 LOGD("ret : 0x%x", ret);
3970 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
3972 int ret = CAMERA_ERROR_NONE;
3973 camera_cli_s *pc = (camera_cli_s *)camera;
3974 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
3976 if (!pc || !pc->cb_info || !foreach_cb) {
3977 LOGE("NULL pointer %p %p", pc, foreach_cb);
3978 return CAMERA_ERROR_INVALID_PARAMETER;
3983 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
3984 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
3986 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3988 LOGD("ret : 0x%x", ret);
3994 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
3996 int ret = CAMERA_ERROR_NONE;
3997 camera_cli_s *pc = (camera_cli_s *)camera;
3998 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4000 if (!pc || !pc->cb_info || !foreach_cb) {
4001 LOGE("NULL pointer %p %p", pc, foreach_cb);
4002 return CAMERA_ERROR_INVALID_PARAMETER;
4007 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4008 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4010 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4012 LOGD("ret : 0x%x", ret);
4018 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4020 int ret = CAMERA_ERROR_NONE;
4021 camera_cli_s *pc = (camera_cli_s *)camera;
4022 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4026 if (!pc || !pc->cb_info || !width || !height) {
4027 LOGE("NULL pointer %p %p %p", pc, width, height);
4028 return CAMERA_ERROR_INVALID_PARAMETER;
4032 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4034 if (ret == CAMERA_ERROR_NONE) {
4035 muse_camera_msg_get(get_width, pc->cb_info->recv_msg);
4036 muse_camera_msg_get(get_height, pc->cb_info->recv_msg);
4038 *height = get_height;
4041 LOGD("ret : 0x%x", ret);
4047 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4049 int ret = CAMERA_ERROR_NONE;
4050 camera_cli_s *pc = (camera_cli_s *)camera;
4051 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4054 if (!pc || !pc->cb_info || !angle) {
4055 LOGE("NULL pointer %p %p", pc, angle);
4056 return CAMERA_ERROR_INVALID_PARAMETER;
4061 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4063 if (ret == CAMERA_ERROR_NONE) {
4064 muse_camera_msg_get(get_angle, pc->cb_info->recv_msg);
4068 LOGD("ret : 0x%x", ret);
4074 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4076 int ret = CAMERA_ERROR_NONE;
4077 camera_cli_s *pc = (camera_cli_s *)camera;
4078 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4079 camera_msg_param param;
4080 int set_mode = (int)mode;
4082 if (!pc || !pc->cb_info) {
4083 LOGE("NULL handle");
4084 return CAMERA_ERROR_INVALID_PARAMETER;
4089 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4091 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4093 LOGD("ret : 0x%x", ret);
4099 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4101 int ret = CAMERA_ERROR_NONE;
4102 camera_cli_s *pc = (camera_cli_s *)camera;
4103 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4106 if (!pc || !pc->cb_info || !mode) {
4107 LOGE("NULL pointer %p %p", pc, mode);
4108 return CAMERA_ERROR_INVALID_PARAMETER;
4113 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4115 if (ret == CAMERA_ERROR_NONE) {
4116 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
4117 *mode = (camera_attr_theater_mode_e)get_mode;
4120 LOGD("ret : 0x%x", ret);
4126 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4128 int ret = CAMERA_ERROR_NONE;
4129 camera_cli_s *pc = (camera_cli_s *)camera;
4130 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4132 if (!pc || !pc->cb_info || !foreach_cb) {
4133 LOGE("NULL pointer %p %p", pc, foreach_cb);
4134 return CAMERA_ERROR_INVALID_PARAMETER;
4139 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4140 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4142 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4144 LOGD("Finish, return :%x", ret);
4150 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4152 int ret = CAMERA_ERROR_NONE;
4153 camera_cli_s *pc = (camera_cli_s *)camera;
4154 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4155 camera_msg_param param;
4156 int set_fps = (int)fps;
4158 if (!pc || !pc->cb_info) {
4159 LOGE("NULL handle");
4160 return CAMERA_ERROR_INVALID_PARAMETER;
4165 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4167 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4169 LOGD("ret : 0x%x", ret);
4175 int camera_attr_set_image_quality(camera_h camera, int quality)
4177 int ret = CAMERA_ERROR_NONE;
4178 camera_cli_s *pc = (camera_cli_s *)camera;
4179 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4180 camera_msg_param param;
4182 if (!pc || !pc->cb_info) {
4183 LOGE("NULL handle");
4184 return CAMERA_ERROR_INVALID_PARAMETER;
4189 CAMERA_MSG_PARAM_SET(param, INT, quality);
4191 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4193 LOGD("ret : 0x%x", ret);
4199 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4201 int ret = CAMERA_ERROR_NONE;
4202 camera_cli_s *pc = (camera_cli_s *)camera;
4203 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4206 if (!pc || !pc->cb_info || !fps) {
4207 LOGE("NULL pointer %p %p", pc, fps);
4208 return CAMERA_ERROR_INVALID_PARAMETER;
4213 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4215 if (ret == CAMERA_ERROR_NONE) {
4216 muse_camera_msg_get(get_fps, pc->cb_info->recv_msg);
4217 *fps = (camera_attr_fps_e)get_fps;
4220 LOGD("ret : 0x%x", ret);
4226 int camera_attr_get_image_quality(camera_h camera, int *quality)
4228 int ret = CAMERA_ERROR_NONE;
4229 camera_cli_s *pc = (camera_cli_s *)camera;
4230 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4231 int get_quality = 0;
4233 if (!pc || !pc->cb_info || !quality) {
4234 LOGE("NULL pointer %p %p", pc, quality);
4235 return CAMERA_ERROR_INVALID_PARAMETER;
4240 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4242 if (ret == CAMERA_ERROR_NONE) {
4243 muse_camera_msg_get(get_quality, pc->cb_info->recv_msg);
4244 *quality = get_quality;
4247 LOGD("ret : 0x%x", ret);
4253 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4255 int ret = CAMERA_ERROR_NONE;
4256 camera_cli_s *pc = (camera_cli_s *)camera;
4257 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4258 int get_bitrate = 0;
4260 if (!pc || !pc->cb_info || !bitrate) {
4261 LOGE("NULL pointer %p %p", pc, bitrate);
4262 return CAMERA_ERROR_INVALID_PARAMETER;
4267 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4269 if (ret == CAMERA_ERROR_NONE) {
4270 muse_camera_msg_get(get_bitrate, pc->cb_info->recv_msg);
4271 *bitrate = get_bitrate;
4274 LOGD("ret : 0x%x", ret);
4280 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4282 int ret = CAMERA_ERROR_NONE;
4283 camera_cli_s *pc = (camera_cli_s *)camera;
4284 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4285 camera_msg_param param;
4286 int set_bitrate = bitrate;
4288 if (!pc || !pc->cb_info) {
4289 LOGE("NULL handle");
4290 return CAMERA_ERROR_INVALID_PARAMETER;
4295 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4297 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4299 LOGD("ret : 0x%x", ret);
4305 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4307 int ret = CAMERA_ERROR_NONE;
4308 camera_cli_s *pc = (camera_cli_s *)camera;
4309 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4310 int get_gop_interval = 0;
4312 if (!pc || !pc->cb_info || !interval) {
4313 LOGE("NULL pointer %p %p", pc, interval);
4314 return CAMERA_ERROR_INVALID_PARAMETER;
4319 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4321 if (ret == CAMERA_ERROR_NONE) {
4322 muse_camera_msg_get(get_gop_interval, pc->cb_info->recv_msg);
4323 *interval = get_gop_interval;
4326 LOGD("ret : 0x%x", ret);
4332 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4334 int ret = CAMERA_ERROR_NONE;
4335 camera_cli_s *pc = (camera_cli_s *)camera;
4336 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4337 camera_msg_param param;
4338 int set_gop_interval = interval;
4340 if (!pc || !pc->cb_info) {
4341 LOGE("NULL handle");
4342 return CAMERA_ERROR_INVALID_PARAMETER;
4347 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4349 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4351 LOGD("ret : 0x%x", ret);
4357 int camera_attr_set_zoom(camera_h camera, int zoom)
4359 int ret = CAMERA_ERROR_NONE;
4360 camera_cli_s *pc = (camera_cli_s *)camera;
4361 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4362 camera_msg_param param;
4364 if (!pc || !pc->cb_info) {
4365 LOGE("NULL handle");
4366 return CAMERA_ERROR_INVALID_PARAMETER;
4369 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4371 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4373 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4375 LOGD("ret : 0x%x", ret);
4381 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4383 int ret = CAMERA_ERROR_NONE;
4384 camera_cli_s *pc = (camera_cli_s *)camera;
4385 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4386 camera_msg_param param;
4387 int set_mode = (int)mode;
4389 if (!pc || !pc->cb_info) {
4390 LOGE("NULL handle");
4391 return CAMERA_ERROR_INVALID_PARAMETER;
4394 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4396 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4398 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4404 int camera_attr_set_af_area(camera_h camera, int x, int y)
4406 int ret = CAMERA_ERROR_NONE;
4407 camera_cli_s *pc = (camera_cli_s *)camera;
4408 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4409 camera_msg_param param;
4412 if (!pc || !pc->cb_info) {
4413 LOGE("NULL handle");
4414 return CAMERA_ERROR_INVALID_PARAMETER;
4417 LOGD("Enter - %d,%d", x, y);
4419 value = (x << 16) | y;
4420 CAMERA_MSG_PARAM_SET(param, INT, value);
4422 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4424 LOGD("ret : 0x%x", ret);
4430 int camera_attr_clear_af_area(camera_h camera)
4432 int ret = CAMERA_ERROR_NONE;
4433 camera_cli_s *pc = (camera_cli_s *)camera;
4434 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4436 if (!pc || !pc->cb_info) {
4437 LOGE("NULL handle");
4438 return CAMERA_ERROR_INVALID_PARAMETER;
4443 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4445 LOGD("ret : 0x%x", ret);
4451 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4453 int ret = CAMERA_ERROR_NONE;
4454 camera_cli_s *pc = (camera_cli_s *)camera;
4455 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4456 camera_msg_param param;
4457 int set_mode = (int)mode;
4459 if (!pc || !pc->cb_info) {
4460 LOGE("NULL handle");
4461 return CAMERA_ERROR_INVALID_PARAMETER;
4466 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4468 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4470 LOGD("ret : 0x%x", ret);
4476 int camera_attr_set_exposure(camera_h camera, int value)
4478 int ret = CAMERA_ERROR_NONE;
4479 camera_cli_s *pc = (camera_cli_s *)camera;
4480 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4481 camera_msg_param param;
4483 if (!pc || !pc->cb_info) {
4484 LOGE("NULL handle");
4485 return CAMERA_ERROR_INVALID_PARAMETER;
4490 CAMERA_MSG_PARAM_SET(param, INT, value);
4492 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4494 LOGD("ret : 0x%x", ret);
4500 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4502 int ret = CAMERA_ERROR_NONE;
4503 camera_cli_s *pc = (camera_cli_s *)camera;
4504 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4505 camera_msg_param param;
4506 int set_iso = (int)iso;
4508 if (!pc || !pc->cb_info) {
4509 LOGE("NULL handle");
4510 return CAMERA_ERROR_INVALID_PARAMETER;
4515 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4517 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4519 LOGD("ret : 0x%x", ret);
4525 int camera_attr_set_brightness(camera_h camera, int level)
4527 int ret = CAMERA_ERROR_NONE;
4528 camera_cli_s *pc = (camera_cli_s *)camera;
4529 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4530 camera_msg_param param;
4532 if (!pc || !pc->cb_info) {
4533 LOGE("NULL handle");
4534 return CAMERA_ERROR_INVALID_PARAMETER;
4539 CAMERA_MSG_PARAM_SET(param, INT, level);
4541 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4543 LOGD("ret : 0x%x", ret);
4549 int camera_attr_set_contrast(camera_h camera, int level)
4551 int ret = CAMERA_ERROR_NONE;
4552 camera_cli_s *pc = (camera_cli_s *)camera;
4553 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4554 camera_msg_param param;
4556 if (!pc || !pc->cb_info) {
4557 LOGE("NULL handle");
4558 return CAMERA_ERROR_INVALID_PARAMETER;
4563 CAMERA_MSG_PARAM_SET(param, INT, level);
4565 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4567 LOGD("ret : 0x%x", ret);
4573 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4575 int ret = CAMERA_ERROR_NONE;
4576 camera_cli_s *pc = (camera_cli_s *)camera;
4577 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4578 camera_msg_param param;
4579 int set_whitebalance = (int)wb;
4581 if (!pc || !pc->cb_info) {
4582 LOGE("NULL handle");
4583 return CAMERA_ERROR_INVALID_PARAMETER;
4588 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4590 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4592 LOGD("ret : 0x%x", ret);
4598 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4600 int ret = CAMERA_ERROR_NONE;
4601 camera_cli_s *pc = (camera_cli_s *)camera;
4602 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4603 camera_msg_param param;
4604 int set_effect = (int)effect;
4606 if (!pc || !pc->cb_info) {
4607 LOGE("NULL handle");
4608 return CAMERA_ERROR_INVALID_PARAMETER;
4613 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4615 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4617 LOGD("ret : 0x%x", ret);
4623 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4625 int ret = CAMERA_ERROR_NONE;
4626 camera_cli_s *pc = (camera_cli_s *)camera;
4627 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4628 camera_msg_param param;
4629 int set_mode = (int)mode;
4631 if (!pc || !pc->cb_info) {
4632 LOGE("NULL handle");
4633 return CAMERA_ERROR_INVALID_PARAMETER;
4638 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4640 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4642 LOGD("ret : 0x%x", ret);
4648 int camera_attr_enable_tag(camera_h camera, bool enable)
4650 int ret = CAMERA_ERROR_NONE;
4651 camera_cli_s *pc = (camera_cli_s *)camera;
4652 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4653 camera_msg_param param;
4654 int set_enable = (int)enable;
4656 if (!pc || !pc->cb_info) {
4657 LOGE("NULL handle");
4658 return CAMERA_ERROR_INVALID_PARAMETER;
4663 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4665 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4667 LOGD("ret : 0x%x", ret);
4673 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4675 int ret = CAMERA_ERROR_NONE;
4676 camera_cli_s *pc = (camera_cli_s *)camera;
4677 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4678 camera_msg_param param;
4680 if (!pc || !pc->cb_info || !description) {
4681 LOGE("NULL pointer %p %p", pc, description);
4682 return CAMERA_ERROR_INVALID_PARAMETER;
4687 CAMERA_MSG_PARAM_SET(param, STRING, description);
4689 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4691 LOGD("ret : 0x%x", ret);
4697 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4699 int ret = CAMERA_ERROR_NONE;
4700 camera_cli_s *pc = (camera_cli_s *)camera;
4701 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4702 camera_msg_param param;
4703 int set_orientation = (int)orientation;
4705 if (!pc || !pc->cb_info) {
4706 LOGE("NULL handle");
4707 return CAMERA_ERROR_INVALID_PARAMETER;
4712 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4714 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4716 LOGD("ret : 0x%x", ret);
4722 int camera_attr_set_tag_software(camera_h camera, const char *software)
4724 int ret = CAMERA_ERROR_NONE;
4725 camera_cli_s *pc = (camera_cli_s *)camera;
4726 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4727 camera_msg_param param;
4729 if (!pc || !pc->cb_info || !software) {
4730 LOGE("NULL pointer %p %p", pc, software);
4731 return CAMERA_ERROR_INVALID_PARAMETER;
4734 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4736 CAMERA_MSG_PARAM_SET(param, STRING, software);
4738 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4740 LOGD("ret : 0x%x", ret);
4746 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4748 int ret = CAMERA_ERROR_NONE;
4749 camera_cli_s *pc = (camera_cli_s *)camera;
4750 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4751 double set_geotag[3] = {latitude, longitude, altitude};
4756 if (!pc || !pc->cb_info) {
4757 LOGE("NULL handle");
4758 return CAMERA_ERROR_INVALID_PARAMETER;
4763 length = sizeof(set_geotag) / sizeof(int) + \
4764 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4766 msg = muse_core_msg_json_factory_new(api,
4767 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4770 LOGE("msg creation failed: api %d", api);
4771 return CAMERA_ERROR_OUT_OF_MEMORY;
4774 if (pc->cb_info->is_server_connected)
4775 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
4778 LOGE("message send failed");
4779 ret = CAMERA_ERROR_INVALID_OPERATION;
4781 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
4784 muse_core_msg_json_factory_free(msg);
4786 LOGD("ret : 0x%x", ret);
4792 int camera_attr_remove_geotag(camera_h camera)
4794 int ret = CAMERA_ERROR_NONE;
4795 camera_cli_s *pc = (camera_cli_s *)camera;
4796 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4798 if (!pc || !pc->cb_info) {
4799 LOGE("NULL handle");
4800 return CAMERA_ERROR_INVALID_PARAMETER;
4805 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4807 LOGD("ret : 0x%x", ret);
4813 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4815 int ret = CAMERA_ERROR_NONE;
4816 camera_cli_s *pc = (camera_cli_s *)camera;
4817 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
4818 camera_msg_param param;
4819 int set_mode = (int)mode;
4821 if (!pc || !pc->cb_info) {
4822 LOGE("NULL handle");
4823 return CAMERA_ERROR_INVALID_PARAMETER;
4828 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4830 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4832 LOGD("ret : 0x%x", ret);
4838 int camera_attr_get_zoom(camera_h camera, int *zoom)
4840 int ret = CAMERA_ERROR_NONE;
4841 camera_cli_s *pc = (camera_cli_s *)camera;
4842 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4845 if (!pc || !pc->cb_info || !zoom) {
4846 LOGE("NULL pointer %p %p", pc, zoom);
4847 return CAMERA_ERROR_INVALID_PARAMETER;
4852 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4854 if (ret == CAMERA_ERROR_NONE) {
4855 muse_camera_msg_get(get_zoom, pc->cb_info->recv_msg);
4859 LOGD("ret : 0x%x", ret);
4865 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
4867 int ret = CAMERA_ERROR_NONE;
4868 camera_cli_s *pc = (camera_cli_s *)camera;
4869 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
4873 if (!pc || !pc->cb_info || !min || !max) {
4874 LOGE("NULL pointer %p %p %p", pc, min, max);
4875 return CAMERA_ERROR_INVALID_PARAMETER;
4880 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4882 if (ret == CAMERA_ERROR_NONE) {
4883 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
4884 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
4889 LOGD("ret : 0x%x", ret);
4895 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
4897 int ret = CAMERA_ERROR_NONE;
4898 camera_cli_s *pc = (camera_cli_s *)camera;
4899 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
4902 if (!pc || !pc->cb_info || !mode) {
4903 LOGE("NULL pointer %p %p", pc, mode);
4904 return CAMERA_ERROR_INVALID_PARAMETER;
4909 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4911 if (ret == CAMERA_ERROR_NONE) {
4912 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
4913 *mode = (camera_attr_af_mode_e)get_mode;
4916 LOGD("ret : 0x%x", ret);
4922 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
4924 int ret = CAMERA_ERROR_NONE;
4925 camera_cli_s *pc = (camera_cli_s *)camera;
4926 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
4929 if (!pc || !pc->cb_info || !mode) {
4930 LOGE("NULL pointer %p %p", pc, mode);
4931 return CAMERA_ERROR_INVALID_PARAMETER;
4936 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4938 if (ret == CAMERA_ERROR_NONE) {
4939 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
4940 *mode = (camera_attr_exposure_mode_e)get_mode;
4943 LOGD("ret : 0x%x", ret);
4949 int camera_attr_get_exposure(camera_h camera, int *value)
4951 int ret = CAMERA_ERROR_NONE;
4952 camera_cli_s *pc = (camera_cli_s *)camera;
4953 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
4956 if (!pc || !pc->cb_info || !value) {
4957 LOGE("NULL pointer %p %p", pc, value);
4958 return CAMERA_ERROR_INVALID_PARAMETER;
4963 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4965 if (ret == CAMERA_ERROR_NONE) {
4966 muse_camera_msg_get(get_value, pc->cb_info->recv_msg);
4970 LOGD("ret : 0x%x", ret);
4976 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
4978 int ret = CAMERA_ERROR_NONE;
4979 camera_cli_s *pc = (camera_cli_s *)camera;
4980 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
4984 if (!pc || !pc->cb_info || !min || !max) {
4985 LOGE("NULL pointer %p %p %p", pc, min, max);
4986 return CAMERA_ERROR_INVALID_PARAMETER;
4991 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4993 if (ret == CAMERA_ERROR_NONE) {
4994 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
4995 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
5000 LOGD("ret : 0x%x", ret);
5006 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5008 int ret = CAMERA_ERROR_NONE;
5009 camera_cli_s *pc = (camera_cli_s *)camera;
5010 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5013 if (!pc || !pc->cb_info || !iso) {
5014 LOGE("NULL pointer %p %p", pc, iso);
5015 return CAMERA_ERROR_INVALID_PARAMETER;
5020 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5022 if (ret == CAMERA_ERROR_NONE) {
5023 muse_camera_msg_get(get_iso, pc->cb_info->recv_msg);
5024 *iso = (camera_attr_iso_e)get_iso;
5027 LOGD("ret : 0x%x", ret);
5033 int camera_attr_get_brightness(camera_h camera, int *level)
5035 int ret = CAMERA_ERROR_NONE;
5036 camera_cli_s *pc = (camera_cli_s *)camera;
5037 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5040 if (!pc || !pc->cb_info || !level) {
5041 LOGE("NULL pointer %p %p", pc, level);
5042 return CAMERA_ERROR_INVALID_PARAMETER;
5047 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5049 if (ret == CAMERA_ERROR_NONE) {
5050 muse_camera_msg_get(get_level, pc->cb_info->recv_msg);
5054 LOGD("ret : 0x%x", ret);
5060 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5062 int ret = CAMERA_ERROR_NONE;
5063 camera_cli_s *pc = (camera_cli_s *)camera;
5064 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5068 if (!pc || !pc->cb_info || !min || !max) {
5069 LOGE("NULL pointer %p %p %p", pc, min, max);
5070 return CAMERA_ERROR_INVALID_PARAMETER;
5075 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5077 if (ret == CAMERA_ERROR_NONE) {
5078 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
5079 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
5084 LOGD("ret : 0x%x", ret);
5090 int camera_attr_get_contrast(camera_h camera, int *level)
5092 int ret = CAMERA_ERROR_NONE;
5093 camera_cli_s *pc = (camera_cli_s *)camera;
5094 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5097 if (!pc || !pc->cb_info || !level) {
5098 LOGE("NULL pointer %p %p", pc, level);
5099 return CAMERA_ERROR_INVALID_PARAMETER;
5104 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5106 if (ret == CAMERA_ERROR_NONE) {
5107 muse_camera_msg_get(get_level, pc->cb_info->recv_msg);
5111 LOGD("ret : 0x%x", ret);
5117 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5119 int ret = CAMERA_ERROR_NONE;
5120 camera_cli_s *pc = (camera_cli_s *)camera;
5121 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5125 if (!pc || !pc->cb_info || !min || !max) {
5126 LOGE("NULL pointer %p %p %p", pc, min, max);
5127 return CAMERA_ERROR_INVALID_PARAMETER;
5132 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5134 if (ret == CAMERA_ERROR_NONE) {
5135 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
5136 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
5141 LOGD("ret : 0x%x", ret);
5147 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5149 int ret = CAMERA_ERROR_NONE;
5150 camera_cli_s *pc = (camera_cli_s *)camera;
5151 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5154 if (!pc || !pc->cb_info || !wb) {
5155 LOGE("NULL pointer %p %p", pc, wb);
5156 return CAMERA_ERROR_INVALID_PARAMETER;
5161 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5163 if (ret == CAMERA_ERROR_NONE) {
5164 muse_camera_msg_get(get_wb, pc->cb_info->recv_msg);
5165 *wb = (camera_attr_whitebalance_e)get_wb;
5168 LOGD("ret : 0x%x", ret);
5174 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5176 int ret = CAMERA_ERROR_NONE;
5177 camera_cli_s *pc = (camera_cli_s *)camera;
5178 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5181 if (!pc || !pc->cb_info || !effect) {
5182 LOGE("NULL pointer %p %p", pc, effect);
5183 return CAMERA_ERROR_INVALID_PARAMETER;
5188 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5190 if (ret == CAMERA_ERROR_NONE) {
5191 muse_camera_msg_get(get_effect, pc->cb_info->recv_msg);
5192 *effect = (camera_attr_effect_mode_e)get_effect;
5195 LOGD("ret : 0x%x", ret);
5201 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5203 int ret = CAMERA_ERROR_NONE;
5204 camera_cli_s *pc = (camera_cli_s *)camera;
5205 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5208 if (!pc || !pc->cb_info || !mode) {
5209 LOGE("NULL pointer %p %p", pc, mode);
5210 return CAMERA_ERROR_INVALID_PARAMETER;
5215 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5217 if (ret == CAMERA_ERROR_NONE) {
5218 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
5219 *mode = (camera_attr_scene_mode_e)get_mode;
5222 LOGD("ret : 0x%x", ret);
5228 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5230 int ret = CAMERA_ERROR_NONE;
5231 camera_cli_s *pc = (camera_cli_s *)camera;
5232 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5233 int get_enabled = 0;
5235 if (!pc || !pc->cb_info || !enable) {
5236 LOGE("NULL pointer %p %p", pc, enable);
5237 return CAMERA_ERROR_INVALID_PARAMETER;
5242 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5244 if (ret == CAMERA_ERROR_NONE) {
5245 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
5246 *enable = (bool)get_enabled;
5249 LOGD("ret : 0x%x", ret);
5255 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5257 int ret = CAMERA_ERROR_NONE;
5258 camera_cli_s *pc = (camera_cli_s *)camera;
5259 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5260 char get_description[MUSE_CAMERA_MSG_MAX_LENGTH] = {0, };
5262 if (!pc || !pc->cb_info || !description) {
5263 LOGE("NULL pointer %p %p", pc, description);
5264 return CAMERA_ERROR_INVALID_PARAMETER;
5269 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5271 if (ret == CAMERA_ERROR_NONE) {
5272 muse_camera_msg_get_string(get_description, pc->cb_info->recv_msg);
5273 *description = strdup(get_description);
5276 LOGD("ret : 0x%x", ret);
5282 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5284 int ret = CAMERA_ERROR_NONE;
5285 camera_cli_s *pc = (camera_cli_s *)camera;
5286 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5287 int get_orientation = 0;
5289 if (!pc || !pc->cb_info || !orientation) {
5290 LOGE("NULL pointer %p %p", pc, orientation);
5291 return CAMERA_ERROR_INVALID_PARAMETER;
5296 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5298 if (ret == CAMERA_ERROR_NONE) {
5299 muse_camera_msg_get(get_orientation, pc->cb_info->recv_msg);
5300 *orientation = (camera_attr_tag_orientation_e)get_orientation;
5303 LOGD("ret : 0x%x", ret);
5309 int camera_attr_get_tag_software(camera_h camera, char **software)
5311 int ret = CAMERA_ERROR_NONE;
5312 camera_cli_s *pc = (camera_cli_s *)camera;
5313 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5314 char get_software[MUSE_CAMERA_MSG_MAX_LENGTH] = {0, };
5316 if (!pc || !pc->cb_info || !software) {
5317 LOGE("NULL pointer %p %p", pc, software);
5318 return CAMERA_ERROR_INVALID_PARAMETER;
5323 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5325 if (ret == CAMERA_ERROR_NONE) {
5326 muse_camera_msg_get_string(get_software, pc->cb_info->recv_msg);
5327 *software = strdup(get_software);
5330 LOGD("ret : 0x%x", ret);
5336 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5338 int ret = CAMERA_ERROR_NONE;
5339 camera_cli_s *pc = (camera_cli_s *)camera;
5340 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5341 double get_geotag[3] = {0.0, };
5343 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5344 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5345 return CAMERA_ERROR_INVALID_PARAMETER;
5350 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5352 if (ret == CAMERA_ERROR_NONE) {
5353 muse_camera_msg_get_array(get_geotag, pc->cb_info->recv_msg);
5354 *latitude = get_geotag[0];
5355 *longitude = get_geotag[1];
5356 *altitude = get_geotag[2];
5359 LOGD("ret : 0x%x", ret);
5365 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5367 int ret = CAMERA_ERROR_NONE;
5368 camera_cli_s *pc = (camera_cli_s *)camera;
5369 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5372 if (!pc || !pc->cb_info || !mode) {
5373 LOGE("NULL pointer %p %p", pc, mode);
5374 return CAMERA_ERROR_INVALID_PARAMETER;
5379 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5381 if (ret == CAMERA_ERROR_NONE) {
5382 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
5383 *mode = (camera_attr_flash_mode_e)get_mode;
5386 LOGD("ret : 0x%x", ret);
5392 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5394 int ret = CAMERA_ERROR_NONE;
5395 int get_flash_state = 0;
5398 LOGE("NULL pointer");
5399 return CAMERA_ERROR_INVALID_PARAMETER;
5402 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5403 (int)device, "get_flash_state", &get_flash_state);
5405 if (ret == CAMERA_ERROR_NONE) {
5406 *state = (camera_flash_state_e)get_flash_state;
5407 LOGD("flash state %d", *state);
5409 LOGE("failed 0x%x", ret);
5416 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5418 int ret = CAMERA_ERROR_NONE;
5419 camera_cli_s *pc = (camera_cli_s *)camera;
5420 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5422 if (!pc || !pc->cb_info || !foreach_cb) {
5423 LOGE("NULL pointer %p %p", pc, foreach_cb);
5424 return CAMERA_ERROR_INVALID_PARAMETER;
5429 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5430 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5432 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5434 LOGD("ret : 0x%x", ret);
5440 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5442 int ret = CAMERA_ERROR_NONE;
5443 camera_cli_s *pc = (camera_cli_s *)camera;
5444 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5446 if (!pc || !pc->cb_info || !foreach_cb) {
5447 LOGE("NULL pointer %p %p", pc, foreach_cb);
5448 return CAMERA_ERROR_INVALID_PARAMETER;
5453 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5454 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5456 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5458 LOGD("ret : 0x%x", ret);
5464 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5466 int ret = CAMERA_ERROR_NONE;
5467 camera_cli_s *pc = (camera_cli_s *)camera;
5468 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5470 if (!pc || !pc->cb_info || !foreach_cb) {
5471 LOGE("NULL pointer %p %p", pc, foreach_cb);
5472 return CAMERA_ERROR_INVALID_PARAMETER;
5477 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5478 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5480 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5482 LOGD("ret : 0x%x", ret);
5488 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5490 int ret = CAMERA_ERROR_NONE;
5491 camera_cli_s *pc = (camera_cli_s *)camera;
5492 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5494 if (!pc || !pc->cb_info || !foreach_cb) {
5495 LOGE("NULL pointer %p %p", pc, foreach_cb);
5496 return CAMERA_ERROR_INVALID_PARAMETER;
5501 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5502 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5504 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5506 LOGD("ret : 0x%x", ret);
5512 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5514 int ret = CAMERA_ERROR_NONE;
5515 camera_cli_s *pc = (camera_cli_s *)camera;
5516 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5518 if (!pc || !pc->cb_info || !foreach_cb) {
5519 LOGE("NULL pointer %p %p", pc, foreach_cb);
5520 return CAMERA_ERROR_INVALID_PARAMETER;
5525 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5526 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5528 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5530 LOGD("ret : 0x%x", ret);
5536 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5538 int ret = CAMERA_ERROR_NONE;
5539 camera_cli_s *pc = (camera_cli_s *)camera;
5540 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5542 if (!pc || !pc->cb_info || !foreach_cb) {
5543 LOGE("NULL pointer %p %p", pc, foreach_cb);
5544 return CAMERA_ERROR_INVALID_PARAMETER;
5549 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5550 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5552 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5554 LOGD("ret : 0x%x", ret);
5560 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5562 int ret = CAMERA_ERROR_NONE;
5563 camera_cli_s *pc = (camera_cli_s *)camera;
5564 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5566 if (!pc || !pc->cb_info || !foreach_cb) {
5567 LOGE("NULL pointer %p %p", pc, foreach_cb);
5568 return CAMERA_ERROR_INVALID_PARAMETER;
5573 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5574 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5576 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5578 LOGD("ret : 0x%x", ret);
5584 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5586 int ret = CAMERA_ERROR_NONE;
5587 camera_cli_s *pc = (camera_cli_s *)camera;
5588 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5590 if (!pc || !pc->cb_info || !foreach_cb) {
5591 LOGE("NULL pointer %p %p", pc, foreach_cb);
5592 return CAMERA_ERROR_INVALID_PARAMETER;
5597 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5598 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5600 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5602 LOGD("Enter, handle :%x", pc->remote_handle);
5608 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)
5610 int ret = CAMERA_ERROR_NONE;
5611 camera_cli_s *pc = (camera_cli_s *)camera;
5612 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5613 camera_msg_param param;
5616 if (!pc || !pc->cb_info || !foreach_cb) {
5617 LOGE("NULL pointer %p %p", pc, foreach_cb);
5618 return CAMERA_ERROR_INVALID_PARAMETER;
5623 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5624 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5626 value = (width << 16) | height;
5627 CAMERA_MSG_PARAM_SET(param, INT, value);
5629 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5631 LOGD("ret : 0x%x", ret);
5637 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5639 int ret = CAMERA_ERROR_NONE;
5640 camera_cli_s *pc = (camera_cli_s *)camera;
5641 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5643 if (!pc || !pc->cb_info || !foreach_cb) {
5644 LOGE("NULL pointer %p %p", pc, foreach_cb);
5645 return CAMERA_ERROR_INVALID_PARAMETER;
5650 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5651 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5653 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5655 LOGD("ret : 0x%x", ret);
5661 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5663 int ret = CAMERA_ERROR_NONE;
5664 camera_cli_s *pc = (camera_cli_s *)camera;
5665 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5667 if (!pc || !pc->cb_info || !foreach_cb) {
5668 LOGE("NULL pointer %p %p", pc, foreach_cb);
5669 return CAMERA_ERROR_INVALID_PARAMETER;
5674 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5675 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5677 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5679 LOGD("ret : 0x%x", ret);
5685 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5687 int ret = CAMERA_ERROR_NONE;
5688 camera_cli_s *pc = (camera_cli_s *)camera;
5689 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5690 camera_msg_param param;
5691 int set_rotation = (int)rotation;
5693 if (!pc || !pc->cb_info) {
5694 LOGE("NULL handle");
5695 return CAMERA_ERROR_INVALID_PARAMETER;
5700 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5702 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5704 LOGD("ret : 0x%x", ret);
5710 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5712 int ret = CAMERA_ERROR_NONE;
5713 camera_cli_s *pc = (camera_cli_s *)camera;
5714 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5715 int get_rotation = 0;
5717 if (!pc || !pc->cb_info || !rotation) {
5718 LOGE("NULL pointer %p %p", pc, rotation);
5719 return CAMERA_ERROR_INVALID_PARAMETER;
5724 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5726 if (ret == CAMERA_ERROR_NONE) {
5727 muse_camera_msg_get(get_rotation, pc->cb_info->recv_msg);
5728 *rotation = (camera_rotation_e)get_rotation;
5731 LOGD("ret : 0x%x", ret);
5737 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5739 int ret = CAMERA_ERROR_NONE;
5740 camera_cli_s *pc = (camera_cli_s *)camera;
5741 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5742 camera_msg_param param;
5743 int set_flip = (int)flip;
5745 if (!pc || !pc->cb_info) {
5746 LOGE("NULL handle");
5747 return CAMERA_ERROR_INVALID_PARAMETER;
5752 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5754 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5756 LOGD("ret : 0x%x", ret);
5762 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5764 int ret = CAMERA_ERROR_NONE;
5765 camera_cli_s *pc = (camera_cli_s *)camera;
5766 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5769 if (!pc || !pc->cb_info || !flip) {
5770 LOGE("NULL pointer %p %p", pc, flip);
5771 return CAMERA_ERROR_INVALID_PARAMETER;
5776 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5778 if (ret == CAMERA_ERROR_NONE) {
5779 muse_camera_msg_get(get_flip, pc->cb_info->recv_msg);
5780 *flip = (camera_flip_e)get_flip;
5783 LOGD("ret : 0x%x", ret);
5788 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5790 int ret = CAMERA_ERROR_NONE;
5791 camera_cli_s *pc = (camera_cli_s *)camera;
5792 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5793 camera_msg_param param;
5794 int set_mode = (int)mode;
5796 if (!pc || !pc->cb_info) {
5797 LOGE("NULL handle");
5798 return CAMERA_ERROR_INVALID_PARAMETER;
5803 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5805 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5807 LOGD("ret : 0x%x", ret);
5813 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5815 int ret = CAMERA_ERROR_NONE;
5816 camera_cli_s *pc = (camera_cli_s *)camera;
5817 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5820 if (!pc || !pc->cb_info || !mode) {
5821 LOGE("NULL pointer %p %p", pc, mode);
5822 return CAMERA_ERROR_INVALID_PARAMETER;
5827 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5829 if (ret == CAMERA_ERROR_NONE) {
5830 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
5831 *mode = (camera_attr_hdr_mode_e)get_mode;
5834 LOGD("ret : 0x%x", ret);
5840 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5842 int ret = CAMERA_ERROR_NONE;
5843 camera_cli_s *pc = (camera_cli_s *)camera;
5844 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
5846 if (!pc || !pc->cb_info) {
5847 LOGE("NULL handle");
5848 return CAMERA_ERROR_INVALID_PARAMETER;
5853 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5856 LOGE("error is occurred 0x%x", ret);
5860 LOGD("ret : %d", ret);
5866 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5868 int ret = CAMERA_ERROR_NONE;
5869 camera_cli_s *pc = (camera_cli_s *)camera;
5870 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5872 if (!pc || !pc->cb_info) {
5873 LOGE("NULL handle");
5874 return CAMERA_ERROR_INVALID_PARAMETER;
5879 if (!camera_attr_is_supported_hdr_capture(camera)) {
5880 LOGE("HDR not supported");
5881 return CAMERA_ERROR_NOT_SUPPORTED;
5885 LOGE("NULL callback");
5886 return CAMERA_ERROR_INVALID_PARAMETER;
5889 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5890 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5892 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5894 LOGD("ret : 0x%x", ret);
5900 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5902 int ret = CAMERA_ERROR_NONE;
5903 camera_cli_s *pc = (camera_cli_s *)camera;
5904 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5906 if (!pc || !pc->cb_info) {
5907 LOGE("NULL handle");
5908 return CAMERA_ERROR_INVALID_PARAMETER;
5913 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5914 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5916 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5918 LOGD("ret : 0x%x", ret);
5924 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
5926 int ret = CAMERA_ERROR_NONE;
5927 camera_cli_s *pc = (camera_cli_s *)camera;
5928 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
5929 camera_msg_param param;
5930 int set_enable = (int)enable;
5932 if (!pc || !pc->cb_info) {
5933 LOGE("NULL handle");
5934 return CAMERA_ERROR_INVALID_PARAMETER;
5939 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
5941 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5943 LOGD("ret : 0x%x", ret);
5949 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
5951 int ret = CAMERA_ERROR_NONE;
5952 camera_cli_s *pc = (camera_cli_s *)camera;
5953 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
5954 int get_enabled = 0;
5956 if (!pc || !pc->cb_info || !enabled) {
5957 LOGE("NULL pointer %p %p", pc, enabled);
5958 return CAMERA_ERROR_INVALID_PARAMETER;
5963 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5965 if (ret == CAMERA_ERROR_NONE) {
5966 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
5967 *enabled = (bool)get_enabled;
5970 LOGD("ret : 0x%x", ret);
5976 bool camera_attr_is_supported_anti_shake(camera_h camera)
5978 int ret = CAMERA_ERROR_NONE;
5979 camera_cli_s *pc = (camera_cli_s *)camera;
5980 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
5982 if (!pc || !pc->cb_info) {
5983 LOGE("NULL handle");
5984 return CAMERA_ERROR_INVALID_PARAMETER;
5989 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5992 LOGE("error is occurred 0x%x", ret);
5996 LOGD("ret : %d", ret);
6002 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6004 int ret = CAMERA_ERROR_NONE;
6005 camera_cli_s *pc = (camera_cli_s *)camera;
6006 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6007 camera_msg_param param;
6008 int set_enable = (int)enable;
6010 if (!pc || !pc->cb_info) {
6011 LOGE("NULL handle");
6012 return CAMERA_ERROR_INVALID_PARAMETER;
6017 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6019 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6021 LOGD("ret : 0x%x", ret);
6027 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6029 int ret = CAMERA_ERROR_NONE;
6030 camera_cli_s *pc = (camera_cli_s *)camera;
6031 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6032 int get_enabled = 0;
6034 if (!pc || !pc->cb_info || !enabled) {
6035 LOGE("NULL pointer %p %p", pc, enabled);
6036 return CAMERA_ERROR_INVALID_PARAMETER;
6041 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6043 if (ret == CAMERA_ERROR_NONE) {
6044 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
6045 *enabled = (bool)get_enabled;
6048 LOGD("ret : 0x%x", ret);
6054 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6056 int ret = CAMERA_ERROR_NONE;
6057 camera_cli_s *pc = (camera_cli_s *)camera;
6058 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6060 if (!pc || !pc->cb_info) {
6061 LOGE("NULL handle");
6062 return CAMERA_ERROR_INVALID_PARAMETER;
6067 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6070 LOGE("error is occurred 0x%x", ret);
6074 LOGD("ret : %d", ret);
6080 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6082 int ret = CAMERA_ERROR_NONE;
6083 camera_cli_s *pc = (camera_cli_s *)camera;
6084 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6085 camera_msg_param param;
6086 int set_enable = (int)enable;
6088 if (!pc || !pc->cb_info) {
6089 LOGE("NULL handle");
6090 return CAMERA_ERROR_INVALID_PARAMETER;
6095 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6097 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6099 LOGD("ret : 0x%x", ret);
6105 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6107 int ret = CAMERA_ERROR_NONE;
6108 camera_cli_s *pc = (camera_cli_s *)camera;
6109 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6110 int get_enabled = 0;
6112 if (!pc || !pc->cb_info || !enabled) {
6113 LOGE("NULL pointer %p %p", pc, enabled);
6114 return CAMERA_ERROR_INVALID_PARAMETER;
6119 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6121 if (ret == CAMERA_ERROR_NONE) {
6122 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
6123 *enabled = (bool)get_enabled;
6126 LOGD("ret : 0x%x", ret);
6132 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6134 int ret = CAMERA_ERROR_NONE;
6135 camera_cli_s *pc = (camera_cli_s *)camera;
6136 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6138 if (!pc || !pc->cb_info) {
6139 LOGE("NULL handle");
6140 return CAMERA_ERROR_INVALID_PARAMETER;
6145 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6148 LOGE("error is occurred 0x%x", ret);
6152 LOGD("ret : %d", ret);
6158 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6160 int ret = CAMERA_ERROR_NONE;
6161 camera_cli_s *pc = (camera_cli_s *)camera;
6162 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6163 camera_msg_param param;
6164 int set_disable = (int)disable;
6166 if (!pc || !pc->cb_info) {
6167 LOGE("NULL handle");
6168 return CAMERA_ERROR_INVALID_PARAMETER;
6173 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6175 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6177 LOGD("ret : 0x%x", ret);
6183 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6185 int ret = CAMERA_ERROR_NONE;
6186 camera_cli_s *pc = (camera_cli_s *)camera;
6187 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6188 camera_msg_param param;
6189 int set_move_type = (int)move_type;
6192 if (!pc || !pc->cb_info) {
6193 LOGE("NULL handle");
6194 return CAMERA_ERROR_INVALID_PARAMETER;
6199 value = (set_move_type << 16) | pan_step;
6200 CAMERA_MSG_PARAM_SET(param, INT, value);
6202 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6204 LOGD("ret : 0x%x", ret);
6210 int camera_attr_get_pan(camera_h camera, int *pan_step)
6212 int ret = CAMERA_ERROR_NONE;
6213 camera_cli_s *pc = (camera_cli_s *)camera;
6214 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6215 int get_pan_step = 0;
6217 if (!pc || !pc->cb_info || !pan_step) {
6218 LOGE("NULL pointer %p %p", pc, pan_step);
6219 return CAMERA_ERROR_INVALID_PARAMETER;
6224 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6226 if (ret == CAMERA_ERROR_NONE) {
6227 muse_camera_msg_get(get_pan_step, pc->cb_info->recv_msg);
6228 *pan_step = get_pan_step;
6231 LOGD("ret : 0x%x", ret);
6237 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6239 int ret = CAMERA_ERROR_NONE;
6240 camera_cli_s *pc = (camera_cli_s *)camera;
6241 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6245 if (!pc || !pc->cb_info || !min || !max) {
6246 LOGE("NULL pointer %p %p", pc, min, max);
6247 return CAMERA_ERROR_INVALID_PARAMETER;
6252 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6254 if (ret == CAMERA_ERROR_NONE) {
6255 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
6256 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
6261 LOGD("ret : 0x%x", ret);
6267 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6269 int ret = CAMERA_ERROR_NONE;
6270 camera_cli_s *pc = (camera_cli_s *)camera;
6271 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6272 camera_msg_param param;
6273 int set_move_type = (int)move_type;
6276 if (!pc || !pc->cb_info) {
6277 LOGE("NULL handle");
6278 return CAMERA_ERROR_INVALID_PARAMETER;
6283 value = (set_move_type << 16) | tilt_step;
6284 CAMERA_MSG_PARAM_SET(param, INT, value);
6286 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6288 LOGD("ret : 0x%x", ret);
6294 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6296 int ret = CAMERA_ERROR_NONE;
6297 camera_cli_s *pc = (camera_cli_s *)camera;
6298 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6299 int get_tilt_step = 0;
6301 if (!pc || !pc->cb_info || !tilt_step) {
6302 LOGE("NULL pointer %p %p", pc, tilt_step);
6303 return CAMERA_ERROR_INVALID_PARAMETER;
6308 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6310 if (ret == CAMERA_ERROR_NONE) {
6311 muse_camera_msg_get(get_tilt_step, pc->cb_info->recv_msg);
6312 *tilt_step = get_tilt_step;
6315 LOGD("ret : 0x%x", ret);
6321 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6323 int ret = CAMERA_ERROR_NONE;
6324 camera_cli_s *pc = (camera_cli_s *)camera;
6325 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6329 if (!pc || !pc->cb_info || !min || !max) {
6330 LOGE("NULL pointer %p %p %p", pc, min, max);
6331 return CAMERA_ERROR_INVALID_PARAMETER;
6336 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6338 if (ret == CAMERA_ERROR_NONE) {
6339 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
6340 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
6345 LOGD("ret : 0x%x", ret);
6351 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6353 int ret = CAMERA_ERROR_NONE;
6354 camera_cli_s *pc = (camera_cli_s *)camera;
6355 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6356 camera_msg_param param;
6357 int set_ptz_type = (int)ptz_type;
6359 if (!pc || !pc->cb_info) {
6360 LOGE("NULL handle");
6361 return CAMERA_ERROR_INVALID_PARAMETER;
6366 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6368 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6370 LOGD("ret : 0x%x", ret);
6376 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6378 int ret = CAMERA_ERROR_NONE;
6379 camera_cli_s *pc = (camera_cli_s *)camera;
6380 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6382 if (!pc || !pc->cb_info || !foreach_cb) {
6383 LOGE("NULL pointer %p %p", pc, foreach_cb);
6384 return CAMERA_ERROR_INVALID_PARAMETER;
6389 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6390 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6392 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6394 LOGD("ret : 0x%x", ret);
6400 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6402 int ret = CAMERA_ERROR_NONE;
6403 camera_cli_s *pc = (camera_cli_s *)camera;
6404 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6405 int set_display_roi_area[4] = {x, y, width, height};
6410 if (!pc || !pc->cb_info) {
6411 LOGE("NULL handle");
6412 return CAMERA_ERROR_INVALID_PARAMETER;
6417 #ifdef TIZEN_FEATURE_EVAS_RENDERER
6418 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6419 g_mutex_lock(&pc->cb_info->evas_mutex);
6421 ret = mm_evas_renderer_set_roi_area(pc->cb_info->evas_info, x, y, width, height);
6423 g_mutex_unlock(&pc->cb_info->evas_mutex);
6425 if (ret != MM_ERROR_NONE) {
6426 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6427 return CAMERA_ERROR_INVALID_OPERATION;
6430 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
6432 length = sizeof(set_display_roi_area) / sizeof(int) + \
6433 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6435 msg = muse_core_msg_json_factory_new(api,
6436 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6439 LOGE("msg creation failed: api %d", api);
6440 return CAMERA_ERROR_OUT_OF_MEMORY;
6443 if (pc->cb_info->is_server_connected)
6444 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
6447 LOGE("message send failed");
6448 ret = CAMERA_ERROR_INVALID_OPERATION;
6450 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6453 muse_core_msg_json_factory_free(msg);
6455 LOGD("ret : 0x%x", ret);
6461 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6463 camera_cli_s *pc = (camera_cli_s *)camera;
6464 int ret = CAMERA_ERROR_NONE;
6465 int get_display_roi_area[4] = {0,};
6466 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6468 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6469 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6470 return CAMERA_ERROR_INVALID_PARAMETER;
6475 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6477 if (ret == CAMERA_ERROR_NONE) {
6478 muse_camera_msg_get_array(get_display_roi_area, pc->cb_info->recv_msg);
6479 *x = get_display_roi_area[0];
6480 *y = get_display_roi_area[1];
6481 *width = get_display_roi_area[2];
6482 *height = get_display_roi_area[3];
6485 LOGD("ret : 0x%x", ret);
6491 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6493 int ret = CAMERA_ERROR_NONE;
6494 int get_device_state = 0;
6497 LOGE("NULL pointer");
6498 return CAMERA_ERROR_INVALID_PARAMETER;
6501 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6502 (int)device, "get_device_state", &get_device_state);
6504 if (ret == CAMERA_ERROR_NONE) {
6505 *state = (camera_device_state_e)get_device_state;
6506 LOGD("device state %d", *state);
6508 LOGE("failed 0x%x", ret);
6515 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6517 int ret = CAMERA_ERROR_NONE;
6518 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6519 camera_cb_info *info = NULL;
6521 if (!callback || !cb_id) {
6522 LOGE("invalid pointer %p %p", callback, cb_id);
6523 return CAMERA_ERROR_INVALID_PARAMETER;
6526 /* check camera support */
6527 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6528 if (ret != CAMERA_ERROR_NONE) {
6529 LOGE("get device state failed");
6533 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6535 info = g_new0(camera_cb_info, 1);
6537 LOGE("info failed");
6538 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6542 info->id = ++g_cam_dev_state_changed_cb_id;
6543 info->callback = (void *)callback;
6547 /* subscribe dbus signal for camera state change */
6548 if (!g_cam_dev_state_changed_cb_conn) {
6549 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6550 if (!g_cam_dev_state_changed_cb_conn) {
6551 LOGE("failed to get gdbus connection");
6552 ret = CAMERA_ERROR_INVALID_OPERATION;
6556 LOGD("subscribe signal %s - %s - %s",
6557 MM_CAMCORDER_DBUS_OBJECT,
6558 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6559 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6561 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6562 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6563 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6564 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6565 LOGE("failed to get gdbus connection");
6566 ret = CAMERA_ERROR_INVALID_OPERATION;
6570 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6573 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6575 LOGD("callback id %d", info->id);
6578 if (ret != CAMERA_ERROR_NONE) {
6584 if (g_cam_dev_state_changed_cb_conn) {
6585 g_object_unref(g_cam_dev_state_changed_cb_conn);
6586 g_cam_dev_state_changed_cb_conn = NULL;
6590 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6596 int camera_remove_device_state_changed_cb(int cb_id)
6598 int ret = CAMERA_ERROR_NONE;
6599 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6600 GList *tmp_list = NULL;
6601 camera_cb_info *info = NULL;
6603 /* check camera support */
6604 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6605 if (ret != CAMERA_ERROR_NONE) {
6606 LOGE("get device state failed");
6610 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6612 if (!g_cam_dev_state_changed_cb_list) {
6613 LOGE("there is no callback info");
6614 ret = CAMERA_ERROR_INVALID_OPERATION;
6618 tmp_list = g_cam_dev_state_changed_cb_list;
6621 info = tmp_list->data;
6622 tmp_list = tmp_list->next;
6629 if (info->id == cb_id) {
6630 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6635 if (!g_cam_dev_state_changed_cb_list) {
6636 /* no remained callback */
6637 if (g_cam_dev_state_changed_cb_conn) {
6638 /* unsubscribe signal */
6639 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6640 g_cam_dev_state_changed_cb_subscribe_id = 0;
6642 /* unref connection */
6643 g_object_unref(g_cam_dev_state_changed_cb_conn);
6644 g_cam_dev_state_changed_cb_conn = NULL;
6648 LOGD("id %d callback removed", cb_id);
6649 ret = CAMERA_ERROR_NONE;
6655 LOGE("id %d callback not found", cb_id);
6656 ret = CAMERA_ERROR_INVALID_PARAMETER;
6659 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);