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 <camera_private.h>
27 #include <muse_core.h>
28 #include <muse_client.h>
30 #include <Elementary.h>
31 #include <tbm_surface_internal.h>
33 #include <Ecore_Wayland.h>
34 #include <wayland-client.h>
35 #include <tizen-extension-client-protocol.h>
36 #ifdef TIZEN_FEATURE_EVAS_RENDERER
37 #include <mm_evas_renderer.h>
38 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
44 #define LOG_TAG "TIZEN_N_CAMERA"
46 /* for device changed callback */
47 static GMutex g_cam_dev_state_changed_cb_lock;
48 static GList *g_cam_dev_state_changed_cb_list;
49 static int g_cam_dev_state_changed_cb_id;
50 static GDBusConnection *g_cam_dev_state_changed_cb_conn;
51 static guint g_cam_dev_state_changed_cb_subscribe_id;
54 static void __global(void *data, struct wl_registry *registry,
55 uint32_t name, const char *interface, uint32_t version)
57 struct tizen_surface **tz_surface = NULL;
64 tz_surface = (struct tizen_surface **)data;
67 LOGW("NULL interface");
71 /*LOGI("interface %s", interface);*/
73 if (strcmp(interface, "tizen_surface") == 0) {
74 LOGD("binding tizen surface for wayland");
76 *tz_surface = wl_registry_bind(registry, name, &tizen_surface_interface, version);
77 if (*tz_surface == NULL)
78 LOGE("failed to bind");
86 static void __global_remove(void *data, struct wl_registry *wl_registry, uint32_t name)
92 static const struct wl_registry_listener _camera_wl_registry_listener = {
97 void __parent_id_getter(void *data, struct tizen_resource *tizen_resource, uint32_t id)
104 *((unsigned int *)data) = id;
106 LOGD("[CLIENT] got parent_id [%u] from server", id);
111 static const struct tizen_resource_listener _camera_tz_resource_listener = {
115 int _camera_get_wl_info(Evas_Object *obj, camera_wl_info_s *wl_info)
117 int ret = CAMERA_ERROR_NONE;
118 Ecore_Wl_Window *window = NULL;
119 struct wl_display *display = NULL;
120 struct wl_display *display_wrapper = NULL;
121 struct wl_surface *surface = NULL;
122 struct wl_registry *registry = NULL;
123 struct wl_event_queue *queue = NULL;
124 struct tizen_surface *tz_surface = NULL;
125 struct tizen_resource *tz_resource = NULL;
127 if (!obj || !wl_info) {
128 LOGE("NULL parameter %p %p", obj, wl_info);
129 return CAMERA_ERROR_INVALID_OPERATION;
132 window = elm_win_wl_window_get(obj);
134 LOGE("failed to get wayland window");
135 ret = CAMERA_ERROR_INVALID_OPERATION;
139 surface = (struct wl_surface *)ecore_wl_window_surface_get(window);
141 LOGE("failed to get wayland surface");
142 ret = CAMERA_ERROR_INVALID_OPERATION;
146 display = (struct wl_display *)ecore_wl_display_get();
148 LOGE("failed to get wayland display");
149 ret = CAMERA_ERROR_INVALID_OPERATION;
153 display_wrapper = wl_proxy_create_wrapper(display);
154 if (!display_wrapper) {
155 LOGE("failed to create wl display wrapper");
156 ret = CAMERA_ERROR_INVALID_OPERATION;
160 queue = wl_display_create_queue(display);
162 LOGE("failed to create wl display queue");
163 ret = CAMERA_ERROR_INVALID_OPERATION;
167 wl_proxy_set_queue((struct wl_proxy *)display_wrapper, queue);
169 registry = wl_display_get_registry(display_wrapper);
171 LOGE("failed to get wayland registry");
172 ret = CAMERA_ERROR_INVALID_OPERATION;
176 wl_registry_add_listener(registry, &_camera_wl_registry_listener, &tz_surface);
178 wl_display_dispatch_queue(display, queue);
179 wl_display_roundtrip_queue(display, queue);
182 LOGE("failed to get tizen surface");
183 ret = CAMERA_ERROR_INVALID_OPERATION;
187 /* Get parent_id which is unique in a entire systemw. */
188 tz_resource = tizen_surface_get_tizen_resource(tz_surface, surface);
190 LOGE("failed to get tizen resurce");
191 ret = CAMERA_ERROR_INVALID_OPERATION;
195 wl_info->parent_id = 0;
197 tizen_resource_add_listener(tz_resource, &_camera_tz_resource_listener, &wl_info->parent_id);
199 wl_display_roundtrip_queue(display, queue);
201 if (wl_info->parent_id > 0) {
203 Ecore_Evas *ecore_evas = NULL;
204 ret = CAMERA_ERROR_NONE;
206 wl_info->evas_obj = obj;
208 evas_object_geometry_get(obj, &wl_info->window_x, &wl_info->window_y,
209 &wl_info->window_width, &wl_info->window_height);
211 ecore_evas = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
213 rotation = ecore_evas_rotation_get(ecore_evas);
214 if (rotation == 90 || rotation == 270) {
215 int temp = wl_info->window_width;
217 LOGD("swap width and height %d, %d", wl_info->window_width, wl_info->window_height);
219 wl_info->window_width = wl_info->window_height;
220 wl_info->window_height = temp;
223 LOGW("failed to get ecore_evas.. skip rotation check");
226 LOGD("evas object : %p, rotation : %d, parent id : %u, window : %d,%d,%dx%d",
227 wl_info->evas_obj, rotation, wl_info->parent_id,
228 wl_info->window_x, wl_info->window_y,
229 wl_info->window_width, wl_info->window_height);
231 ret = CAMERA_ERROR_INVALID_OPERATION;
232 LOGE("failed to get parent id");
237 tizen_surface_destroy(tz_surface);
242 tizen_resource_destroy(tz_resource);
247 wl_registry_destroy(registry);
252 wl_event_queue_destroy(queue);
256 if (display_wrapper) {
257 wl_proxy_wrapper_destroy(display_wrapper);
258 display_wrapper = NULL;
265 static void __camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value)
268 api < 0 || api >= MUSE_CAMERA_API_MAX) {
269 LOGE("invalid param %p %d", cb_info, api);
273 g_mutex_lock(&(cb_info->api_mutex[api]));
274 cb_info->api_waiting[api] += value;
275 g_mutex_unlock(&(cb_info->api_mutex[api]));
277 /*LOGD("api %d, value %d, waiting %d",
278 api, value, cb_info->api_waiting[api]);*/
284 static void __camera_device_state_changed_cb(GDBusConnection *connection,
285 const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
286 const gchar *signal_name, GVariant *param, gpointer user_data)
289 camera_device_e device = CAMERA_DEVICE_CAMERA0;
290 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
291 GList *tmp_list = NULL;
292 camera_cb_info *info = NULL;
294 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
296 if (!g_cam_dev_state_changed_cb_list || !param) {
297 LOGW("no callback or NULL param %p", param);
301 /* get device and state */
302 g_variant_get(param, "(i)", &value);
304 device = value >> 16;
305 state = 0x0000ffff & value;
307 LOGD("device %d, state %d", device, state);
309 tmp_list = g_cam_dev_state_changed_cb_list;
312 info = (camera_cb_info *)tmp_list->data;
315 if (info->callback) {
316 LOGD("start id[%d] callback", info->id);
317 ((camera_device_state_changed_cb)info->callback)(device, state, info->user_data);
318 LOGD("returned id[%d] callback", info->id);
320 LOGW("NULL callback for id %d", info->id);
324 tmp_list = tmp_list->next;
328 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
334 static int _camera_import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle)
336 tbm_bo tmp_bo = NULL;
337 tbm_bo_handle tmp_bo_handle = {NULL, };
339 if (!bufmgr || !bo || !bo_handle || !tbm_key) {
340 LOGE("invalid parameter - %p %p %p, key %d",
341 bufmgr, bo, bo_handle, tbm_key);
345 tmp_bo = tbm_bo_import(bufmgr, tbm_key);
346 if (tmp_bo == NULL) {
347 LOGE("import failed - key %d", tbm_key);
351 tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
352 if (tmp_bo_handle.ptr == NULL) {
353 LOGE("map failed %p", tmp_bo);
354 tbm_bo_unref(tmp_bo);
359 tbm_bo_unmap(tmp_bo);
361 /* set bo and bo_handle */
363 *bo_handle = tmp_bo_handle;
368 static void _camera_release_imported_bo(tbm_bo *bo)
381 static int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
383 int ret = CAMERA_ERROR_NONE;
386 /*LOGD("Enter api : %d", api);*/
388 if (!cb_info->is_server_connected) {
389 LOGE("server is disconnected");
390 return CAMERA_ERROR_SERVICE_DISCONNECTED;
393 g_mutex_lock(&(cb_info->api_mutex[api]));
395 if (cb_info->api_activating[api] == 0) {
396 if (time_out == CAMERA_CB_NO_TIMEOUT) {
397 LOGW("wait for api %d", api);
398 g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
399 ret = cb_info->api_ret[api];
400 cb_info->api_activating[api] = 0;
401 LOGW("api %d returned 0x%x", api, ret);
403 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
404 if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
405 ret = cb_info->api_ret[api];
406 cb_info->api_activating[api] = 0;
407 /*LOGD("return value : 0x%x", ret);*/
409 ret = CAMERA_ERROR_INVALID_OPERATION;
410 LOGE("api %d was TIMED OUT!", api);
414 ret = cb_info->api_ret[api];
415 cb_info->api_activating[api] = 0;
417 /*LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);*/
420 g_mutex_unlock(&(cb_info->api_mutex[api]));
422 if (ret != CAMERA_ERROR_NONE) {
423 LOGE("api %d : error 0x%x", api, ret);
425 if (ret == CAMERA_ERROR_SOUND_POLICY)
426 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
427 else if (ret == CAMERA_ERROR_SOUND_POLICY_BY_CALL)
428 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
429 else if (ret == CAMERA_ERROR_SOUND_POLICY_BY_ALARM)
430 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
437 static void _camera_msg_send(int api, camera_cb_info_s *cb_info,
438 int *ret, int timeout)
444 LOGE("NULL info - api %d", api);
447 *ret = CAMERA_ERROR_INVALID_PARAMETER;
452 msg = muse_core_msg_new(api, NULL);
454 LOGE("msg failed: api %d", api);
457 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
462 /*LOGD("send msg %s", msg);*/
464 if (cb_info->is_server_connected) {
465 __camera_update_api_waiting(cb_info, api, 1);
467 g_mutex_lock(&cb_info->fd_lock);
468 send_ret = muse_core_msg_send(cb_info->fd, msg);
469 g_mutex_unlock(&cb_info->fd_lock);
473 LOGE("msg send failed");
475 *ret = CAMERA_ERROR_INVALID_OPERATION;
478 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
481 __camera_update_api_waiting(cb_info, api, -1);
483 muse_core_msg_free(msg);
489 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
490 int *ret, camera_msg_param *param, int timeout)
495 if (!cb_info || !param) {
496 LOGE("invalid pointer : api %d - %p %p", api, cb_info, param);
499 *ret = CAMERA_ERROR_INVALID_PARAMETER;
504 /*LOGD("type %d, name %s", param->type, param->name);*/
506 switch (param->type) {
508 msg = muse_core_msg_new(api,
509 param->type, param->name, param->value.value_INT,
512 case MUSE_TYPE_STRING:
513 msg = muse_core_msg_new(api,
514 param->type, param->name, param->value.value_STRING,
518 LOGE("unknown type %d", param->type);
523 LOGE("msg failed: api %d", api);
526 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
531 /*LOGD("send msg %s", msg);*/
533 if (cb_info->is_server_connected) {
534 __camera_update_api_waiting(cb_info, api, 1);
536 g_mutex_lock(&cb_info->fd_lock);
537 send_ret = muse_core_msg_send(cb_info->fd, msg);
538 g_mutex_unlock(&cb_info->fd_lock);
542 LOGE("msg send failed");
545 *ret = CAMERA_ERROR_INVALID_OPERATION;
548 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
551 __camera_update_api_waiting(cb_info, api, -1);
553 muse_core_msg_free(msg);
559 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
561 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
562 in_format >= MM_PIXEL_FORMAT_NUM ||
563 out_format == NULL) {
564 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
565 return CAMERA_ERROR_INVALID_PARAMETER;
569 case MM_PIXEL_FORMAT_NV12:
570 case MM_PIXEL_FORMAT_NV12T:
571 *out_format = TBM_FORMAT_NV12;
573 case MM_PIXEL_FORMAT_NV16:
574 *out_format = TBM_FORMAT_NV16;
576 case MM_PIXEL_FORMAT_NV21:
577 *out_format = TBM_FORMAT_NV21;
579 case MM_PIXEL_FORMAT_YUYV:
580 *out_format = TBM_FORMAT_YUYV;
582 case MM_PIXEL_FORMAT_UYVY:
583 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
584 *out_format = TBM_FORMAT_UYVY;
586 case MM_PIXEL_FORMAT_422P:
587 *out_format = TBM_FORMAT_YUV422;
589 case MM_PIXEL_FORMAT_I420:
590 *out_format = TBM_FORMAT_YUV420;
592 case MM_PIXEL_FORMAT_YV12:
593 *out_format = TBM_FORMAT_YVU420;
595 case MM_PIXEL_FORMAT_RGB565:
596 *out_format = TBM_FORMAT_RGB565;
598 case MM_PIXEL_FORMAT_RGB888:
599 *out_format = TBM_FORMAT_RGB888;
601 case MM_PIXEL_FORMAT_RGBA:
602 *out_format = TBM_FORMAT_RGBA8888;
604 case MM_PIXEL_FORMAT_ARGB:
605 *out_format = TBM_FORMAT_ARGB8888;
608 LOGE("invalid in_format %d", in_format);
609 return CAMERA_ERROR_INVALID_PARAMETER;
612 return CAMERA_ERROR_NONE;
616 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
618 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
619 in_format >= MM_PIXEL_FORMAT_NUM ||
621 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
622 return CAMERA_ERROR_INVALID_PARAMETER;
626 case MM_PIXEL_FORMAT_NV12:
627 case MM_PIXEL_FORMAT_NV12T:
628 *mimetype = MEDIA_FORMAT_NV12;
630 case MM_PIXEL_FORMAT_NV16:
631 *mimetype = MEDIA_FORMAT_NV16;
633 case MM_PIXEL_FORMAT_NV21:
634 *mimetype = MEDIA_FORMAT_NV21;
636 case MM_PIXEL_FORMAT_YUYV:
637 *mimetype = MEDIA_FORMAT_YUYV;
639 case MM_PIXEL_FORMAT_UYVY:
640 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
641 *mimetype = MEDIA_FORMAT_UYVY;
643 case MM_PIXEL_FORMAT_422P:
644 *mimetype = MEDIA_FORMAT_422P;
646 case MM_PIXEL_FORMAT_I420:
647 *mimetype = MEDIA_FORMAT_I420;
649 case MM_PIXEL_FORMAT_YV12:
650 *mimetype = MEDIA_FORMAT_YV12;
652 case MM_PIXEL_FORMAT_RGB565:
653 *mimetype = MEDIA_FORMAT_RGB565;
655 case MM_PIXEL_FORMAT_RGB888:
656 *mimetype = MEDIA_FORMAT_RGB888;
658 case MM_PIXEL_FORMAT_RGBA:
659 *mimetype = MEDIA_FORMAT_RGBA;
661 case MM_PIXEL_FORMAT_ARGB:
662 *mimetype = MEDIA_FORMAT_ARGB;
665 LOGE("invalid in_format %d", in_format);
666 return CAMERA_ERROR_INVALID_PARAMETER;
669 return CAMERA_ERROR_NONE;
672 void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_key,
673 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame)
676 unsigned char *buf_pos = NULL;
678 if (stream == NULL || buffer_bo_handle == NULL || frame == NULL) {
679 LOGE("invalid parameter - stream:%p, buffer_bo_handle:%p", stream, buffer_bo_handle);
684 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
685 frame->format = MM_PIXEL_FORMAT_UYVY;
687 frame->format = stream->format;
689 frame->width = stream->width;
690 frame->height = stream->height;
691 frame->timestamp = stream->timestamp;
692 frame->num_of_planes = stream->num_planes;
694 if (num_buffer_key == 0) {
696 if (!data_bo_handle || !data_bo_handle->ptr) {
697 LOGE("NULL pointer");
701 buf_pos = data_bo_handle->ptr;
703 if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) {
704 frame->data.encoded_plane.data = buf_pos;
705 frame->data.encoded_plane.size = stream->data.encoded.length_data;
706 total_size = stream->data.encoded.length_data;
708 switch (stream->num_planes) {
710 frame->data.single_plane.yuv = buf_pos;
711 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
712 total_size = stream->data.yuv420.length_yuv;
715 frame->data.double_plane.y = buf_pos;
716 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
717 buf_pos += stream->data.yuv420sp.length_y;
718 frame->data.double_plane.uv = buf_pos;
719 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
720 total_size = stream->data.yuv420sp.length_y + \
721 stream->data.yuv420sp.length_uv;
724 frame->data.triple_plane.y = buf_pos;
725 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
726 buf_pos += stream->data.yuv420p.length_y;
727 frame->data.triple_plane.u = buf_pos;
728 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
729 buf_pos += stream->data.yuv420p.length_u;
730 frame->data.triple_plane.v = buf_pos;
731 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
732 total_size = stream->data.yuv420p.length_y + \
733 stream->data.yuv420p.length_u + \
734 stream->data.yuv420p.length_v;
742 switch (stream->num_planes) {
744 frame->data.single_plane.yuv = buffer_bo_handle[0].ptr;
745 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
746 total_size = stream->data.yuv420.length_yuv;
749 frame->data.double_plane.y = buffer_bo_handle[0].ptr;
750 if (stream->num_planes == (unsigned int)num_buffer_key)
751 frame->data.double_plane.uv = buffer_bo_handle[1].ptr;
753 frame->data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
754 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
755 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
756 total_size = stream->data.yuv420sp.length_y + \
757 stream->data.yuv420sp.length_uv;
760 frame->data.triple_plane.y = buffer_bo_handle[0].ptr;
761 if (stream->num_planes == (unsigned int)num_buffer_key) {
762 frame->data.triple_plane.u = buffer_bo_handle[1].ptr;
763 frame->data.triple_plane.v = buffer_bo_handle[2].ptr;
765 frame->data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y;
766 frame->data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u;
768 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
769 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
770 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
771 total_size = stream->data.yuv420p.length_y + \
772 stream->data.yuv420p.length_u + \
773 stream->data.yuv420p.length_v;
781 LOGD("format %d, %dx%d, size %d plane num %d",
782 frame.format, frame.width, frame.height, total_size, frame.num_of_planes);
788 int _camera_media_packet_data_create(int tbm_key, int num_buffer_key, tbm_bo bo,
789 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
792 int ret = CAMERA_ERROR_NONE;
793 camera_media_packet_data *tmp_mp_data = NULL;
795 if (*mp_data == NULL) {
796 tmp_mp_data = g_new0(camera_media_packet_data, 1);
798 tmp_mp_data->tbm_key = tbm_key;
799 tmp_mp_data->num_buffer_key = num_buffer_key;
800 tmp_mp_data->bo = bo;
801 tmp_mp_data->data_bo = data_bo;
802 tmp_mp_data->ref_cnt++;
804 for (i = 0 ; i < num_buffer_key ; i++)
805 tmp_mp_data->buffer_bo[i] = buffer_bo[i];
807 *mp_data = tmp_mp_data;
808 /*LOGD("mp_data %p", tmp_mp_data);*/
810 ret = CAMERA_ERROR_OUT_OF_MEMORY;
811 LOGE("failed to alloc media packet data");
814 ((camera_media_packet_data *)*mp_data)->ref_cnt++;
820 void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
824 camera_msg_param param;
826 if (!mp_data || !cb_info) {
827 LOGE("NULL pointer %p %p", mp_data, cb_info);
831 if (mp_data->ref_cnt > 1) {
833 LOGD("ref count %d", mp_data->ref_cnt);
835 /* release imported bo */
836 for (i = 0 ; i < mp_data->num_buffer_key ; i++) {
837 tbm_bo_unref(mp_data->buffer_bo[i]);
838 mp_data->buffer_bo[i] = NULL;
842 _camera_release_imported_bo(&mp_data->bo);
843 _camera_release_imported_bo(&mp_data->data_bo);
846 tbm_key = mp_data->tbm_key;
848 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
850 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
859 int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
860 camera_media_packet_data *mp_data, media_packet_h *packet)
862 media_packet_h pkt = NULL;
863 bool make_pkt_fmt = false;
864 tbm_surface_h tsurf = NULL;
865 tbm_surface_info_s tsurf_info;
866 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
867 uint32_t bo_format = 0;
870 int num_buffer_key = 0;
871 tbm_bo *buffer_bo = NULL;
873 if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) {
874 LOGE("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p",
875 cb_info, stream, mp_data, packet);
876 return CAMERA_ERROR_INVALID_PARAMETER;
879 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
880 buffer_bo = mp_data->buffer_bo;
881 num_buffer_key = mp_data->num_buffer_key;
883 /* create tbm surface */
884 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
885 tsurf_info.planes[i].stride = stream->stride[i];
887 /* get tbm surface format */
888 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
889 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
891 if (ret == CAMERA_ERROR_NONE) {
892 tsurf_info.width = stream->width;
893 tsurf_info.height = stream->height;
894 tsurf_info.format = bo_format;
895 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
896 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
898 if (num_buffer_key > 0) {
900 case TBM_FORMAT_NV12:
901 case TBM_FORMAT_NV21:
902 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
903 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
904 tsurf_info.planes[0].offset = 0;
905 if (num_buffer_key == 1)
906 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
907 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
909 case TBM_FORMAT_YUV420:
910 case TBM_FORMAT_YVU420:
911 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
912 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
913 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
914 tsurf_info.planes[0].offset = 0;
915 if (num_buffer_key == 1) {
916 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
917 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
919 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
921 case TBM_FORMAT_UYVY:
922 case TBM_FORMAT_YUYV:
923 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
924 tsurf_info.planes[0].offset = 0;
925 tsurf_info.size = tsurf_info.planes[0].size;
931 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_key);
932 } else if (mp_data->data_bo) {
934 case TBM_FORMAT_NV12:
935 case TBM_FORMAT_NV21:
936 tsurf_info.planes[0].size = stream->width * stream->height;
937 tsurf_info.planes[1].size = (tsurf_info.planes[0].size) >> 1;
938 tsurf_info.planes[0].offset = 0;
939 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
940 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
942 case TBM_FORMAT_YUV420:
943 case TBM_FORMAT_YVU420:
944 tsurf_info.planes[0].size = stream->width * stream->height;
945 tsurf_info.planes[1].size = (stream->width >> 1) * (stream->height >> 1);
946 tsurf_info.planes[2].size = tsurf_info.planes[1].size;
947 tsurf_info.planes[0].offset = 0;
948 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
949 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
950 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
952 case TBM_FORMAT_UYVY:
953 case TBM_FORMAT_YUYV:
954 tsurf_info.planes[0].size = (stream->width * stream->height) << 1;
955 tsurf_info.planes[0].offset = 0;
956 tsurf_info.size = tsurf_info.planes[0].size;
962 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1);
964 /*LOGD("tbm surface %p", tsurf);*/
968 /* check media packet format */
969 if (cb_info->pkt_fmt) {
970 int pkt_fmt_width = 0;
971 int pkt_fmt_height = 0;
972 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
974 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
975 if (pkt_fmt_mimetype != mimetype ||
976 pkt_fmt_width != stream->width ||
977 pkt_fmt_height != stream->height) {
978 LOGW("change fmt: current 0x%x, %dx%d",
979 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
980 media_format_unref(cb_info->pkt_fmt);
981 cb_info->pkt_fmt = NULL;
988 /* create packet format */
990 LOGW("make new pkt_fmt - 0x%x, %dx%d", mimetype, stream->width, stream->height);
991 ret = media_format_create(&cb_info->pkt_fmt);
992 if (ret == MEDIA_FORMAT_ERROR_NONE) {
993 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
994 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
995 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
996 LOGW("media_format_set : 0x%x", ret);
998 LOGW("media_format_create failed 0x%x", ret);
1002 /* create media packet */
1003 ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt,
1004 tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
1005 (void *)cb_info, &pkt);
1006 if (ret != MEDIA_PACKET_ERROR_NONE) {
1007 LOGE("media_packet_create failed 0x%x", ret);
1008 tbm_surface_destroy(tsurf);
1012 LOGE("tbm surface failed. %dx%d, format %d, num_buffer_key %d, data_bo %p",
1013 stream->width, stream->height, stream->format, num_buffer_key, mp_data->data_bo);
1017 /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
1018 /* set media packet data */
1019 ret = media_packet_set_extra(pkt, (void *)mp_data);
1020 if (ret != MEDIA_PACKET_ERROR_NONE) {
1021 LOGE("media_packet_set_extra failed");
1023 _camera_media_packet_data_release(mp_data, cb_info);
1026 media_packet_destroy(pkt);
1029 /* set timestamp : msec -> nsec */
1030 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
1031 LOGW("media_packet_set_pts failed");
1040 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
1043 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1044 camera_media_packet_data *mp_data = NULL;
1045 tbm_surface_h tsurf = NULL;
1047 if (!pkt || !cb_info) {
1048 LOGE("NULL pointer %p %p", pkt, cb_info);
1049 return MEDIA_PACKET_FINALIZE;
1052 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1053 if (ret != MEDIA_PACKET_ERROR_NONE) {
1054 LOGE("media_packet_get_extra failed 0x%x", ret);
1055 return MEDIA_PACKET_FINALIZE;
1058 /*LOGD("mp_data %p", mp_data);*/
1060 g_mutex_lock(&cb_info->mp_data_mutex);
1062 _camera_media_packet_data_release(mp_data, cb_info);
1065 g_mutex_unlock(&cb_info->mp_data_mutex);
1067 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1068 if (ret != MEDIA_PACKET_ERROR_NONE)
1069 LOGE("get tbm_surface failed 0x%x", ret);
1072 tbm_surface_destroy(tsurf);
1076 return MEDIA_PACKET_FINALIZE;
1079 static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event)
1085 tbm_bo_handle bo_handle = {NULL, };
1086 camera_msg_param param;
1088 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1089 LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event);
1093 /*LOGD("get camera msg %s, event %d", recv_msg, event);*/
1095 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1096 if (!(CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) &&
1097 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] == NULL &&
1098 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] == NULL) {
1099 /* return preview callback */
1100 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info, NULL, 0);
1103 muse_camera_msg_get(tbm_key, recv_msg);
1104 LOGW("all preview callback from user are NULL - return key %d", tbm_key);
1106 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1107 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1111 } else if (cb_info->user_cb[event] == NULL) {
1112 LOGW("user callback for event %d is not set", event);
1117 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1123 muse_camera_msg_get(previous, recv_msg);
1124 muse_camera_msg_get(current, recv_msg);
1125 muse_camera_msg_get(by_policy, recv_msg);
1127 LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
1128 previous, current, by_policy);
1130 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1131 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1134 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1138 muse_camera_msg_get(state, recv_msg);
1140 LOGD("FOCUS state - %d", state);
1142 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1145 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1146 LOGD("CAPTURE_COMPLETED");
1147 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1149 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1150 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1154 int num_buffer_key = 0;
1155 int buffer_key[BUFFER_MAX_PLANE_NUM] = {0, };
1157 unsigned char *buf_pos = NULL;
1159 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
1160 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
1161 tbm_bo data_bo = NULL;
1162 tbm_bo_handle data_bo_handle = {.ptr = NULL};
1164 camera_preview_data_s frame;
1165 camera_stream_data_s *stream = NULL;
1166 camera_media_packet_data *mp_data = NULL;
1167 media_packet_h pkt = NULL;
1168 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1169 media_packet_h pkt_evas = NULL;
1170 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1172 muse_camera_msg_get(tbm_key, recv_msg);
1173 muse_camera_msg_get(num_buffer_key, recv_msg);
1174 muse_camera_msg_get_array(buffer_key, recv_msg);
1175 muse_camera_msg_get(data_key, recv_msg);
1177 memset(&frame, 0x0, sizeof(camera_preview_data_s));
1180 LOGE("invalid key %d", tbm_key);
1184 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1186 if (num_buffer_key < 0 || num_buffer_key > BUFFER_MAX_PLANE_NUM) {
1187 LOGE("invalid num buffer key %d", num_buffer_key);
1188 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1193 /* import tbm data_bo and get virtual address */
1194 if (!_camera_import_tbm_key(cb_info->bufmgr, data_key, &data_bo, &data_bo_handle)) {
1195 LOGE("failed to import data key %d", data_key);
1196 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1201 /* import tbm bo and get virtual address */
1202 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
1203 LOGE("failed to import key %d", tbm_key);
1204 _camera_release_imported_bo(&data_bo);
1205 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1209 buf_pos = (unsigned char *)bo_handle.ptr;
1211 /* get stream info */
1212 stream = (camera_stream_data_s *)buf_pos;
1214 for (i = 0 ; i < num_buffer_key ; i++) {
1215 /* import buffer bo and get virtual address */
1216 if (!_camera_import_tbm_key(cb_info->bufmgr, buffer_key[i], &buffer_bo[i], &buffer_bo_handle[i])) {
1217 LOGE("failed to import buffer key %d", buffer_key[i]);
1219 /* release imported bo */
1220 _camera_release_imported_bo(&data_bo);
1221 _camera_release_imported_bo(&bo);
1223 for (i -= 1 ; i >= 0 ; i--)
1224 _camera_release_imported_bo(&buffer_bo[i]);
1226 /* send return buffer */
1227 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1233 /* call preview callback */
1234 g_mutex_lock(&cb_info->preview_cb_mutex);
1236 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
1237 _camera_preview_frame_create(stream, num_buffer_key, buffer_bo_handle, &data_bo_handle, &frame);
1239 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
1240 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
1243 g_mutex_unlock(&cb_info->preview_cb_mutex);
1245 if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
1246 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1247 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
1249 if (ret == CAMERA_ERROR_NONE) {
1250 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt_evas);
1251 if (ret != CAMERA_ERROR_NONE) {
1252 LOGE("create pkt for evas failed");
1253 _camera_media_packet_data_release(mp_data, cb_info);
1257 #else /* TIZEN_FEATURE_EVAS_RENDERER */
1258 LOGW("evas renderer is not supported");
1259 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1262 /* call media packet callback */
1263 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
1264 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
1266 if (ret == CAMERA_ERROR_NONE) {
1267 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt);
1269 if (ret == CAMERA_ERROR_NONE) {
1270 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
1271 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
1273 _camera_media_packet_data_release(mp_data, cb_info);
1279 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1280 /* call evas renderer */
1282 g_mutex_lock(&cb_info->evas_mutex);
1283 if (cb_info->run_evas_render) {
1284 mm_evas_renderer_write(pkt_evas, cb_info->evas_info);
1286 LOGW("evas renderer is stopped, skip this buffer...");
1287 media_packet_destroy(pkt_evas);
1290 g_mutex_unlock(&cb_info->evas_mutex);
1292 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1294 /* send message for preview callback return */
1295 if (!CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS))
1296 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info, NULL, 0);
1298 if (mp_data == NULL) {
1299 /* release imported bo */
1300 for (i = 0 ; i < num_buffer_key ; i++)
1301 _camera_release_imported_bo(&buffer_bo[i]);
1303 /* unmap and unref tbm bo */
1304 _camera_release_imported_bo(&data_bo);
1305 _camera_release_imported_bo(&bo);
1308 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1310 /*LOGD("return buffer Done");*/
1314 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1318 muse_camera_msg_get(percent, recv_msg);
1320 LOGD("HDR progress - %d \%", percent);
1322 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1325 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1331 muse_camera_msg_get(policy, recv_msg);
1332 muse_camera_msg_get(previous, recv_msg);
1333 muse_camera_msg_get(current, recv_msg);
1335 LOGW("INTERRUPTED - policy %d, state previous %d, current %d",
1336 policy, previous, current);
1338 if (policy == CAMERA_POLICY_SOUND)
1339 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND is deprecated and will be removed from next release.");
1340 else if (policy == CAMERA_POLICY_SOUND_BY_CALL)
1341 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_CALL is deprecated and will be removed from next release.");
1342 else if (policy == CAMERA_POLICY_SOUND_BY_ALARM)
1343 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_ALARM is deprecated and will be removed from next release.");
1345 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1346 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1349 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1354 muse_camera_msg_get(policy, recv_msg);
1355 muse_camera_msg_get(state, recv_msg);
1357 LOGW("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1359 if (policy == CAMERA_POLICY_SOUND)
1360 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND is deprecated and will be removed from next release.");
1361 else if (policy == CAMERA_POLICY_SOUND_BY_CALL)
1362 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_CALL is deprecated and will be removed from next release.");
1363 else if (policy == CAMERA_POLICY_SOUND_BY_ALARM)
1364 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_ALARM is deprecated and will be removed from next release.");
1366 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1367 (camera_state_e)state, cb_info->user_data[event]);
1370 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1373 camera_detected_face_s *faces = NULL;
1375 muse_camera_msg_get(count, recv_msg);
1376 muse_camera_msg_get(tbm_key, recv_msg);
1379 LOGD("FACE_DETECTION - count %d, tbm_key %d", count, tbm_key);
1383 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
1385 faces = bo_handle.ptr;
1389 ((camera_face_detected_cb)cb_info->user_cb[event])(faces, count, cb_info->user_data[event]);
1392 _camera_release_imported_bo(&bo);
1396 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1397 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1398 /*LOGD("return buffer done");*/
1401 LOGE("invalid message - count %d, key %d", count, tbm_key);
1405 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1408 int current_state = 0;
1410 muse_camera_msg_get(error, recv_msg);
1411 muse_camera_msg_get(current_state, recv_msg);
1413 LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
1415 if (error == CAMERA_ERROR_SOUND_POLICY)
1416 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
1417 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_CALL)
1418 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
1419 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_ALARM)
1420 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
1422 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1423 (camera_state_e)current_state, cb_info->user_data[event]);
1426 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1428 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1429 muse_camera_msg_get(param1, recv_msg);
1430 muse_camera_msg_get(param2, recv_msg);
1432 /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/
1434 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1435 cb_info->user_cb[event] = NULL;
1436 cb_info->user_data[event] = NULL;
1437 LOGW("stop foreach callback for event %d", event);
1440 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1442 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1444 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1446 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1448 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1450 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1452 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1454 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1456 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1458 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1460 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1462 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1464 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1466 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1468 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1469 muse_camera_msg_get(param1, recv_msg);
1471 /*LOGD("event %d SUPPORTED %d ", event, param1);*/
1473 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1474 cb_info->user_cb[event] = NULL;
1475 cb_info->user_data[event] = NULL;
1476 LOGW("stop foreach callback for event %d", event);
1479 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1481 camera_image_data_s *rImage = NULL;
1482 camera_image_data_s *rPostview = NULL;
1483 camera_image_data_s *rThumbnail = NULL;
1484 unsigned char *buf_pos = NULL;
1485 int tbm_key_main = 0;
1486 int tbm_key_post = 0;
1487 int tbm_key_thumb = 0;
1488 tbm_bo bo_main = NULL;
1489 tbm_bo bo_post = NULL;
1490 tbm_bo bo_thumb = NULL;
1491 tbm_bo_handle bo_main_handle = {NULL, };
1492 tbm_bo_handle bo_post_handle = {NULL, };
1493 tbm_bo_handle bo_thumb_handle = {NULL, };
1495 muse_camera_msg_get(tbm_key_main, recv_msg);
1496 muse_camera_msg_get(tbm_key_post, recv_msg);
1497 muse_camera_msg_get(tbm_key_thumb, recv_msg);
1500 LOGD("camera capture callback came in. tbm_key_main %d, tbm_key_post %d, tbm_key_thumb %d",
1501 tbm_key_main, tbm_key_post, tbm_key_thumb);
1504 if (tbm_key_main <= 0) {
1505 LOGE("invalid key %d", tbm_key_main);
1509 /* import tbm bo and get virtual address */
1510 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_main, &bo_main, &bo_main_handle))
1513 buf_pos = (unsigned char *)bo_main_handle.ptr;
1514 rImage = (camera_image_data_s *)buf_pos;
1515 rImage->data = buf_pos + sizeof(camera_image_data_s);
1516 if (rImage->exif && rImage->exif_size > 0) {
1517 rImage->exif = rImage->data + rImage->size;
1519 rImage->exif = NULL;
1520 rImage->exif_size = 0;
1523 LOGD("image info %dx%d, size %d, EXIF info %p, size %d",
1524 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
1526 if (tbm_key_post > 0) {
1527 /* import tbm bo and get virtual address */
1528 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_post, &bo_post, &bo_post_handle))
1531 buf_pos = (unsigned char *)bo_post_handle.ptr;
1532 rPostview = (camera_image_data_s *)buf_pos;
1533 LOGD("rPostview->size : %d", rPostview->size);
1534 rPostview->data = buf_pos + sizeof(camera_image_data_s);
1537 if (tbm_key_thumb > 0) {
1538 /* import tbm bo and get virtual address */
1539 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_thumb, &bo_thumb, &bo_thumb_handle))
1542 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
1544 rThumbnail = (camera_image_data_s *)buf_pos;
1545 LOGD("rThumbnail->size : %d", rThumbnail->size);
1546 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
1549 ((camera_capturing_cb)cb_info->user_cb[event])(rImage, rPostview, rThumbnail, cb_info->user_data[event]);
1551 /* unmap and unref tbm bo */
1552 _camera_release_imported_bo(&bo_main);
1555 tbm_key = tbm_key_main;
1557 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1559 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1561 if (tbm_key_post > 0) {
1562 /* unmap and unref tbm bo */
1563 _camera_release_imported_bo(&bo_post);
1566 param.value.value_INT = tbm_key_post;
1567 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1570 if (tbm_key_thumb > 0) {
1571 /* unmap and unref tbm bo */
1572 _camera_release_imported_bo(&bo_thumb);
1575 param.value.value_INT = tbm_key_thumb;
1576 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1579 LOGD("return buffer done");
1583 LOGW("unhandled event %d", event);
1590 static bool _camera_idle_event_callback(void *data)
1592 camera_cb_info_s *cb_info = NULL;
1593 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1595 if (cam_idle_event == NULL) {
1596 LOGE("cam_idle_event is NULL");
1601 g_mutex_lock(&cam_idle_event->event_mutex);
1603 cb_info = cam_idle_event->cb_info;
1604 if (cb_info == NULL) {
1605 LOGW("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1606 goto IDLE_EVENT_CALLBACK_DONE;
1609 /* remove event from list */
1610 g_mutex_lock(&cb_info->idle_event_mutex);
1612 if (cb_info->idle_event_list)
1613 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1615 /*LOGD("remove camera idle event %p, %p", cam_idle_event, cb_info->idle_event_list);*/
1616 g_mutex_unlock(&cb_info->idle_event_mutex);
1619 _camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
1621 /* send signal for waiting thread */
1622 g_cond_signal(&cb_info->idle_event_cond);
1624 IDLE_EVENT_CALLBACK_DONE:
1625 /* unlock and release event */
1626 g_mutex_unlock(&cam_idle_event->event_mutex);
1627 g_mutex_clear(&cam_idle_event->event_mutex);
1629 g_free(cam_idle_event);
1630 cam_idle_event = NULL;
1635 static void *_camera_msg_handler_func(gpointer data)
1639 camera_message_s *cam_msg = NULL;
1640 camera_idle_event_s *cam_idle_event = NULL;
1641 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1642 camera_cb_info_s *cb_info = NULL;
1644 if (!handler_info || !handler_info->cb_info) {
1645 LOGE("NULL handler %p", handler_info);
1649 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1650 type = handler_info->type;
1652 LOGD("t:%d start", type);
1654 g_mutex_lock(&handler_info->mutex);
1656 while (g_atomic_int_get(&handler_info->running)) {
1657 if (g_queue_is_empty(handler_info->queue)) {
1658 /*LOGD("t:%d signal wait...", type);*/
1659 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1660 /*LOGD("t:%d signal received", type);*/
1662 if (g_atomic_int_get(&handler_info->running) == 0) {
1663 LOGD("t:%d stop event thread", type);
1668 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1670 g_mutex_unlock(&handler_info->mutex);
1672 if (cam_msg == NULL) {
1673 LOGE("t:%d NULL message", type);
1674 g_mutex_lock(&handler_info->mutex);
1680 if (api < MUSE_CAMERA_API_MAX) {
1683 g_mutex_lock(&cb_info->api_mutex[api]);
1685 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1686 if (cb_info->api_waiting[api] > 0) {
1687 cb_info->api_ret[api] = ret;
1688 cb_info->api_activating[api] = 1;
1690 /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
1692 g_cond_signal(&cb_info->api_cond[api]);
1694 LOGW("no waiting for this api [%d]", api);
1697 LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1700 g_mutex_unlock(&cb_info->api_mutex[api]);
1701 } else if (api == MUSE_CAMERA_CB_EVENT) {
1702 switch (cam_msg->event_class) {
1703 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1704 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event);
1706 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1707 cam_idle_event = g_new0(camera_idle_event_s, 1);
1708 if (cam_idle_event == NULL) {
1709 LOGE("t:%d cam_idle_event alloc failed", type);
1713 cam_idle_event->event = cam_msg->event;
1714 cam_idle_event->cb_info = cb_info;
1715 g_mutex_init(&cam_idle_event->event_mutex);
1716 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg) - 1);
1718 /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, cam_msg->event, cam_idle_event);*/
1720 g_mutex_lock(&cb_info->idle_event_mutex);
1721 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1722 g_mutex_unlock(&cb_info->idle_event_mutex);
1724 g_idle_add_full(G_PRIORITY_DEFAULT,
1725 (GSourceFunc)_camera_idle_event_callback,
1726 (gpointer)cam_idle_event,
1730 LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
1734 LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1740 g_mutex_lock(&handler_info->mutex);
1743 /* remove remained event */
1744 while (!g_queue_is_empty(handler_info->queue)) {
1745 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1747 LOGD("t:%d remove camera message %p", type, cam_msg);
1751 LOGW("t:%d NULL camera message", type);
1755 g_mutex_unlock(&handler_info->mutex);
1757 LOGD("t:%d return", type);
1763 static void _camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1765 camera_idle_event_s *cam_idle_event = NULL;
1767 gint64 end_time = 0;
1769 if (cb_info == NULL) {
1770 LOGE("cb_info is NULL");
1774 g_mutex_lock(&cb_info->idle_event_mutex);
1776 if (cb_info->idle_event_list == NULL) {
1777 LOGD("No remained idle event");
1778 g_mutex_unlock(&cb_info->idle_event_mutex);
1782 list = cb_info->idle_event_list;
1785 cam_idle_event = list->data;
1786 list = g_list_next(list);
1788 if (!cam_idle_event) {
1789 LOGW("Fail to remove idle event. The event is NULL");
1793 if (!g_mutex_trylock(&cam_idle_event->event_mutex)) {
1794 LOGW("lock failed, %p event is calling now", cam_idle_event);
1796 end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
1798 if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
1799 LOGW("signal received");
1806 LOGW("set NULL cb_info for event %p %d, it will be freed on idle callback",
1807 cam_idle_event, cam_idle_event->event);
1809 cam_idle_event->cb_info = NULL;
1811 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1813 g_mutex_unlock(&cam_idle_event->event_mutex);
1816 g_list_free(cb_info->idle_event_list);
1817 cb_info->idle_event_list = NULL;
1819 g_mutex_unlock(&cb_info->idle_event_mutex);
1825 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg)
1827 camera_message_s *cam_msg = NULL;
1829 if (!cb_info || !msg) {
1830 LOGE("NULL pointer %p %p", cb_info, msg);
1834 cam_msg = g_new0(camera_message_s, 1);
1836 LOGE("failed to alloc cam_msg for [%s]", msg);
1841 cam_msg->event = event;
1842 cam_msg->event_class = event_class;
1844 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1846 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1848 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1849 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1850 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1851 g_cond_signal(&cb_info->preview_cb_info.cond);
1852 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1853 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1854 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1855 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1856 g_cond_signal(&cb_info->capture_cb_info.cond);
1857 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1859 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1860 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1861 g_cond_signal(&cb_info->msg_handler_info.cond);
1862 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1871 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg)
1873 int ret = CAMERA_ERROR_NONE;
1877 int event_class = -1;
1881 if (!cb_info || !msg) {
1882 LOGE("invalid ptr %p %p", cb_info, msg);
1886 /*LOGD("msg [%s]", msg);*/
1888 if (!muse_camera_msg_get(api, msg)) {
1889 LOGE("failed to get camera api");
1893 if (api == MUSE_CAMERA_CB_EVENT) {
1894 if (!muse_camera_msg_get(event, msg) ||
1895 !muse_camera_msg_get(event_class, msg)) {
1896 LOGE("failed to get camera event or event_class [%s]", msg);
1900 if (!muse_camera_msg_get(api_class, msg)) {
1901 LOGE("failed to get camera api_class [%s]", msg);
1906 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1907 if (api >= MUSE_CAMERA_API_MAX) {
1908 LOGE("invalid api %d", api);
1912 if (!muse_camera_msg_get(ret, msg)) {
1913 LOGE("failed to get camera ret");
1917 g_mutex_lock(&cb_info->api_mutex[api]);
1920 case MUSE_CAMERA_API_CREATE:
1921 if (ret != CAMERA_ERROR_NONE) {
1922 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1923 LOGE("camera create error 0x%x. close client cb handler", ret);
1926 case MUSE_CAMERA_API_DESTROY:
1927 if (ret == CAMERA_ERROR_NONE) {
1928 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1929 LOGD("camera destroy done. close client cb handler");
1933 muse_camera_msg_get(get_type, msg);
1934 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1935 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1936 muse_camera_msg_get(get_index, msg);
1939 case MUSE_CAMERA_GET_TYPE_INT:
1940 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
1942 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1943 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
1944 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
1946 case MUSE_CAMERA_GET_TYPE_ARRAY:
1947 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
1948 muse_core_msg_deserialize("get_value",
1949 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
1950 LOGD("get display roi %d,%d,%dx%d",
1951 cb_info->get_display_roi_area[0],
1952 cb_info->get_display_roi_area[1],
1953 cb_info->get_display_roi_area[2],
1954 cb_info->get_display_roi_area[3]);
1956 muse_core_msg_deserialize("get_value",
1957 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
1958 LOGD("get geotag %lf, %lf, %lf",
1959 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
1962 case MUSE_CAMERA_GET_TYPE_STRING:
1963 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
1966 LOGW("unknown type %d", get_type);
1973 if (cb_info->api_waiting[api] > 0) {
1974 cb_info->api_ret[api] = ret;
1975 cb_info->api_activating[api] = 1;
1977 g_cond_signal(&cb_info->api_cond[api]);
1979 LOGW("no waiting for this api [%d]", api);
1982 g_mutex_unlock(&cb_info->api_mutex[api]);
1983 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
1984 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg);
1986 LOGW("unknown camera api %d, class %d", api, api_class);
1993 static void *_camera_msg_recv_func(gpointer data)
1995 int recv_length = 0;
1996 int single_length = 0;
1997 int remained_length = 0;
1998 char *recv_msg = NULL;
1999 char *single_msg = NULL;
2000 char *remained_msg = NULL;
2004 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
2007 LOGE("cb_info NULL");
2013 single_msg = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
2015 LOGE("single_msg malloc failed");
2019 recv_msg = cb_info->recv_msg;
2021 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
2022 recv_length = muse_core_msg_recv(cb_info->fd, recv_msg);
2023 if (recv_length <= 0) {
2024 cb_info->is_server_connected = FALSE;
2025 LOGE("receive msg failed - server disconnected");
2033 /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
2035 /* Need to split the combined entering msgs */
2036 for (cur_pos = 0 ; cur_pos < recv_length ; cur_pos++) {
2037 if (recv_msg[cur_pos] == '}') {
2038 single_length = cur_pos - prev_pos + 1;
2040 if (single_length < MUSE_CAMERA_MSG_MAX_LENGTH) {
2041 /* check remained msg */
2042 if (remained_length > 0) {
2044 strncpy(single_msg, remained_msg, remained_length);
2045 strncpy(single_msg + remained_length, recv_msg + prev_pos, single_length);
2046 single_msg[remained_length + single_length] = '\0';
2049 remained_msg = NULL;
2051 strncpy(single_msg, recv_msg + prev_pos, single_length);
2052 single_msg[single_length] = '\0';
2053 LOGE("lost msg [%s], skip...", single_msg);
2056 remained_length = 0;
2058 strncpy(single_msg, recv_msg + prev_pos, single_length);
2059 single_msg[single_length] = '\0';
2062 if (single_msg[0] == '{') {
2064 /*LOGD("splitted msg : [%s], Index : %d", single_msg, num_msg);*/
2065 /* process each message */
2066 __camera_process_msg(cb_info, single_msg);
2068 LOGE("invalid msg [%s]", single_msg);
2071 LOGE("too long message [len %d] skip...", single_length);
2074 prev_pos = cur_pos + 1;
2078 /* check incompleted message */
2079 if (recv_msg[recv_length - 1] != '}') {
2080 remained_length = recv_length - prev_pos;
2082 LOGW("incompleted message [len %d]", remained_length);
2084 remained_msg = (char *)malloc(remained_length + 1);
2086 strncpy(remained_msg, recv_msg + prev_pos, remained_length);
2087 remained_msg[remained_length] = '\0';
2089 LOGE("failed to alloc for remained msg");
2092 remained_length = 0;
2096 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
2098 if (!cb_info->is_server_connected) {
2099 /* send error msg for server disconnection */
2100 char *error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
2101 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
2102 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
2106 LOGE("error_msg failed");
2107 goto CB_HANDLER_EXIT;
2110 __camera_add_msg_to_queue(cb_info,
2111 MUSE_CAMERA_CB_EVENT,
2112 MUSE_CAMERA_EVENT_TYPE_ERROR,
2113 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
2116 muse_core_msg_free(error_msg);
2119 LOGE("add error msg for service disconnection done");
2130 remained_msg = NULL;
2137 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2138 int type, const char *thread_name, camera_cb_info_s *cb_info)
2140 if (!handler_info || !thread_name || !cb_info) {
2141 LOGE("t:%d NULL %p %p %p",
2142 type, handler_info, thread_name, cb_info);
2148 handler_info->type = type;
2149 handler_info->queue = g_queue_new();
2150 if (handler_info->queue == NULL) {
2151 LOGE("t:%d queue failed", type);
2155 g_mutex_init(&handler_info->mutex);
2156 g_cond_init(&handler_info->cond);
2158 handler_info->cb_info = (void *)cb_info;
2159 g_atomic_int_set(&handler_info->running, 1);
2161 handler_info->thread = g_thread_try_new(thread_name,
2162 _camera_msg_handler_func, (gpointer)handler_info, NULL);
2163 if (handler_info->thread == NULL) {
2164 LOGE("t:%d thread failed", type);
2166 g_mutex_clear(&handler_info->mutex);
2167 g_cond_clear(&handler_info->cond);
2168 g_queue_free(handler_info->queue);
2169 handler_info->queue = NULL;
2174 LOGD("t:%d done", type);
2180 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2184 if (!handler_info) {
2185 LOGE("NULL handler");
2189 if (!handler_info->thread) {
2190 LOGW("thread is not created");
2194 type = handler_info->type;
2196 LOGD("t:%d thread %p", type, handler_info->thread);
2198 g_mutex_lock(&handler_info->mutex);
2199 g_atomic_int_set(&handler_info->running, 0);
2200 g_cond_signal(&handler_info->cond);
2201 g_mutex_unlock(&handler_info->mutex);
2203 g_thread_join(handler_info->thread);
2204 handler_info->thread = NULL;
2206 g_mutex_clear(&handler_info->mutex);
2207 g_cond_clear(&handler_info->cond);
2208 g_queue_free(handler_info->queue);
2209 handler_info->queue = NULL;
2211 LOGD("t:%d done", type);
2217 static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
2219 camera_cb_info_s *cb_info = NULL;
2222 g_return_val_if_fail(sockfd > 0, NULL);
2224 cb_info = g_new0(camera_cb_info_s, 1);
2225 if (cb_info == NULL) {
2226 LOGE("cb_info failed");
2230 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2232 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2233 g_mutex_init(&cb_info->api_mutex[i]);
2234 g_cond_init(&cb_info->api_cond[i]);
2237 g_mutex_init(&cb_info->fd_lock);
2238 g_mutex_init(&cb_info->idle_event_mutex);
2239 g_cond_init(&cb_info->idle_event_cond);
2240 g_mutex_init(&cb_info->mp_data_mutex);
2241 g_mutex_init(&cb_info->preview_cb_mutex);
2242 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2243 g_mutex_init(&cb_info->evas_mutex);
2244 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2246 /* message handler thread */
2247 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2248 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2249 LOGE("msg_handler_info failed");
2253 /* message handler thread for preview callback */
2254 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2255 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2256 LOGE("preview_cb_info failed");
2260 /* message handler thread for capture callback */
2261 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2262 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2263 LOGE("capture_cb_info failed");
2267 cb_info->fd = sockfd;
2268 cb_info->preview_cb_flag = 0;
2269 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2270 cb_info->evas_info = NULL;
2271 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2273 /* message receive thread */
2274 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2275 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2276 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2277 if (cb_info->msg_recv_thread == NULL) {
2278 LOGE("message receive thread creation failed");
2282 cb_info->is_server_connected = TRUE;
2288 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2289 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2290 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2292 g_mutex_clear(&cb_info->fd_lock);
2293 g_mutex_clear(&cb_info->idle_event_mutex);
2294 g_cond_clear(&cb_info->idle_event_cond);
2295 g_mutex_clear(&cb_info->mp_data_mutex);
2296 g_mutex_clear(&cb_info->preview_cb_mutex);
2297 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2298 g_mutex_clear(&cb_info->evas_mutex);
2299 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2301 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2302 g_mutex_clear(&cb_info->api_mutex[i]);
2303 g_cond_clear(&cb_info->api_cond[i]);
2313 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2317 g_return_if_fail(cb_info != NULL);
2319 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2321 g_thread_join(cb_info->msg_recv_thread);
2322 cb_info->msg_recv_thread = NULL;
2324 LOGD("msg_recv thread removed");
2326 /* destroy msg handler threads */
2327 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2328 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2329 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2331 g_mutex_clear(&cb_info->fd_lock);
2332 g_mutex_clear(&cb_info->idle_event_mutex);
2333 g_cond_clear(&cb_info->idle_event_cond);
2334 g_mutex_clear(&cb_info->mp_data_mutex);
2335 g_mutex_clear(&cb_info->preview_cb_mutex);
2336 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2337 g_mutex_clear(&cb_info->evas_mutex);
2338 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2340 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2341 g_mutex_clear(&cb_info->api_mutex[i]);
2342 g_cond_clear(&cb_info->api_cond[i]);
2345 if (cb_info->fd > -1) {
2346 muse_core_connection_close(cb_info->fd);
2350 if (cb_info->bufmgr) {
2351 tbm_bufmgr_deinit(cb_info->bufmgr);
2352 cb_info->bufmgr = NULL;
2354 if (cb_info->pkt_fmt) {
2355 media_format_unref(cb_info->pkt_fmt);
2356 cb_info->pkt_fmt = NULL;
2359 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2360 if (cb_info->evas_info)
2361 mm_evas_renderer_destroy(&cb_info->evas_info);
2362 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2364 cb_info->preview_cb_flag = 0;
2373 int _camera_start_evas_rendering(camera_h camera)
2375 int ret = CAMERA_ERROR_NONE;
2376 camera_cli_s *pc = (camera_cli_s *)camera;
2378 if (!pc || !pc->cb_info) {
2379 LOGE("NULL handle");
2380 return CAMERA_ERROR_INVALID_PARAMETER;
2385 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2386 LOGE("EVAS surface is not set");
2387 return CAMERA_ERROR_NONE;
2390 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2391 g_mutex_lock(&pc->cb_info->evas_mutex);
2393 /* set evas render flag as RUN */
2394 pc->cb_info->run_evas_render = true;
2395 ret = CAMERA_ERROR_NONE;
2397 g_mutex_unlock(&pc->cb_info->evas_mutex);
2398 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2399 LOGW("evas renderer is not supported");
2400 ret = CAMERA_ERROR_NOT_SUPPORTED;
2401 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2407 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2409 int ret = CAMERA_ERROR_NONE;
2410 camera_cli_s *pc = (camera_cli_s *)camera;
2412 if (!pc || !pc->cb_info) {
2413 LOGE("NULL handle");
2414 return CAMERA_ERROR_INVALID_PARAMETER;
2417 LOGD("stop - keep screen %d", keep_screen);
2419 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2420 LOGE("EVAS surface is not set");
2421 return CAMERA_ERROR_NONE;
2424 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2425 g_mutex_lock(&pc->cb_info->evas_mutex);
2427 /* set evas render flag as STOP and release buffers */
2428 pc->cb_info->run_evas_render = false;
2430 ret = mm_evas_renderer_retrieve_all_packets(pc->cb_info->evas_info, keep_screen);
2431 if (ret != MM_ERROR_NONE) {
2432 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2433 ret = CAMERA_ERROR_INVALID_OPERATION;
2436 g_mutex_unlock(&pc->cb_info->evas_mutex);
2437 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2438 LOGW("evas renderer is not supported");
2439 ret = CAMERA_ERROR_NOT_SUPPORTED;
2440 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2446 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2448 int ret = CAMERA_ERROR_NONE;
2451 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2453 /* create muse connection */
2454 if (!key || !value) {
2455 LOGE("NULL pointer");
2456 return CAMERA_ERROR_INVALID_PARAMETER;
2459 sock_fd = muse_client_new();
2461 LOGE("muse_client_new failed");
2462 return CAMERA_ERROR_INVALID_OPERATION;
2465 msg = muse_core_msg_new(api,
2466 MUSE_TYPE_INT, "module", MUSE_CAMERA,
2467 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2471 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2475 ret = muse_core_msg_send(sock_fd, msg);
2477 muse_core_msg_free(msg);
2481 LOGE("send msg failed");
2482 ret = CAMERA_ERROR_INVALID_OPERATION;
2486 ret = muse_core_msg_recv(sock_fd, recv_msg);
2488 LOGE("recv msg failed %d", errno);
2489 ret = CAMERA_ERROR_INVALID_OPERATION;
2493 if (!muse_camera_msg_get(ret, recv_msg)) {
2494 LOGE("failed to get return value from msg [%s]", recv_msg);
2495 ret = CAMERA_ERROR_INVALID_OPERATION;
2499 if (ret == CAMERA_ERROR_NONE)
2500 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2502 LOGD("api %d - value %d", api, *value);
2506 muse_core_connection_close(sock_fd);
2514 int camera_create(camera_device_e device, camera_h *camera)
2517 char *send_msg = NULL;
2519 int ret = CAMERA_ERROR_NONE;
2521 camera_cli_s *pc = NULL;
2522 tbm_bufmgr bufmgr = NULL;
2524 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2525 muse_core_api_module_e muse_module = MUSE_CAMERA;
2526 int device_type = (int)device;
2529 LOGE("NULL pointer");
2530 return CAMERA_ERROR_INVALID_PARAMETER;
2533 sock_fd = muse_client_new();
2535 LOGE("muse_client_new failed - returned fd %d", sock_fd);
2536 ret = CAMERA_ERROR_INVALID_OPERATION;
2542 send_msg = muse_core_msg_new(api,
2543 MUSE_TYPE_INT, "module", muse_module,
2544 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2545 MUSE_TYPE_INT, "pid", pid,
2550 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2554 send_ret = muse_core_msg_send(sock_fd, send_msg);
2556 muse_core_msg_free(send_msg);
2560 LOGE("send msg failed %d", errno);
2561 ret = CAMERA_ERROR_INVALID_OPERATION;
2565 pc = g_new0(camera_cli_s, 1);
2567 LOGE("camera_cli_s alloc failed");
2568 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2572 bufmgr = tbm_bufmgr_init(-1);
2573 if (bufmgr == NULL) {
2574 LOGE("get tbm bufmgr failed");
2575 ret = CAMERA_ERROR_INVALID_OPERATION;
2579 pc->cb_info = _camera_client_callback_new(sock_fd);
2580 if (pc->cb_info == NULL) {
2581 LOGE("cb_info alloc failed");
2582 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2588 LOGD("cb info : %d", pc->cb_info->fd);
2590 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2592 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2594 if (ret == CAMERA_ERROR_NONE) {
2595 intptr_t handle = 0;
2596 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2598 LOGE("Receiving Handle Failed!!");
2599 ret = CAMERA_ERROR_INVALID_OPERATION;
2603 pc->remote_handle = handle;
2604 pc->cb_info->bufmgr = bufmgr;
2606 ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL);
2607 if (ret != CAMERA_ERROR_NONE) {
2608 LOGE("init display failed 0x%x", ret);
2612 LOGD("camera create 0x%x", pc->remote_handle);
2613 *camera = (camera_h)pc;
2622 tbm_bufmgr_deinit(bufmgr);
2627 muse_core_connection_close(sock_fd);
2633 _camera_client_callback_destroy(pc->cb_info);
2640 LOGE("camera create error : 0x%x", ret);
2646 int camera_change_device(camera_h camera, camera_device_e device)
2649 int ret = CAMERA_ERROR_NONE;
2650 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2651 camera_cli_s *pc = (camera_cli_s *)camera;
2652 camera_msg_param param;
2654 if (!pc || !pc->cb_info) {
2655 LOGE("NULL handle");
2656 return CAMERA_ERROR_INVALID_PARAMETER;
2659 CAMERA_MSG_PARAM_SET(param, INT, device);
2661 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2663 if (ret == CAMERA_ERROR_NONE) {
2664 /* reset callback and user data */
2665 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2666 pc->cb_info->user_cb[i] = NULL;
2667 pc->cb_info->user_data[i] = NULL;
2669 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
2676 int camera_destroy(camera_h camera)
2678 int ret = CAMERA_ERROR_NONE;
2679 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2680 camera_cli_s *pc = (camera_cli_s *)camera;
2682 if (!pc || !pc->cb_info) {
2683 LOGE("NULL handle");
2684 return CAMERA_ERROR_INVALID_PARAMETER;
2689 if (pc->cb_info->is_server_connected)
2690 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2692 LOGW("server disconnected. release resource without send message.");
2694 if (ret == CAMERA_ERROR_NONE) {
2695 _camera_deactivate_idle_event_all(pc->cb_info);
2696 _camera_client_callback_destroy(pc->cb_info);
2706 int camera_start_preview(camera_h camera)
2708 int ret = CAMERA_ERROR_NONE;
2709 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2710 camera_cli_s *pc = (camera_cli_s *)camera;
2712 if (!pc || !pc->cb_info) {
2713 LOGE("NULL handle");
2714 return CAMERA_ERROR_INVALID_PARAMETER;
2719 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2720 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2721 ret = _camera_start_evas_rendering(camera);
2722 if (ret != CAMERA_ERROR_NONE) {
2723 LOGE("stop preview because of error");
2724 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, pc->cb_info, NULL, 0);
2728 LOGD("ret : 0x%x", ret);
2734 int camera_stop_preview(camera_h camera)
2736 int ret = CAMERA_ERROR_NONE;
2737 camera_cli_s *pc = (camera_cli_s *)camera;
2738 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2739 camera_state_e current_state = CAMERA_STATE_NONE;
2741 if (!pc || !pc->cb_info) {
2742 LOGE("NULL handle");
2743 return CAMERA_ERROR_INVALID_PARAMETER;
2748 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2749 ret = camera_get_state(camera, ¤t_state);
2750 if (ret != CAMERA_ERROR_NONE) {
2751 LOGE("failed to get current state 0x%x", ret);
2755 if (current_state == CAMERA_STATE_PREVIEW) {
2756 ret = _camera_stop_evas_rendering(camera, false);
2757 if (ret != CAMERA_ERROR_NONE)
2762 /* send stop preview message */
2763 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2765 if (ret != CAMERA_ERROR_NONE &&
2766 current_state == CAMERA_STATE_PREVIEW) {
2767 LOGW("restart evas rendering");
2768 _camera_start_evas_rendering(camera);
2771 LOGD("ret : 0x%x", ret);
2777 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2779 int ret = CAMERA_ERROR_NONE;
2780 camera_cli_s *pc = (camera_cli_s *)camera;
2781 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2783 if (!pc || !pc->cb_info) {
2784 LOGE("NULL handle");
2785 return CAMERA_ERROR_INVALID_PARAMETER;
2790 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2791 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2793 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2794 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2796 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2798 LOGD("ret : 0x%x", ret);
2804 bool camera_is_supported_continuous_capture(camera_h camera)
2806 int ret = CAMERA_ERROR_NONE;
2807 camera_cli_s *pc = (camera_cli_s *)camera;
2808 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2810 if (!pc || !pc->cb_info) {
2811 LOGE("NULL handle");
2812 return CAMERA_ERROR_INVALID_PARAMETER;
2817 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2820 LOGE("error is occurred 0x%x", ret);
2824 LOGD("ret : %d", ret);
2830 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)
2832 int ret = CAMERA_ERROR_NONE;
2833 camera_cli_s *pc = (camera_cli_s *)camera;
2834 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2835 camera_msg_param param;
2838 if (!pc || !pc->cb_info) {
2839 LOGE("NULL handle");
2840 return CAMERA_ERROR_INVALID_PARAMETER;
2845 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2846 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2848 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2849 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2851 value = (count << 16) | interval;
2852 CAMERA_MSG_PARAM_SET(param, INT, value);
2854 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2856 LOGD("ret : 0x%x", ret);
2862 int camera_stop_continuous_capture(camera_h camera)
2864 int ret = CAMERA_ERROR_NONE;
2865 camera_cli_s *pc = (camera_cli_s *)camera;
2866 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2868 if (!pc || !pc->cb_info) {
2869 LOGE("NULL handle");
2870 return CAMERA_ERROR_INVALID_PARAMETER;
2875 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2877 LOGD("ret : 0x%x", ret);
2883 bool camera_is_supported_face_detection(camera_h camera)
2885 int ret = CAMERA_ERROR_NONE;
2886 camera_cli_s *pc = (camera_cli_s *)camera;
2887 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2889 if (!pc || !pc->cb_info) {
2890 LOGE("NULL handle");
2891 return CAMERA_ERROR_INVALID_PARAMETER;
2896 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2899 LOGE("error is occurred 0x%x", ret);
2903 LOGD("ret : %d", ret);
2909 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2911 int ret = CAMERA_ERROR_NONE;
2912 camera_cli_s *pc = (camera_cli_s *)camera;
2913 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2915 if (!pc || !pc->cb_info) {
2916 LOGE("NULL handle");
2917 return CAMERA_ERROR_INVALID_PARAMETER;
2922 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2925 LOGE("error is occurred 0x%x", ret);
2929 LOGD("ret : %d", ret);
2935 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2937 int ret = CAMERA_ERROR_NONE;
2938 camera_cli_s *pc = (camera_cli_s *)camera;
2939 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2941 if (!pc || !pc->cb_info) {
2942 LOGE("NULL handle");
2943 return CAMERA_ERROR_INVALID_PARAMETER;
2948 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2951 LOGE("error is occurred 0x%x", ret);
2955 LOGD("ret : %d", ret);
2960 int camera_get_device_count(camera_h camera, int *device_count)
2962 int ret = CAMERA_ERROR_NONE;
2963 camera_cli_s *pc = (camera_cli_s *)camera;
2964 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2966 if (!pc || !pc->cb_info) {
2967 LOGE("NULL handle");
2968 return CAMERA_ERROR_INVALID_PARAMETER;
2973 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2975 if (ret == CAMERA_ERROR_NONE)
2976 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2978 LOGD("ret : 0x%x", ret);
2983 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2985 int ret = CAMERA_ERROR_NONE;
2986 camera_cli_s *pc = (camera_cli_s *)camera;
2987 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2989 if (!pc || !pc->cb_info) {
2990 LOGE("NULL handle");
2991 return CAMERA_ERROR_INVALID_PARAMETER;
2996 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2997 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2999 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3001 LOGD("ret : 0x%x", ret);
3006 int camera_stop_face_detection(camera_h camera)
3008 int ret = CAMERA_ERROR_NONE;
3009 camera_cli_s *pc = (camera_cli_s *)camera;
3010 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
3012 if (!pc || !pc->cb_info) {
3013 LOGE("NULL handle");
3014 return CAMERA_ERROR_INVALID_PARAMETER;
3019 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3021 LOGD("ret : 0x%x", ret);
3026 int camera_get_state(camera_h camera, camera_state_e *state)
3028 int ret = CAMERA_ERROR_NONE;
3029 camera_cli_s *pc = (camera_cli_s *)camera;
3030 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
3032 if (!pc || !pc->cb_info || !state) {
3033 LOGE("NULL pointer %p %p", pc, state);
3034 return CAMERA_ERROR_INVALID_PARAMETER;
3039 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3041 if (ret == CAMERA_ERROR_NONE)
3042 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
3044 LOGD("ret : 0x%x", ret);
3049 int camera_start_focusing(camera_h camera, bool continuous)
3051 int ret = CAMERA_ERROR_NONE;
3052 camera_cli_s *pc = (camera_cli_s *)camera;
3053 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
3054 camera_msg_param param;
3055 int is_continuous = (int)continuous;
3057 if (!pc || !pc->cb_info) {
3058 LOGE("NULL handle");
3059 return CAMERA_ERROR_INVALID_PARAMETER;
3064 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
3066 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3068 LOGD("ret : 0x%x", ret);
3073 int camera_cancel_focusing(camera_h camera)
3075 int ret = CAMERA_ERROR_NONE;
3076 camera_cli_s *pc = (camera_cli_s *)camera;
3077 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3079 if (!pc || !pc->cb_info) {
3080 LOGE("NULL handle");
3081 return CAMERA_ERROR_INVALID_PARAMETER;
3084 LOGD("Enter, remote_handle : %x", pc->remote_handle);
3086 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3088 LOGD("ret : 0x%x", ret);
3093 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3095 int ret = CAMERA_ERROR_NONE;
3096 void *set_display_handle = NULL;
3097 Evas_Object *obj = NULL;
3098 const char *object_type = NULL;
3099 camera_cli_s *pc = (camera_cli_s *)camera;
3100 camera_cb_info_s *cb_info = NULL;
3101 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3102 camera_state_e current_state = CAMERA_STATE_NONE;
3103 camera_msg_param param;
3107 if (!pc || !pc->cb_info) {
3108 LOGE("NULL handle");
3109 return CAMERA_ERROR_INVALID_PARAMETER;
3112 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
3113 LOGE("invalid type %d", type);
3114 return CAMERA_ERROR_INVALID_PARAMETER;
3117 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
3118 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
3119 return CAMERA_ERROR_INVALID_PARAMETER;
3122 cb_info = (camera_cb_info_s *)pc->cb_info;
3124 ret = camera_get_state(camera, ¤t_state);
3125 if (ret != CAMERA_ERROR_NONE) {
3126 LOGE("failed to get current state 0x%x", ret);
3130 if (current_state != CAMERA_STATE_CREATED) {
3131 LOGE("INVALID_STATE : current %d", current_state);
3132 return CAMERA_ERROR_INVALID_STATE;
3135 LOGD("Enter - display : %p", display);
3137 if (type == CAMERA_DISPLAY_TYPE_NONE) {
3138 set_display_handle = 0;
3139 LOGD("display type NONE");
3141 obj = (Evas_Object *)display;
3142 object_type = evas_object_type_get(obj);
3144 if (type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
3145 /* get wayland parent id */
3146 if (_camera_get_wl_info(obj, &pc->wl_info) != CAMERA_ERROR_NONE) {
3147 LOGE("failed to get wayland info");
3148 return CAMERA_ERROR_INVALID_OPERATION;
3151 set_display_handle = (void *)&pc->wl_info;
3152 LOGD("display type OVERLAY : handle %p", set_display_handle);
3153 } else if (type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
3154 /* evas object surface */
3155 set_display_handle = (void *)display;
3156 LOGD("display type EVAS : handle %p", set_display_handle);
3158 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3159 g_mutex_lock(&cb_info->evas_mutex);
3161 if (cb_info->evas_info) {
3162 LOGW("destroy existed evas renderer %p", cb_info->evas_info);
3163 ret = mm_evas_renderer_destroy(&cb_info->evas_info);
3164 if (ret != MM_ERROR_NONE) {
3165 LOGE("failed to destroy evas renderer %p", cb_info->evas_info);
3166 g_mutex_unlock(&cb_info->evas_mutex);
3167 return CAMERA_ERROR_INVALID_OPERATION;
3171 /* create evas renderer */
3172 ret = mm_evas_renderer_create(&cb_info->evas_info, (Evas_Object *)set_display_handle);
3173 if (ret == MM_ERROR_NONE) {
3174 camera_flip_e flip = CAMERA_FLIP_NONE;
3175 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3176 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3183 camera_get_display_flip(camera, &flip);
3184 camera_get_display_mode(camera, &mode);
3185 camera_get_display_rotation(camera, &rotation);
3186 camera_is_display_visible(camera, &visible);
3187 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3189 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
3190 flip, mode, rotation, visible, x, y, width, height);
3192 ret = mm_evas_renderer_set_flip(cb_info->evas_info, flip);
3193 ret |= mm_evas_renderer_set_geometry(cb_info->evas_info, mode);
3194 ret |= mm_evas_renderer_set_rotation(cb_info->evas_info, rotation);
3195 ret |= mm_evas_renderer_set_visible(cb_info->evas_info, visible);
3197 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
3198 ret |= mm_evas_renderer_set_roi_area(cb_info->evas_info, x, y, width, height);
3201 g_mutex_unlock(&cb_info->evas_mutex);
3203 if (ret != MM_ERROR_NONE) {
3204 LOGE("mm_evas_renderer error 0x%x", ret);
3205 return CAMERA_ERROR_INVALID_OPERATION;
3207 #else /* TIZEN_FEATURE_EVAS_RENDERER */
3208 LOGE("EVAS surface is not supported");
3209 return CAMERA_ERROR_NOT_SUPPORTED;
3210 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3212 LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type);
3213 return CAMERA_ERROR_INVALID_PARAMETER;
3216 LOGE("failed to get evas object type from %p", obj);
3217 return CAMERA_ERROR_INVALID_PARAMETER;
3221 pc->display_handle = (intptr_t)set_display_handle;
3223 if (type == CAMERA_DISPLAY_TYPE_OVERLAY) {
3226 length = sizeof(camera_wl_info_s) / sizeof(int) + \
3227 (sizeof(camera_wl_info_s) % sizeof(int) ? 1 : 0);
3229 msg = muse_core_msg_new(api,
3230 MUSE_TYPE_INT, "type", type,
3231 MUSE_TYPE_ARRAY, "wl_info", length, (int *)&pc->wl_info,
3234 LOGE("msg creation failed: api %d", api);
3235 return CAMERA_ERROR_OUT_OF_MEMORY;
3238 if (pc->cb_info->is_server_connected) {
3239 __camera_update_api_waiting(pc->cb_info, api, 1);
3241 g_mutex_lock(&pc->cb_info->fd_lock);
3242 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
3243 g_mutex_unlock(&pc->cb_info->fd_lock);
3247 LOGE("message send failed");
3248 ret = CAMERA_ERROR_INVALID_OPERATION;
3250 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
3253 __camera_update_api_waiting(pc->cb_info, api, -1);
3255 muse_core_msg_free(msg);
3257 LOGD("wayland parent id : %d, window %d,%d,%dx%d",
3258 pc->wl_info.parent_id, pc->wl_info.window_x, pc->wl_info.window_y,
3259 pc->wl_info.window_width, pc->wl_info.window_height);
3261 CAMERA_MSG_PARAM_SET(param, INT, type);
3263 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3266 if (ret != CAMERA_ERROR_NONE)
3267 LOGE("set display error 0x%x", ret);
3268 else if (type == CAMERA_DISPLAY_TYPE_EVAS)
3269 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3275 int camera_set_preview_resolution(camera_h camera, int width, int height)
3277 int ret = CAMERA_ERROR_NONE;
3278 camera_state_e current_state = CAMERA_STATE_NONE;
3279 camera_cli_s *pc = (camera_cli_s *)camera;
3280 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3281 camera_msg_param param;
3284 if (!pc || !pc->cb_info) {
3285 LOGE("NULL handle");
3286 return CAMERA_ERROR_INVALID_PARAMETER;
3289 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3290 ret = camera_get_state(camera, ¤t_state);
3291 if (ret != CAMERA_ERROR_NONE) {
3292 LOGE("failed to get current state 0x%x", ret);
3296 if (current_state == CAMERA_STATE_PREVIEW) {
3297 ret = _camera_stop_evas_rendering(camera, true);
3298 if (ret != CAMERA_ERROR_NONE)
3303 value = (width << 16) | height;
3304 CAMERA_MSG_PARAM_SET(param, INT, value);
3306 LOGD("%dx%d -> 0x%x", width, height, value);
3308 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3310 LOGD("ret : 0x%x", ret);
3312 if (current_state == CAMERA_STATE_PREVIEW) {
3313 LOGW("restart evas rendering");
3314 _camera_start_evas_rendering(camera);
3321 int camera_set_capture_resolution(camera_h camera, int width, int height)
3323 int ret = CAMERA_ERROR_NONE;
3324 camera_cli_s *pc = (camera_cli_s *)camera;
3325 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3326 camera_msg_param param;
3329 if (!pc || !pc->cb_info) {
3330 LOGE("NULL handle");
3331 return CAMERA_ERROR_INVALID_PARAMETER;
3336 value = (width << 16) | height;
3337 CAMERA_MSG_PARAM_SET(param, INT, value);
3339 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3341 LOGD("ret : 0x%x", ret);
3347 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3349 int ret = CAMERA_ERROR_NONE;
3350 int set_format = (int)format;
3351 camera_cli_s *pc = (camera_cli_s *)camera;
3352 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3353 camera_msg_param param;
3355 if (!pc || !pc->cb_info) {
3356 LOGE("NULL handle");
3357 return CAMERA_ERROR_INVALID_PARAMETER;
3360 LOGD("Enter - format %d", set_format);
3362 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3364 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3366 LOGD("ret : 0x%x", ret);
3372 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3374 int ret = CAMERA_ERROR_NONE;
3375 int set_format = (int)format;
3376 camera_msg_param param;
3377 camera_cli_s *pc = (camera_cli_s *)camera;
3378 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3380 if (!pc || !pc->cb_info) {
3381 LOGE("NULL handle");
3382 return CAMERA_ERROR_INVALID_PARAMETER;
3385 LOGD("Enter - capture_format %d", set_format);
3387 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3389 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3391 LOGD("ret : 0x%x", ret);
3397 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3399 int ret = CAMERA_ERROR_NONE;
3400 camera_cli_s *pc = (camera_cli_s *)camera;
3401 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3403 if (!pc || !pc->cb_info || !width || !height) {
3404 LOGE("NULL pointer %p %p %p", pc, width, height);
3405 return CAMERA_ERROR_INVALID_PARAMETER;
3410 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3412 if (ret == CAMERA_ERROR_NONE) {
3413 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3414 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3417 LOGD("ret : 0x%x", ret);
3423 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3425 int ret = CAMERA_ERROR_NONE;
3426 int set_rotation = (int)rotation;
3427 camera_cli_s *pc = (camera_cli_s *)camera;
3428 camera_msg_param param;
3430 if (!pc || !pc->cb_info) {
3431 LOGE("NULL handle");
3432 return CAMERA_ERROR_INVALID_PARAMETER;
3435 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3436 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3437 g_mutex_lock(&pc->cb_info->evas_mutex);
3439 ret = mm_evas_renderer_set_rotation(pc->cb_info->evas_info, rotation);
3441 g_mutex_unlock(&pc->cb_info->evas_mutex);
3443 if (ret != MM_ERROR_NONE) {
3444 LOGE("failed to set rotation for evas surface 0x%x", ret);
3445 return CAMERA_ERROR_INVALID_OPERATION;
3448 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3450 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3452 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3458 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3460 int ret = CAMERA_ERROR_NONE;
3461 camera_cli_s *pc = (camera_cli_s *)camera;
3463 if (!pc || !pc->cb_info || !rotation) {
3464 LOGE("NULL pointer %p %p", pc, rotation);
3465 return CAMERA_ERROR_INVALID_PARAMETER;
3468 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3470 if (ret == CAMERA_ERROR_NONE)
3471 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3477 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3479 int ret = CAMERA_ERROR_NONE;
3480 int set_flip = (int)flip;
3481 camera_cli_s *pc = (camera_cli_s *)camera;
3482 camera_msg_param param;
3484 if (!pc || !pc->cb_info) {
3485 LOGE("NULL handle");
3486 return CAMERA_ERROR_INVALID_PARAMETER;
3489 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3490 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3491 g_mutex_lock(&pc->cb_info->evas_mutex);
3493 ret = mm_evas_renderer_set_flip(pc->cb_info->evas_info, flip);
3495 g_mutex_unlock(&pc->cb_info->evas_mutex);
3497 if (ret != MM_ERROR_NONE) {
3498 LOGE("failed to set flip for evas surface 0x%x", ret);
3499 return CAMERA_ERROR_INVALID_OPERATION;
3502 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3504 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3506 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3512 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3514 int ret = CAMERA_ERROR_NONE;
3515 camera_cli_s *pc = (camera_cli_s *)camera;
3517 if (!pc || !pc->cb_info || !flip) {
3518 LOGE("NULL pointer %p %p", pc, flip);
3519 return CAMERA_ERROR_INVALID_PARAMETER;
3522 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3524 if (ret == CAMERA_ERROR_NONE)
3525 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3531 int camera_set_display_visible(camera_h camera, bool visible)
3533 int ret = CAMERA_ERROR_NONE;
3534 int set_visible = (int)visible;
3535 camera_cli_s *pc = (camera_cli_s *)camera;
3536 camera_msg_param param;
3538 if (!pc || !pc->cb_info) {
3539 LOGE("NULL handle");
3540 return CAMERA_ERROR_INVALID_PARAMETER;
3543 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3544 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3545 g_mutex_lock(&pc->cb_info->evas_mutex);
3547 ret = mm_evas_renderer_set_visible(pc->cb_info->evas_info, visible);
3549 g_mutex_unlock(&pc->cb_info->evas_mutex);
3551 if (ret != MM_ERROR_NONE) {
3552 LOGE("failed to set visible for evas surface 0x%x", ret);
3553 return CAMERA_ERROR_INVALID_OPERATION;
3556 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3558 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3560 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3566 int camera_is_display_visible(camera_h camera, bool *visible)
3568 int ret = CAMERA_ERROR_NONE;
3569 camera_cli_s *pc = (camera_cli_s *)camera;
3571 if (!pc || !pc->cb_info || !visible) {
3572 LOGE("NULL pointer %p %p", pc, visible);
3573 return CAMERA_ERROR_INVALID_PARAMETER;
3576 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3578 if (ret == CAMERA_ERROR_NONE)
3579 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3585 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3587 int ret = CAMERA_ERROR_NONE;
3588 int set_mode = (int)mode;
3589 camera_cli_s *pc = (camera_cli_s *)camera;
3590 camera_msg_param param;
3592 if (!pc || !pc->cb_info) {
3593 LOGE("NULL handle");
3594 return CAMERA_ERROR_INVALID_PARAMETER;
3597 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3598 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3599 g_mutex_lock(&pc->cb_info->evas_mutex);
3601 ret = mm_evas_renderer_set_geometry(pc->cb_info->evas_info, mode);
3603 g_mutex_unlock(&pc->cb_info->evas_mutex);
3605 if (ret != MM_ERROR_NONE) {
3606 LOGE("failed to set geometry for evas surface 0x%x", ret);
3607 return CAMERA_ERROR_INVALID_OPERATION;
3610 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3612 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3614 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3620 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3622 int ret = CAMERA_ERROR_NONE;
3623 camera_cli_s *pc = (camera_cli_s *)camera;
3625 if (!pc || !pc->cb_info || !mode) {
3626 LOGE("NULL pointer %p %p", pc, mode);
3627 return CAMERA_ERROR_INVALID_PARAMETER;
3630 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3632 if (ret == CAMERA_ERROR_NONE)
3633 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3639 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3641 int ret = CAMERA_ERROR_NONE;
3642 int set_hint = (int)hint;
3643 camera_cli_s *pc = (camera_cli_s *)camera;
3644 camera_msg_param param;
3646 if (!pc || !pc->cb_info) {
3647 LOGE("NULL handle");
3648 return CAMERA_ERROR_INVALID_PARAMETER;
3651 LOGD("Enter - hint %d", set_hint);
3653 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3655 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3661 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3663 int ret = CAMERA_ERROR_NONE;
3664 camera_cli_s *pc = (camera_cli_s *)camera;
3665 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3667 if (!pc || !pc->cb_info || !hint) {
3668 LOGE("NULL pointer %p %p", pc, hint);
3669 return CAMERA_ERROR_INVALID_PARAMETER;
3672 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3674 if (ret == CAMERA_ERROR_NONE) {
3675 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3676 LOGD("display reuse hint %d", *hint);
3683 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3685 int ret = CAMERA_ERROR_NONE;
3686 camera_cli_s *pc = (camera_cli_s *)camera;
3687 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3689 if (!pc || !pc->cb_info || !width || !height) {
3690 LOGE("NULL pointer %p %p %p", pc, width, height);
3691 return CAMERA_ERROR_INVALID_PARAMETER;
3696 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3698 if (ret == CAMERA_ERROR_NONE) {
3699 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3700 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3703 LOGD("ret : 0x%x", ret);
3709 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3711 int ret = CAMERA_ERROR_NONE;
3712 camera_cli_s *pc = (camera_cli_s *)camera;
3713 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3715 if (!pc || !pc->cb_info || !format) {
3716 LOGE("NULL pointer %p %p", pc, format);
3717 return CAMERA_ERROR_INVALID_PARAMETER;
3722 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3724 if (ret == CAMERA_ERROR_NONE)
3725 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3727 LOGD("ret : 0x%x", ret);
3733 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3735 int ret = CAMERA_ERROR_NONE;
3736 camera_cli_s *pc = (camera_cli_s *)camera;
3737 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3739 if (!pc || !pc->cb_info || !format) {
3740 LOGE("NULL pointer %p %p", pc, format);
3741 return CAMERA_ERROR_INVALID_PARAMETER;
3746 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3748 if (ret == CAMERA_ERROR_NONE)
3749 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3751 LOGD("ret : 0x%x", ret);
3757 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3759 int ret = CAMERA_ERROR_NONE;
3760 camera_cli_s *pc = (camera_cli_s *)camera;
3761 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3763 if (!pc || !pc->cb_info || !facing_direction) {
3764 LOGE("NULL pointer %p %p", pc, facing_direction);
3765 return CAMERA_ERROR_INVALID_PARAMETER;
3770 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3772 if (ret == CAMERA_ERROR_NONE)
3773 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3775 LOGD("ret : 0x%x", ret);
3781 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3783 int ret = CAMERA_ERROR_NONE;
3784 camera_cli_s *pc = (camera_cli_s *)camera;
3785 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3787 if (!pc || !pc->cb_info || !callback) {
3788 LOGE("NULL pointer %p %p", pc, callback);
3789 return CAMERA_ERROR_INVALID_PARAMETER;
3794 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3796 if (ret == CAMERA_ERROR_NONE) {
3797 g_mutex_lock(&pc->cb_info->preview_cb_mutex);
3799 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3800 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3802 g_mutex_unlock(&pc->cb_info->preview_cb_mutex);
3804 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3807 LOGD("ret : 0x%x", ret);
3813 int camera_unset_preview_cb(camera_h camera)
3815 int ret = CAMERA_ERROR_NONE;
3816 camera_cli_s *pc = (camera_cli_s *)camera;
3817 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3819 if (!pc || !pc->cb_info) {
3820 LOGE("NULL handle");
3821 return CAMERA_ERROR_INVALID_PARAMETER;
3826 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3828 if (ret == CAMERA_ERROR_NONE) {
3829 g_mutex_lock(&pc->cb_info->preview_cb_mutex);
3831 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3832 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3834 g_mutex_unlock(&pc->cb_info->preview_cb_mutex);
3836 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3839 LOGD("ret : 0x%x", ret);
3845 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3847 int ret = CAMERA_ERROR_NONE;
3848 camera_cli_s *pc = (camera_cli_s *)camera;
3849 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3851 if (!pc || !pc->cb_info) {
3852 LOGE("NULL handle");
3853 return CAMERA_ERROR_INVALID_PARAMETER;
3856 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3857 LOGE("NOT SUPPORTED");
3858 return CAMERA_ERROR_NOT_SUPPORTED;
3861 if (callback == NULL) {
3862 LOGE("NULL callback");
3863 return CAMERA_ERROR_INVALID_PARAMETER;
3868 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3870 if (ret == CAMERA_ERROR_NONE) {
3871 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3872 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3875 LOGD("ret : 0x%x", ret);
3881 int camera_unset_media_packet_preview_cb(camera_h camera)
3883 int ret = CAMERA_ERROR_NONE;
3884 camera_cli_s *pc = (camera_cli_s *)camera;
3885 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3887 if (!pc || !pc->cb_info) {
3888 LOGE("NULL handle");
3889 return CAMERA_ERROR_INVALID_PARAMETER;
3894 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3896 if (ret == CAMERA_ERROR_NONE) {
3897 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3898 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3901 LOGD("ret : 0x%x", ret);
3907 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3909 int ret = CAMERA_ERROR_NONE;
3910 camera_cli_s *pc = (camera_cli_s *)camera;
3911 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3913 if (!pc || !pc->cb_info || !callback) {
3914 LOGE("NULL pointer %p %p", pc, callback);
3915 return CAMERA_ERROR_INVALID_PARAMETER;
3920 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3922 if (ret == CAMERA_ERROR_NONE) {
3923 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3924 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3927 LOGD("ret : 0x%x", ret);
3933 int camera_unset_state_changed_cb(camera_h camera)
3935 int ret = CAMERA_ERROR_NONE;
3936 camera_cli_s *pc = (camera_cli_s *)camera;
3937 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3939 if (!pc || !pc->cb_info) {
3940 LOGE("NULL handle");
3941 return CAMERA_ERROR_INVALID_PARAMETER;
3946 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3948 if (ret == CAMERA_ERROR_NONE) {
3949 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3950 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3953 LOGD("ret : 0x%x", ret);
3959 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3961 int ret = CAMERA_ERROR_NONE;
3962 camera_cli_s *pc = (camera_cli_s *)camera;
3963 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3965 if (!pc || !pc->cb_info || !callback) {
3966 LOGE("NULL pointer %p %p", pc, callback);
3967 return CAMERA_ERROR_INVALID_PARAMETER;
3972 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3974 if (ret == CAMERA_ERROR_NONE) {
3975 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3976 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3979 LOGD("ret : 0x%x", ret);
3985 int camera_unset_interrupted_cb(camera_h camera)
3987 int ret = CAMERA_ERROR_NONE;
3988 camera_cli_s *pc = (camera_cli_s *)camera;
3989 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3991 if (!pc || !pc->cb_info) {
3992 LOGE("NULL handle");
3993 return CAMERA_ERROR_INVALID_PARAMETER;
3998 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4000 if (ret == CAMERA_ERROR_NONE) {
4001 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
4002 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
4005 LOGD("ret : 0x%x", ret);
4011 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
4013 int ret = CAMERA_ERROR_NONE;
4014 camera_cli_s *pc = (camera_cli_s *)camera;
4015 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
4017 if (!pc || !pc->cb_info || !callback) {
4018 LOGE("NULL pointer %p %p", pc, callback);
4019 return CAMERA_ERROR_INVALID_PARAMETER;
4024 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4026 if (ret == CAMERA_ERROR_NONE) {
4027 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
4028 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
4031 LOGD("ret : 0x%x", ret);
4037 int camera_unset_interrupt_started_cb(camera_h camera)
4039 int ret = CAMERA_ERROR_NONE;
4040 camera_cli_s *pc = (camera_cli_s *)camera;
4041 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
4043 if (!pc || !pc->cb_info) {
4044 LOGE("NULL handle");
4045 return CAMERA_ERROR_INVALID_PARAMETER;
4050 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4052 if (ret == CAMERA_ERROR_NONE) {
4053 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4054 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4057 LOGD("ret : 0x%x", ret);
4063 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
4065 int ret = CAMERA_ERROR_NONE;
4066 camera_cli_s *pc = (camera_cli_s *)camera;
4067 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
4069 if (!pc || !pc->cb_info || !callback) {
4070 LOGE("NULL pointer %p %p", pc, callback);
4071 return CAMERA_ERROR_INVALID_PARAMETER;
4076 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4078 if (ret == CAMERA_ERROR_NONE) {
4079 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
4080 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
4083 LOGD("ret : 0x%x", ret);
4089 int camera_unset_focus_changed_cb(camera_h camera)
4091 int ret = CAMERA_ERROR_NONE;
4092 camera_cli_s *pc = (camera_cli_s *)camera;
4093 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
4095 if (!pc || !pc->cb_info) {
4096 LOGE("NULL handle");
4097 return CAMERA_ERROR_INVALID_PARAMETER;
4102 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4104 if (ret == CAMERA_ERROR_NONE) {
4105 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4106 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4109 LOGD("ret : 0x%x", ret);
4115 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
4117 int ret = CAMERA_ERROR_NONE;
4118 camera_cli_s *pc = (camera_cli_s *)camera;
4119 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
4121 if (!pc || !pc->cb_info || !callback) {
4122 LOGE("NULL pointer %p %p", pc, callback);
4123 return CAMERA_ERROR_INVALID_PARAMETER;
4128 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4130 if (ret == CAMERA_ERROR_NONE) {
4131 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4132 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4135 LOGD("ret : 0x%x", ret);
4141 int camera_unset_error_cb(camera_h camera)
4143 int ret = CAMERA_ERROR_NONE;
4144 camera_cli_s *pc = (camera_cli_s *)camera;
4145 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4147 if (!pc || !pc->cb_info) {
4148 LOGE("NULL handle");
4149 return CAMERA_ERROR_INVALID_PARAMETER;
4154 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4156 if (ret == CAMERA_ERROR_NONE) {
4157 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4158 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4161 LOGD("ret : 0x%x", ret);
4167 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4169 int ret = CAMERA_ERROR_NONE;
4170 camera_cli_s *pc = (camera_cli_s *)camera;
4171 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4173 if (!pc || !pc->cb_info || !foreach_cb) {
4174 LOGE("NULL pointer %p %p", pc, foreach_cb);
4175 return CAMERA_ERROR_INVALID_PARAMETER;
4180 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4181 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4183 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4185 LOGD("ret : 0x%x", ret);
4191 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4193 int ret = CAMERA_ERROR_NONE;
4194 camera_cli_s *pc = (camera_cli_s *)camera;
4195 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4197 if (!pc || !pc->cb_info || !foreach_cb) {
4198 LOGE("NULL pointer %p %p", pc, foreach_cb);
4199 return CAMERA_ERROR_INVALID_PARAMETER;
4204 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4205 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4207 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4209 LOGD("ret : 0x%x", ret);
4215 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4217 int ret = CAMERA_ERROR_NONE;
4218 camera_cli_s *pc = (camera_cli_s *)camera;
4219 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4221 if (!pc || !pc->cb_info || !foreach_cb) {
4222 LOGE("NULL pointer %p %p", pc, foreach_cb);
4223 return CAMERA_ERROR_INVALID_PARAMETER;
4228 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4229 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4231 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4233 LOGD("ret : 0x%x", ret);
4239 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4241 int ret = CAMERA_ERROR_NONE;
4242 camera_cli_s *pc = (camera_cli_s *)camera;
4243 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4245 if (!pc || !pc->cb_info || !foreach_cb) {
4246 LOGE("NULL pointer %p %p", pc, foreach_cb);
4247 return CAMERA_ERROR_INVALID_PARAMETER;
4252 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4253 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4255 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4257 LOGD("ret : 0x%x", ret);
4263 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4265 int ret = CAMERA_ERROR_NONE;
4266 camera_cli_s *pc = (camera_cli_s *)camera;
4267 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4269 if (!pc || !pc->cb_info || !width || !height) {
4270 LOGE("NULL pointer %p %p %p", pc, width, height);
4271 return CAMERA_ERROR_INVALID_PARAMETER;
4275 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4277 if (ret == CAMERA_ERROR_NONE) {
4278 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4279 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4282 LOGD("ret : 0x%x", ret);
4288 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4290 int ret = CAMERA_ERROR_NONE;
4291 camera_cli_s *pc = (camera_cli_s *)camera;
4292 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4294 if (!pc || !pc->cb_info || !angle) {
4295 LOGE("NULL pointer %p %p", pc, angle);
4296 return CAMERA_ERROR_INVALID_PARAMETER;
4301 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4303 if (ret == CAMERA_ERROR_NONE)
4304 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4306 LOGD("ret : 0x%x", ret);
4312 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4314 int ret = CAMERA_ERROR_NONE;
4315 camera_cli_s *pc = (camera_cli_s *)camera;
4316 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4317 camera_msg_param param;
4318 int set_mode = (int)mode;
4320 if (!pc || !pc->cb_info) {
4321 LOGE("NULL handle");
4322 return CAMERA_ERROR_INVALID_PARAMETER;
4327 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4329 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4331 LOGD("ret : 0x%x", ret);
4337 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4339 int ret = CAMERA_ERROR_NONE;
4340 camera_cli_s *pc = (camera_cli_s *)camera;
4341 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4343 if (!pc || !pc->cb_info || !mode) {
4344 LOGE("NULL pointer %p %p", pc, mode);
4345 return CAMERA_ERROR_INVALID_PARAMETER;
4350 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4352 if (ret == CAMERA_ERROR_NONE)
4353 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4355 LOGD("ret : 0x%x", ret);
4361 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4363 int ret = CAMERA_ERROR_NONE;
4364 camera_cli_s *pc = (camera_cli_s *)camera;
4365 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4367 if (!pc || !pc->cb_info || !foreach_cb) {
4368 LOGE("NULL pointer %p %p", pc, foreach_cb);
4369 return CAMERA_ERROR_INVALID_PARAMETER;
4374 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4375 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4377 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4379 LOGD("Finish, return :%x", ret);
4385 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4387 int ret = CAMERA_ERROR_NONE;
4388 camera_cli_s *pc = (camera_cli_s *)camera;
4389 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4390 camera_msg_param param;
4391 int set_fps = (int)fps;
4393 if (!pc || !pc->cb_info) {
4394 LOGE("NULL handle");
4395 return CAMERA_ERROR_INVALID_PARAMETER;
4400 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4402 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4404 LOGD("ret : 0x%x", ret);
4410 int camera_attr_set_image_quality(camera_h camera, int quality)
4412 int ret = CAMERA_ERROR_NONE;
4413 camera_cli_s *pc = (camera_cli_s *)camera;
4414 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4415 camera_msg_param param;
4417 if (!pc || !pc->cb_info) {
4418 LOGE("NULL handle");
4419 return CAMERA_ERROR_INVALID_PARAMETER;
4424 CAMERA_MSG_PARAM_SET(param, INT, quality);
4426 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4428 LOGD("ret : 0x%x", ret);
4434 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4436 int ret = CAMERA_ERROR_NONE;
4437 camera_cli_s *pc = (camera_cli_s *)camera;
4438 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4440 if (!pc || !pc->cb_info || !fps) {
4441 LOGE("NULL pointer %p %p", pc, fps);
4442 return CAMERA_ERROR_INVALID_PARAMETER;
4447 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4449 if (ret == CAMERA_ERROR_NONE)
4450 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4452 LOGD("ret : 0x%x", ret);
4458 int camera_attr_get_image_quality(camera_h camera, int *quality)
4460 int ret = CAMERA_ERROR_NONE;
4461 camera_cli_s *pc = (camera_cli_s *)camera;
4462 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4464 if (!pc || !pc->cb_info || !quality) {
4465 LOGE("NULL pointer %p %p", pc, quality);
4466 return CAMERA_ERROR_INVALID_PARAMETER;
4471 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4473 if (ret == CAMERA_ERROR_NONE)
4474 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4476 LOGD("ret : 0x%x", ret);
4482 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4484 int ret = CAMERA_ERROR_NONE;
4485 camera_cli_s *pc = (camera_cli_s *)camera;
4486 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4488 if (!pc || !pc->cb_info || !bitrate) {
4489 LOGE("NULL pointer %p %p", pc, bitrate);
4490 return CAMERA_ERROR_INVALID_PARAMETER;
4495 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4497 if (ret == CAMERA_ERROR_NONE)
4498 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4500 LOGD("ret : 0x%x", ret);
4506 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4508 int ret = CAMERA_ERROR_NONE;
4509 camera_cli_s *pc = (camera_cli_s *)camera;
4510 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4511 camera_msg_param param;
4512 int set_bitrate = bitrate;
4514 if (!pc || !pc->cb_info) {
4515 LOGE("NULL handle");
4516 return CAMERA_ERROR_INVALID_PARAMETER;
4521 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4523 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4525 LOGD("ret : 0x%x", ret);
4531 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4533 int ret = CAMERA_ERROR_NONE;
4534 camera_cli_s *pc = (camera_cli_s *)camera;
4535 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4537 if (!pc || !pc->cb_info || !interval) {
4538 LOGE("NULL pointer %p %p", pc, interval);
4539 return CAMERA_ERROR_INVALID_PARAMETER;
4544 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4546 if (ret == CAMERA_ERROR_NONE)
4547 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4549 LOGD("ret : 0x%x", ret);
4555 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4557 int ret = CAMERA_ERROR_NONE;
4558 camera_cli_s *pc = (camera_cli_s *)camera;
4559 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4560 camera_msg_param param;
4561 int set_gop_interval = interval;
4563 if (!pc || !pc->cb_info) {
4564 LOGE("NULL handle");
4565 return CAMERA_ERROR_INVALID_PARAMETER;
4570 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4572 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4574 LOGD("ret : 0x%x", ret);
4580 int camera_attr_set_zoom(camera_h camera, int zoom)
4582 int ret = CAMERA_ERROR_NONE;
4583 camera_cli_s *pc = (camera_cli_s *)camera;
4584 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4585 camera_msg_param param;
4587 if (!pc || !pc->cb_info) {
4588 LOGE("NULL handle");
4589 return CAMERA_ERROR_INVALID_PARAMETER;
4592 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4594 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4596 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4598 LOGD("ret : 0x%x", ret);
4604 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4606 int ret = CAMERA_ERROR_NONE;
4607 camera_cli_s *pc = (camera_cli_s *)camera;
4608 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4609 camera_msg_param param;
4610 int set_mode = (int)mode;
4612 if (!pc || !pc->cb_info) {
4613 LOGE("NULL handle");
4614 return CAMERA_ERROR_INVALID_PARAMETER;
4617 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4619 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4621 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4627 int camera_attr_set_af_area(camera_h camera, int x, int y)
4629 int ret = CAMERA_ERROR_NONE;
4630 camera_cli_s *pc = (camera_cli_s *)camera;
4631 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4632 camera_msg_param param;
4635 if (!pc || !pc->cb_info) {
4636 LOGE("NULL handle");
4637 return CAMERA_ERROR_INVALID_PARAMETER;
4640 LOGD("Enter - %d,%d", x, y);
4642 value = (x << 16) | y;
4643 CAMERA_MSG_PARAM_SET(param, INT, value);
4645 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4647 LOGD("ret : 0x%x", ret);
4653 int camera_attr_clear_af_area(camera_h camera)
4655 int ret = CAMERA_ERROR_NONE;
4656 camera_cli_s *pc = (camera_cli_s *)camera;
4657 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4659 if (!pc || !pc->cb_info) {
4660 LOGE("NULL handle");
4661 return CAMERA_ERROR_INVALID_PARAMETER;
4666 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4668 LOGD("ret : 0x%x", ret);
4674 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4676 int ret = CAMERA_ERROR_NONE;
4677 camera_cli_s *pc = (camera_cli_s *)camera;
4678 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4679 camera_msg_param param;
4680 int set_mode = (int)mode;
4682 if (!pc || !pc->cb_info) {
4683 LOGE("NULL handle");
4684 return CAMERA_ERROR_INVALID_PARAMETER;
4689 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4691 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4693 LOGD("ret : 0x%x", ret);
4699 int camera_attr_set_exposure(camera_h camera, int value)
4701 int ret = CAMERA_ERROR_NONE;
4702 camera_cli_s *pc = (camera_cli_s *)camera;
4703 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4704 camera_msg_param param;
4706 if (!pc || !pc->cb_info) {
4707 LOGE("NULL handle");
4708 return CAMERA_ERROR_INVALID_PARAMETER;
4713 CAMERA_MSG_PARAM_SET(param, INT, value);
4715 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4717 LOGD("ret : 0x%x", ret);
4723 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4725 int ret = CAMERA_ERROR_NONE;
4726 camera_cli_s *pc = (camera_cli_s *)camera;
4727 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4728 camera_msg_param param;
4729 int set_iso = (int)iso;
4731 if (!pc || !pc->cb_info) {
4732 LOGE("NULL handle");
4733 return CAMERA_ERROR_INVALID_PARAMETER;
4738 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4740 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4742 LOGD("ret : 0x%x", ret);
4748 int camera_attr_set_brightness(camera_h camera, int level)
4750 int ret = CAMERA_ERROR_NONE;
4751 camera_cli_s *pc = (camera_cli_s *)camera;
4752 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4753 camera_msg_param param;
4755 if (!pc || !pc->cb_info) {
4756 LOGE("NULL handle");
4757 return CAMERA_ERROR_INVALID_PARAMETER;
4762 CAMERA_MSG_PARAM_SET(param, INT, level);
4764 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4766 LOGD("ret : 0x%x", ret);
4772 int camera_attr_set_contrast(camera_h camera, int level)
4774 int ret = CAMERA_ERROR_NONE;
4775 camera_cli_s *pc = (camera_cli_s *)camera;
4776 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4777 camera_msg_param param;
4779 if (!pc || !pc->cb_info) {
4780 LOGE("NULL handle");
4781 return CAMERA_ERROR_INVALID_PARAMETER;
4786 CAMERA_MSG_PARAM_SET(param, INT, level);
4788 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4790 LOGD("ret : 0x%x", ret);
4796 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4798 int ret = CAMERA_ERROR_NONE;
4799 camera_cli_s *pc = (camera_cli_s *)camera;
4800 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4801 camera_msg_param param;
4802 int set_whitebalance = (int)wb;
4804 if (!pc || !pc->cb_info) {
4805 LOGE("NULL handle");
4806 return CAMERA_ERROR_INVALID_PARAMETER;
4811 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4813 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4815 LOGD("ret : 0x%x", ret);
4821 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4823 int ret = CAMERA_ERROR_NONE;
4824 camera_cli_s *pc = (camera_cli_s *)camera;
4825 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4826 camera_msg_param param;
4827 int set_effect = (int)effect;
4829 if (!pc || !pc->cb_info) {
4830 LOGE("NULL handle");
4831 return CAMERA_ERROR_INVALID_PARAMETER;
4836 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4838 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4840 LOGD("ret : 0x%x", ret);
4846 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4848 int ret = CAMERA_ERROR_NONE;
4849 camera_cli_s *pc = (camera_cli_s *)camera;
4850 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4851 camera_msg_param param;
4852 int set_mode = (int)mode;
4854 if (!pc || !pc->cb_info) {
4855 LOGE("NULL handle");
4856 return CAMERA_ERROR_INVALID_PARAMETER;
4861 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4863 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4865 LOGD("ret : 0x%x", ret);
4871 int camera_attr_enable_tag(camera_h camera, bool enable)
4873 int ret = CAMERA_ERROR_NONE;
4874 camera_cli_s *pc = (camera_cli_s *)camera;
4875 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4876 camera_msg_param param;
4877 int set_enable = (int)enable;
4879 if (!pc || !pc->cb_info) {
4880 LOGE("NULL handle");
4881 return CAMERA_ERROR_INVALID_PARAMETER;
4886 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4888 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4890 LOGD("ret : 0x%x", ret);
4896 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4898 int ret = CAMERA_ERROR_NONE;
4899 camera_cli_s *pc = (camera_cli_s *)camera;
4900 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4901 camera_msg_param param;
4903 if (!pc || !pc->cb_info || !description) {
4904 LOGE("NULL pointer %p %p", pc, description);
4905 return CAMERA_ERROR_INVALID_PARAMETER;
4910 CAMERA_MSG_PARAM_SET(param, STRING, description);
4912 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4914 LOGD("ret : 0x%x", ret);
4920 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4922 int ret = CAMERA_ERROR_NONE;
4923 camera_cli_s *pc = (camera_cli_s *)camera;
4924 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4925 camera_msg_param param;
4926 int set_orientation = (int)orientation;
4928 if (!pc || !pc->cb_info) {
4929 LOGE("NULL handle");
4930 return CAMERA_ERROR_INVALID_PARAMETER;
4935 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4937 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4939 LOGD("ret : 0x%x", ret);
4945 int camera_attr_set_tag_software(camera_h camera, const char *software)
4947 int ret = CAMERA_ERROR_NONE;
4948 camera_cli_s *pc = (camera_cli_s *)camera;
4949 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4950 camera_msg_param param;
4952 if (!pc || !pc->cb_info || !software) {
4953 LOGE("NULL pointer %p %p", pc, software);
4954 return CAMERA_ERROR_INVALID_PARAMETER;
4957 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4959 CAMERA_MSG_PARAM_SET(param, STRING, software);
4961 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4963 LOGD("ret : 0x%x", ret);
4969 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4971 int ret = CAMERA_ERROR_NONE;
4972 camera_cli_s *pc = (camera_cli_s *)camera;
4973 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4974 double set_geotag[3] = {latitude, longitude, altitude};
4979 if (!pc || !pc->cb_info) {
4980 LOGE("NULL handle");
4981 return CAMERA_ERROR_INVALID_PARAMETER;
4986 length = sizeof(set_geotag) / sizeof(int) + \
4987 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4989 msg = muse_core_msg_new(api,
4990 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4993 LOGE("msg creation failed: api %d", api);
4994 return CAMERA_ERROR_OUT_OF_MEMORY;
4997 if (pc->cb_info->is_server_connected) {
4998 __camera_update_api_waiting(pc->cb_info, api, 1);
5000 g_mutex_lock(&pc->cb_info->fd_lock);
5001 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
5002 g_mutex_unlock(&pc->cb_info->fd_lock);
5006 LOGE("message send failed");
5007 ret = CAMERA_ERROR_INVALID_OPERATION;
5009 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
5012 __camera_update_api_waiting(pc->cb_info, api, -1);
5014 muse_core_msg_free(msg);
5016 LOGD("ret : 0x%x", ret);
5022 int camera_attr_remove_geotag(camera_h camera)
5024 int ret = CAMERA_ERROR_NONE;
5025 camera_cli_s *pc = (camera_cli_s *)camera;
5026 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
5028 if (!pc || !pc->cb_info) {
5029 LOGE("NULL handle");
5030 return CAMERA_ERROR_INVALID_PARAMETER;
5035 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5037 LOGD("ret : 0x%x", ret);
5043 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
5045 int ret = CAMERA_ERROR_NONE;
5046 camera_cli_s *pc = (camera_cli_s *)camera;
5047 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
5048 camera_msg_param param;
5049 int set_mode = (int)mode;
5051 if (!pc || !pc->cb_info) {
5052 LOGE("NULL handle");
5053 return CAMERA_ERROR_INVALID_PARAMETER;
5058 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5060 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5062 LOGD("ret : 0x%x", ret);
5068 int camera_attr_get_zoom(camera_h camera, int *zoom)
5070 int ret = CAMERA_ERROR_NONE;
5071 camera_cli_s *pc = (camera_cli_s *)camera;
5072 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
5074 if (!pc || !pc->cb_info || !zoom) {
5075 LOGE("NULL pointer %p %p", pc, zoom);
5076 return CAMERA_ERROR_INVALID_PARAMETER;
5081 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5083 if (ret == CAMERA_ERROR_NONE)
5084 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
5086 LOGD("ret : 0x%x", ret);
5092 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
5094 int ret = CAMERA_ERROR_NONE;
5095 camera_cli_s *pc = (camera_cli_s *)camera;
5096 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
5098 if (!pc || !pc->cb_info || !min || !max) {
5099 LOGE("NULL pointer %p %p %p", pc, min, max);
5100 return CAMERA_ERROR_INVALID_PARAMETER;
5105 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5107 if (ret == CAMERA_ERROR_NONE) {
5108 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
5109 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
5112 LOGD("ret : 0x%x", ret);
5118 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
5120 int ret = CAMERA_ERROR_NONE;
5121 camera_cli_s *pc = (camera_cli_s *)camera;
5122 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
5124 if (!pc || !pc->cb_info || !mode) {
5125 LOGE("NULL pointer %p %p", pc, mode);
5126 return CAMERA_ERROR_INVALID_PARAMETER;
5131 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5133 if (ret == CAMERA_ERROR_NONE)
5134 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5136 LOGD("ret : 0x%x", ret);
5142 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5144 int ret = CAMERA_ERROR_NONE;
5145 camera_cli_s *pc = (camera_cli_s *)camera;
5146 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5148 if (!pc || !pc->cb_info || !mode) {
5149 LOGE("NULL pointer %p %p", pc, mode);
5150 return CAMERA_ERROR_INVALID_PARAMETER;
5155 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5157 if (ret == CAMERA_ERROR_NONE)
5158 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5160 LOGD("ret : 0x%x", ret);
5166 int camera_attr_get_exposure(camera_h camera, int *value)
5168 int ret = CAMERA_ERROR_NONE;
5169 camera_cli_s *pc = (camera_cli_s *)camera;
5170 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5172 if (!pc || !pc->cb_info || !value) {
5173 LOGE("NULL pointer %p %p", pc, value);
5174 return CAMERA_ERROR_INVALID_PARAMETER;
5179 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5181 if (ret == CAMERA_ERROR_NONE)
5182 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5184 LOGD("ret : 0x%x", ret);
5190 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5192 int ret = CAMERA_ERROR_NONE;
5193 camera_cli_s *pc = (camera_cli_s *)camera;
5194 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5196 if (!pc || !pc->cb_info || !min || !max) {
5197 LOGE("NULL pointer %p %p %p", pc, min, max);
5198 return CAMERA_ERROR_INVALID_PARAMETER;
5203 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5205 if (ret == CAMERA_ERROR_NONE) {
5206 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5207 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5210 LOGD("ret : 0x%x", ret);
5216 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5218 int ret = CAMERA_ERROR_NONE;
5219 camera_cli_s *pc = (camera_cli_s *)camera;
5220 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5222 if (!pc || !pc->cb_info || !iso) {
5223 LOGE("NULL pointer %p %p", pc, iso);
5224 return CAMERA_ERROR_INVALID_PARAMETER;
5229 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5231 if (ret == CAMERA_ERROR_NONE)
5232 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5234 LOGD("ret : 0x%x", ret);
5240 int camera_attr_get_brightness(camera_h camera, int *level)
5242 int ret = CAMERA_ERROR_NONE;
5243 camera_cli_s *pc = (camera_cli_s *)camera;
5244 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5246 if (!pc || !pc->cb_info || !level) {
5247 LOGE("NULL pointer %p %p", pc, level);
5248 return CAMERA_ERROR_INVALID_PARAMETER;
5253 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5255 if (ret == CAMERA_ERROR_NONE)
5256 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5258 LOGD("ret : 0x%x", ret);
5264 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5266 int ret = CAMERA_ERROR_NONE;
5267 camera_cli_s *pc = (camera_cli_s *)camera;
5268 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5270 if (!pc || !pc->cb_info || !min || !max) {
5271 LOGE("NULL pointer %p %p %p", pc, min, max);
5272 return CAMERA_ERROR_INVALID_PARAMETER;
5277 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5279 if (ret == CAMERA_ERROR_NONE) {
5280 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5281 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5284 LOGD("ret : 0x%x", ret);
5290 int camera_attr_get_contrast(camera_h camera, int *level)
5292 int ret = CAMERA_ERROR_NONE;
5293 camera_cli_s *pc = (camera_cli_s *)camera;
5294 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5296 if (!pc || !pc->cb_info || !level) {
5297 LOGE("NULL pointer %p %p", pc, level);
5298 return CAMERA_ERROR_INVALID_PARAMETER;
5303 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5305 if (ret == CAMERA_ERROR_NONE)
5306 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5308 LOGD("ret : 0x%x", ret);
5314 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5316 int ret = CAMERA_ERROR_NONE;
5317 camera_cli_s *pc = (camera_cli_s *)camera;
5318 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5320 if (!pc || !pc->cb_info || !min || !max) {
5321 LOGE("NULL pointer %p %p %p", pc, min, max);
5322 return CAMERA_ERROR_INVALID_PARAMETER;
5327 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5329 if (ret == CAMERA_ERROR_NONE) {
5330 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5331 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5332 LOGD("min %d, max %d", *min, *max);
5335 LOGD("ret : 0x%x", ret);
5341 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5343 int ret = CAMERA_ERROR_NONE;
5344 camera_cli_s *pc = (camera_cli_s *)camera;
5345 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5347 if (!pc || !pc->cb_info || !wb) {
5348 LOGE("NULL pointer %p %p", pc, wb);
5349 return CAMERA_ERROR_INVALID_PARAMETER;
5354 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5356 if (ret == CAMERA_ERROR_NONE)
5357 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5359 LOGD("ret : 0x%x", ret);
5365 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
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_EFFECT;
5371 if (!pc || !pc->cb_info || !effect) {
5372 LOGE("NULL pointer %p %p", pc, effect);
5373 return CAMERA_ERROR_INVALID_PARAMETER;
5378 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5380 if (ret == CAMERA_ERROR_NONE)
5381 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5383 LOGD("ret : 0x%x", ret);
5389 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5391 int ret = CAMERA_ERROR_NONE;
5392 camera_cli_s *pc = (camera_cli_s *)camera;
5393 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5395 if (!pc || !pc->cb_info || !mode) {
5396 LOGE("NULL pointer %p %p", pc, mode);
5397 return CAMERA_ERROR_INVALID_PARAMETER;
5402 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5404 if (ret == CAMERA_ERROR_NONE)
5405 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5407 LOGD("ret : 0x%x", ret);
5413 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5415 int ret = CAMERA_ERROR_NONE;
5416 camera_cli_s *pc = (camera_cli_s *)camera;
5417 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5419 if (!pc || !pc->cb_info || !enable) {
5420 LOGE("NULL pointer %p %p", pc, enable);
5421 return CAMERA_ERROR_INVALID_PARAMETER;
5426 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5428 if (ret == CAMERA_ERROR_NONE)
5429 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5431 LOGD("ret : 0x%x", ret);
5437 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5439 int ret = CAMERA_ERROR_NONE;
5440 camera_cli_s *pc = (camera_cli_s *)camera;
5441 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5443 if (!pc || !pc->cb_info || !description) {
5444 LOGE("NULL pointer %p %p", pc, description);
5445 return CAMERA_ERROR_INVALID_PARAMETER;
5450 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5452 if (ret == CAMERA_ERROR_NONE)
5453 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5455 LOGD("ret : 0x%x", ret);
5461 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5463 int ret = CAMERA_ERROR_NONE;
5464 camera_cli_s *pc = (camera_cli_s *)camera;
5465 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5467 if (!pc || !pc->cb_info || !orientation) {
5468 LOGE("NULL pointer %p %p", pc, orientation);
5469 return CAMERA_ERROR_INVALID_PARAMETER;
5474 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5476 if (ret == CAMERA_ERROR_NONE)
5477 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5479 LOGD("ret : 0x%x", ret);
5485 int camera_attr_get_tag_software(camera_h camera, char **software)
5487 int ret = CAMERA_ERROR_NONE;
5488 camera_cli_s *pc = (camera_cli_s *)camera;
5489 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5491 if (!pc || !pc->cb_info || !software) {
5492 LOGE("NULL pointer %p %p", pc, software);
5493 return CAMERA_ERROR_INVALID_PARAMETER;
5498 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5500 if (ret == CAMERA_ERROR_NONE)
5501 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5503 LOGD("ret : 0x%x", ret);
5509 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5511 int ret = CAMERA_ERROR_NONE;
5512 camera_cli_s *pc = (camera_cli_s *)camera;
5513 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5515 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5516 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5517 return CAMERA_ERROR_INVALID_PARAMETER;
5522 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5524 if (ret == CAMERA_ERROR_NONE) {
5525 *latitude = pc->cb_info->get_geotag[0];
5526 *longitude = pc->cb_info->get_geotag[1];
5527 *altitude = pc->cb_info->get_geotag[2];
5530 LOGD("ret : 0x%x", ret);
5536 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
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_GET_FLASH_MODE;
5542 if (!pc || !pc->cb_info || !mode) {
5543 LOGE("NULL pointer %p %p", pc, mode);
5544 return CAMERA_ERROR_INVALID_PARAMETER;
5549 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5551 if (ret == CAMERA_ERROR_NONE)
5552 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5554 LOGD("ret : 0x%x", ret);
5560 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5562 int ret = CAMERA_ERROR_NONE;
5563 int get_flash_state = 0;
5566 LOGE("NULL pointer");
5567 return CAMERA_ERROR_INVALID_PARAMETER;
5570 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5571 (int)device, "get_flash_state", &get_flash_state);
5573 if (ret == CAMERA_ERROR_NONE) {
5574 *state = (camera_flash_state_e)get_flash_state;
5575 LOGD("flash state %d", *state);
5577 LOGE("failed 0x%x", ret);
5584 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_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_AF_MODE;
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_AF_MODE] = foreach_cb;
5598 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5600 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5602 LOGD("ret : 0x%x", ret);
5608 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_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_EXPOSURE_MODE;
5614 if (!pc || !pc->cb_info || !foreach_cb) {
5615 LOGE("NULL pointer %p %p", pc, foreach_cb);
5616 return CAMERA_ERROR_INVALID_PARAMETER;
5621 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5622 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5624 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5626 LOGD("ret : 0x%x", ret);
5632 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5634 int ret = CAMERA_ERROR_NONE;
5635 camera_cli_s *pc = (camera_cli_s *)camera;
5636 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5638 if (!pc || !pc->cb_info || !foreach_cb) {
5639 LOGE("NULL pointer %p %p", pc, foreach_cb);
5640 return CAMERA_ERROR_INVALID_PARAMETER;
5645 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5646 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5648 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5650 LOGD("ret : 0x%x", ret);
5656 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5658 int ret = CAMERA_ERROR_NONE;
5659 camera_cli_s *pc = (camera_cli_s *)camera;
5660 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5662 if (!pc || !pc->cb_info || !foreach_cb) {
5663 LOGE("NULL pointer %p %p", pc, foreach_cb);
5664 return CAMERA_ERROR_INVALID_PARAMETER;
5669 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5670 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5672 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5674 LOGD("ret : 0x%x", ret);
5680 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5682 int ret = CAMERA_ERROR_NONE;
5683 camera_cli_s *pc = (camera_cli_s *)camera;
5684 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5686 if (!pc || !pc->cb_info || !foreach_cb) {
5687 LOGE("NULL pointer %p %p", pc, foreach_cb);
5688 return CAMERA_ERROR_INVALID_PARAMETER;
5693 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5694 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5696 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5698 LOGD("ret : 0x%x", ret);
5704 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5706 int ret = CAMERA_ERROR_NONE;
5707 camera_cli_s *pc = (camera_cli_s *)camera;
5708 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5710 if (!pc || !pc->cb_info || !foreach_cb) {
5711 LOGE("NULL pointer %p %p", pc, foreach_cb);
5712 return CAMERA_ERROR_INVALID_PARAMETER;
5717 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5718 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5720 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5722 LOGD("ret : 0x%x", ret);
5728 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5730 int ret = CAMERA_ERROR_NONE;
5731 camera_cli_s *pc = (camera_cli_s *)camera;
5732 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5734 if (!pc || !pc->cb_info || !foreach_cb) {
5735 LOGE("NULL pointer %p %p", pc, foreach_cb);
5736 return CAMERA_ERROR_INVALID_PARAMETER;
5741 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5742 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5744 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5746 LOGD("ret : 0x%x", ret);
5752 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5754 int ret = CAMERA_ERROR_NONE;
5755 camera_cli_s *pc = (camera_cli_s *)camera;
5756 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5758 if (!pc || !pc->cb_info || !foreach_cb) {
5759 LOGE("NULL pointer %p %p", pc, foreach_cb);
5760 return CAMERA_ERROR_INVALID_PARAMETER;
5765 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5766 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5768 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5770 LOGD("Enter, handle :%x", pc->remote_handle);
5776 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)
5778 int ret = CAMERA_ERROR_NONE;
5779 camera_cli_s *pc = (camera_cli_s *)camera;
5780 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5781 camera_msg_param param;
5784 if (!pc || !pc->cb_info || !foreach_cb) {
5785 LOGE("NULL pointer %p %p", pc, foreach_cb);
5786 return CAMERA_ERROR_INVALID_PARAMETER;
5791 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5792 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5794 value = (width << 16) | height;
5795 CAMERA_MSG_PARAM_SET(param, INT, value);
5797 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5799 LOGD("ret : 0x%x", ret);
5805 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5807 int ret = CAMERA_ERROR_NONE;
5808 camera_cli_s *pc = (camera_cli_s *)camera;
5809 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5811 if (!pc || !pc->cb_info || !foreach_cb) {
5812 LOGE("NULL pointer %p %p", pc, foreach_cb);
5813 return CAMERA_ERROR_INVALID_PARAMETER;
5818 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5819 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5821 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5823 LOGD("ret : 0x%x", ret);
5829 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5831 int ret = CAMERA_ERROR_NONE;
5832 camera_cli_s *pc = (camera_cli_s *)camera;
5833 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5835 if (!pc || !pc->cb_info || !foreach_cb) {
5836 LOGE("NULL pointer %p %p", pc, foreach_cb);
5837 return CAMERA_ERROR_INVALID_PARAMETER;
5842 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5843 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5845 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5847 LOGD("ret : 0x%x", ret);
5853 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5855 int ret = CAMERA_ERROR_NONE;
5856 camera_cli_s *pc = (camera_cli_s *)camera;
5857 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5858 camera_msg_param param;
5859 int set_rotation = (int)rotation;
5861 if (!pc || !pc->cb_info) {
5862 LOGE("NULL handle");
5863 return CAMERA_ERROR_INVALID_PARAMETER;
5868 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5870 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5872 LOGD("ret : 0x%x", ret);
5878 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5880 int ret = CAMERA_ERROR_NONE;
5881 camera_cli_s *pc = (camera_cli_s *)camera;
5882 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5884 if (!pc || !pc->cb_info || !rotation) {
5885 LOGE("NULL pointer %p %p", pc, rotation);
5886 return CAMERA_ERROR_INVALID_PARAMETER;
5891 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5893 if (ret == CAMERA_ERROR_NONE)
5894 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5896 LOGD("ret : 0x%x", ret);
5902 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5904 int ret = CAMERA_ERROR_NONE;
5905 camera_cli_s *pc = (camera_cli_s *)camera;
5906 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5907 camera_msg_param param;
5908 int set_flip = (int)flip;
5910 if (!pc || !pc->cb_info) {
5911 LOGE("NULL handle");
5912 return CAMERA_ERROR_INVALID_PARAMETER;
5917 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5919 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5921 LOGD("ret : 0x%x", ret);
5927 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5929 int ret = CAMERA_ERROR_NONE;
5930 camera_cli_s *pc = (camera_cli_s *)camera;
5931 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5933 if (!pc || !pc->cb_info || !flip) {
5934 LOGE("NULL pointer %p %p", pc, flip);
5935 return CAMERA_ERROR_INVALID_PARAMETER;
5940 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5942 if (ret == CAMERA_ERROR_NONE)
5943 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5945 LOGD("ret : 0x%x", ret);
5950 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5952 int ret = CAMERA_ERROR_NONE;
5953 camera_cli_s *pc = (camera_cli_s *)camera;
5954 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5955 camera_msg_param param;
5956 int set_mode = (int)mode;
5958 if (!pc || !pc->cb_info) {
5959 LOGE("NULL handle");
5960 return CAMERA_ERROR_INVALID_PARAMETER;
5965 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5967 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5969 LOGD("ret : 0x%x", ret);
5975 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5977 int ret = CAMERA_ERROR_NONE;
5978 camera_cli_s *pc = (camera_cli_s *)camera;
5979 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5981 if (!pc || !pc->cb_info || !mode) {
5982 LOGE("NULL pointer %p %p", pc, mode);
5983 return CAMERA_ERROR_INVALID_PARAMETER;
5988 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5990 if (ret == CAMERA_ERROR_NONE)
5991 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
5993 LOGD("ret : 0x%x", ret);
5999 bool camera_attr_is_supported_hdr_capture(camera_h camera)
6001 int ret = CAMERA_ERROR_NONE;
6002 camera_cli_s *pc = (camera_cli_s *)camera;
6003 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
6005 if (!pc || !pc->cb_info) {
6006 LOGE("NULL handle");
6007 return CAMERA_ERROR_INVALID_PARAMETER;
6012 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6015 LOGE("error is occurred 0x%x", ret);
6019 LOGD("ret : %d", ret);
6025 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
6027 int ret = CAMERA_ERROR_NONE;
6028 camera_cli_s *pc = (camera_cli_s *)camera;
6029 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
6031 if (!pc || !pc->cb_info) {
6032 LOGE("NULL handle");
6033 return CAMERA_ERROR_INVALID_PARAMETER;
6038 if (!camera_attr_is_supported_hdr_capture(camera)) {
6039 LOGE("HDR not supported");
6040 return CAMERA_ERROR_NOT_SUPPORTED;
6044 LOGE("NULL callback");
6045 return CAMERA_ERROR_INVALID_PARAMETER;
6048 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6050 if (ret == CAMERA_ERROR_NONE) {
6051 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
6052 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
6055 LOGD("ret : 0x%x", ret);
6061 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
6063 int ret = CAMERA_ERROR_NONE;
6064 camera_cli_s *pc = (camera_cli_s *)camera;
6065 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
6067 if (!pc || !pc->cb_info) {
6068 LOGE("NULL handle");
6069 return CAMERA_ERROR_INVALID_PARAMETER;
6074 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6076 if (ret == CAMERA_ERROR_NONE) {
6077 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6078 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6081 LOGD("ret : 0x%x", ret);
6087 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6089 int ret = CAMERA_ERROR_NONE;
6090 camera_cli_s *pc = (camera_cli_s *)camera;
6091 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
6092 camera_msg_param param;
6093 int set_enable = (int)enable;
6095 if (!pc || !pc->cb_info) {
6096 LOGE("NULL handle");
6097 return CAMERA_ERROR_INVALID_PARAMETER;
6102 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6104 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6106 LOGD("ret : 0x%x", ret);
6112 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6114 int ret = CAMERA_ERROR_NONE;
6115 camera_cli_s *pc = (camera_cli_s *)camera;
6116 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6118 if (!pc || !pc->cb_info || !enabled) {
6119 LOGE("NULL pointer %p %p", pc, enabled);
6120 return CAMERA_ERROR_INVALID_PARAMETER;
6125 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6127 if (ret == CAMERA_ERROR_NONE)
6128 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6130 LOGD("ret : 0x%x", ret);
6136 bool camera_attr_is_supported_anti_shake(camera_h camera)
6138 int ret = CAMERA_ERROR_NONE;
6139 camera_cli_s *pc = (camera_cli_s *)camera;
6140 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6142 if (!pc || !pc->cb_info) {
6143 LOGE("NULL handle");
6144 return CAMERA_ERROR_INVALID_PARAMETER;
6149 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6152 LOGE("error is occurred 0x%x", ret);
6156 LOGD("ret : %d", ret);
6162 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6164 int ret = CAMERA_ERROR_NONE;
6165 camera_cli_s *pc = (camera_cli_s *)camera;
6166 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6167 camera_msg_param param;
6168 int set_enable = (int)enable;
6170 if (!pc || !pc->cb_info) {
6171 LOGE("NULL handle");
6172 return CAMERA_ERROR_INVALID_PARAMETER;
6177 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6179 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6181 LOGD("ret : 0x%x", ret);
6187 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6189 int ret = CAMERA_ERROR_NONE;
6190 camera_cli_s *pc = (camera_cli_s *)camera;
6191 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6193 if (!pc || !pc->cb_info || !enabled) {
6194 LOGE("NULL pointer %p %p", pc, enabled);
6195 return CAMERA_ERROR_INVALID_PARAMETER;
6200 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6202 if (ret == CAMERA_ERROR_NONE)
6203 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6205 LOGD("ret : 0x%x", ret);
6211 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6213 int ret = CAMERA_ERROR_NONE;
6214 camera_cli_s *pc = (camera_cli_s *)camera;
6215 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6217 if (!pc || !pc->cb_info) {
6218 LOGE("NULL handle");
6219 return CAMERA_ERROR_INVALID_PARAMETER;
6224 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6227 LOGE("error is occurred 0x%x", ret);
6231 LOGD("ret : %d", ret);
6237 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
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_ENABLE_AUTO_CONTRAST;
6242 camera_msg_param param;
6243 int set_enable = (int)enable;
6245 if (!pc || !pc->cb_info) {
6246 LOGE("NULL handle");
6247 return CAMERA_ERROR_INVALID_PARAMETER;
6252 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6254 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6256 LOGD("ret : 0x%x", ret);
6262 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6264 int ret = CAMERA_ERROR_NONE;
6265 camera_cli_s *pc = (camera_cli_s *)camera;
6266 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6268 if (!pc || !pc->cb_info || !enabled) {
6269 LOGE("NULL pointer %p %p", pc, enabled);
6270 return CAMERA_ERROR_INVALID_PARAMETER;
6275 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6277 if (ret == CAMERA_ERROR_NONE)
6278 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6280 LOGD("ret : 0x%x", ret);
6286 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6288 int ret = CAMERA_ERROR_NONE;
6289 camera_cli_s *pc = (camera_cli_s *)camera;
6290 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6292 if (!pc || !pc->cb_info) {
6293 LOGE("NULL handle");
6294 return CAMERA_ERROR_INVALID_PARAMETER;
6299 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6302 LOGE("error is occurred 0x%x", ret);
6306 LOGD("ret : %d", ret);
6312 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6314 int ret = CAMERA_ERROR_NONE;
6315 camera_cli_s *pc = (camera_cli_s *)camera;
6316 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6317 camera_msg_param param;
6318 int set_disable = (int)disable;
6320 if (!pc || !pc->cb_info) {
6321 LOGE("NULL handle");
6322 return CAMERA_ERROR_INVALID_PARAMETER;
6327 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6329 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6331 LOGD("ret : 0x%x", ret);
6337 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6339 int ret = CAMERA_ERROR_NONE;
6340 camera_cli_s *pc = (camera_cli_s *)camera;
6341 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6342 camera_msg_param param;
6343 int set_move_type = (int)move_type;
6346 if (!pc || !pc->cb_info) {
6347 LOGE("NULL handle");
6348 return CAMERA_ERROR_INVALID_PARAMETER;
6353 value = (set_move_type << 16) | pan_step;
6354 CAMERA_MSG_PARAM_SET(param, INT, value);
6356 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6358 LOGD("ret : 0x%x", ret);
6364 int camera_attr_get_pan(camera_h camera, int *pan_step)
6366 int ret = CAMERA_ERROR_NONE;
6367 camera_cli_s *pc = (camera_cli_s *)camera;
6368 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6370 if (!pc || !pc->cb_info || !pan_step) {
6371 LOGE("NULL pointer %p %p", pc, pan_step);
6372 return CAMERA_ERROR_INVALID_PARAMETER;
6377 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6379 if (ret == CAMERA_ERROR_NONE)
6380 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6382 LOGD("ret : 0x%x", ret);
6388 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6390 int ret = CAMERA_ERROR_NONE;
6391 camera_cli_s *pc = (camera_cli_s *)camera;
6392 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6394 if (!pc || !pc->cb_info || !min || !max) {
6395 LOGE("NULL pointer %p %p", pc, min, max);
6396 return CAMERA_ERROR_INVALID_PARAMETER;
6401 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6403 if (ret == CAMERA_ERROR_NONE) {
6404 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6405 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6408 LOGD("ret : 0x%x", ret);
6414 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6416 int ret = CAMERA_ERROR_NONE;
6417 camera_cli_s *pc = (camera_cli_s *)camera;
6418 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6419 camera_msg_param param;
6420 int set_move_type = (int)move_type;
6423 if (!pc || !pc->cb_info) {
6424 LOGE("NULL handle");
6425 return CAMERA_ERROR_INVALID_PARAMETER;
6430 value = (set_move_type << 16) | tilt_step;
6431 CAMERA_MSG_PARAM_SET(param, INT, value);
6433 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6435 LOGD("ret : 0x%x", ret);
6441 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6443 int ret = CAMERA_ERROR_NONE;
6444 camera_cli_s *pc = (camera_cli_s *)camera;
6445 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6447 if (!pc || !pc->cb_info || !tilt_step) {
6448 LOGE("NULL pointer %p %p", pc, tilt_step);
6449 return CAMERA_ERROR_INVALID_PARAMETER;
6454 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6456 if (ret == CAMERA_ERROR_NONE)
6457 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6459 LOGD("ret : 0x%x", ret);
6465 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6467 int ret = CAMERA_ERROR_NONE;
6468 camera_cli_s *pc = (camera_cli_s *)camera;
6469 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6471 if (!pc || !pc->cb_info || !min || !max) {
6472 LOGE("NULL pointer %p %p %p", pc, min, max);
6473 return CAMERA_ERROR_INVALID_PARAMETER;
6478 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6480 if (ret == CAMERA_ERROR_NONE) {
6481 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6482 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6485 LOGD("ret : 0x%x", ret);
6491 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6493 int ret = CAMERA_ERROR_NONE;
6494 camera_cli_s *pc = (camera_cli_s *)camera;
6495 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6496 camera_msg_param param;
6497 int set_ptz_type = (int)ptz_type;
6499 if (!pc || !pc->cb_info) {
6500 LOGE("NULL handle");
6501 return CAMERA_ERROR_INVALID_PARAMETER;
6506 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6508 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6510 LOGD("ret : 0x%x", ret);
6516 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6518 int ret = CAMERA_ERROR_NONE;
6519 camera_cli_s *pc = (camera_cli_s *)camera;
6520 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6522 if (!pc || !pc->cb_info || !foreach_cb) {
6523 LOGE("NULL pointer %p %p", pc, foreach_cb);
6524 return CAMERA_ERROR_INVALID_PARAMETER;
6529 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6530 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6532 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6534 LOGD("ret : 0x%x", ret);
6540 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6542 int ret = CAMERA_ERROR_NONE;
6543 camera_cli_s *pc = (camera_cli_s *)camera;
6544 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6545 int set_display_roi_area[4] = {x, y, width, height};
6550 if (!pc || !pc->cb_info) {
6551 LOGE("NULL handle");
6552 return CAMERA_ERROR_INVALID_PARAMETER;
6557 #ifdef TIZEN_FEATURE_EVAS_RENDERER
6558 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6559 g_mutex_lock(&pc->cb_info->evas_mutex);
6561 ret = mm_evas_renderer_set_roi_area(pc->cb_info->evas_info, x, y, width, height);
6563 g_mutex_unlock(&pc->cb_info->evas_mutex);
6565 if (ret != MM_ERROR_NONE) {
6566 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6567 return CAMERA_ERROR_INVALID_OPERATION;
6570 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
6572 length = sizeof(set_display_roi_area) / sizeof(int) + \
6573 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6575 msg = muse_core_msg_new(api,
6576 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6579 LOGE("msg creation failed: api %d", api);
6580 return CAMERA_ERROR_OUT_OF_MEMORY;
6583 if (pc->cb_info->is_server_connected) {
6584 __camera_update_api_waiting(pc->cb_info, api, 1);
6586 g_mutex_lock(&pc->cb_info->fd_lock);
6587 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
6588 g_mutex_unlock(&pc->cb_info->fd_lock);
6592 LOGE("message send failed");
6593 ret = CAMERA_ERROR_INVALID_OPERATION;
6595 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6598 __camera_update_api_waiting(pc->cb_info, api, -1);
6600 muse_core_msg_free(msg);
6602 LOGD("ret : 0x%x", ret);
6608 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6610 camera_cli_s *pc = (camera_cli_s *)camera;
6611 int ret = CAMERA_ERROR_NONE;
6612 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6614 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6615 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6616 return CAMERA_ERROR_INVALID_PARAMETER;
6621 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6623 if (ret == CAMERA_ERROR_NONE) {
6624 *x = pc->cb_info->get_display_roi_area[0];
6625 *y = pc->cb_info->get_display_roi_area[1];
6626 *width = pc->cb_info->get_display_roi_area[2];
6627 *height = pc->cb_info->get_display_roi_area[3];
6630 LOGD("ret : 0x%x", ret);
6636 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6638 int ret = CAMERA_ERROR_NONE;
6639 int get_device_state = 0;
6642 LOGE("NULL pointer");
6643 return CAMERA_ERROR_INVALID_PARAMETER;
6646 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6647 (int)device, "get_device_state", &get_device_state);
6649 if (ret == CAMERA_ERROR_NONE) {
6650 *state = (camera_device_state_e)get_device_state;
6651 LOGD("device state %d", *state);
6653 LOGE("failed 0x%x", ret);
6660 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6662 int ret = CAMERA_ERROR_NONE;
6663 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6664 camera_cb_info *info = NULL;
6666 if (!callback || !cb_id) {
6667 LOGE("invalid pointer %p %p", callback, cb_id);
6668 return CAMERA_ERROR_INVALID_PARAMETER;
6671 /* check camera support */
6672 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6673 if (ret != CAMERA_ERROR_NONE) {
6674 LOGE("get device state failed");
6678 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6680 info = g_new0(camera_cb_info, 1);
6682 LOGE("info failed");
6683 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6687 info->id = ++g_cam_dev_state_changed_cb_id;
6688 info->callback = (void *)callback;
6689 info->user_data = user_data;
6693 /* subscribe dbus signal for camera state change */
6694 if (!g_cam_dev_state_changed_cb_conn) {
6695 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6696 if (!g_cam_dev_state_changed_cb_conn) {
6697 LOGE("failed to get gdbus connection");
6698 ret = CAMERA_ERROR_INVALID_OPERATION;
6702 LOGD("subscribe signal %s - %s - %s",
6703 MM_CAMCORDER_DBUS_OBJECT,
6704 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6705 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6707 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6708 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6709 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6710 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6711 LOGE("failed to get gdbus connection");
6712 ret = CAMERA_ERROR_INVALID_OPERATION;
6716 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6719 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6721 LOGD("callback id %d", info->id);
6724 if (ret != CAMERA_ERROR_NONE) {
6730 if (g_cam_dev_state_changed_cb_conn) {
6731 g_object_unref(g_cam_dev_state_changed_cb_conn);
6732 g_cam_dev_state_changed_cb_conn = NULL;
6736 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6742 int camera_remove_device_state_changed_cb(int cb_id)
6744 int ret = CAMERA_ERROR_NONE;
6745 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6746 GList *tmp_list = NULL;
6747 camera_cb_info *info = NULL;
6749 /* check camera support */
6750 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6751 if (ret != CAMERA_ERROR_NONE) {
6752 LOGE("get device state failed");
6756 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6758 if (!g_cam_dev_state_changed_cb_list) {
6759 LOGE("there is no callback info");
6760 ret = CAMERA_ERROR_INVALID_OPERATION;
6764 tmp_list = g_cam_dev_state_changed_cb_list;
6767 info = tmp_list->data;
6768 tmp_list = tmp_list->next;
6775 if (info->id == cb_id) {
6776 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6781 if (!g_cam_dev_state_changed_cb_list) {
6782 /* no remained callback */
6783 if (g_cam_dev_state_changed_cb_conn) {
6784 /* unsubscribe signal */
6785 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6786 g_cam_dev_state_changed_cb_subscribe_id = 0;
6788 /* unref connection */
6789 g_object_unref(g_cam_dev_state_changed_cb_conn);
6790 g_cam_dev_state_changed_cb_conn = NULL;
6794 LOGD("id %d callback removed", cb_id);
6795 ret = CAMERA_ERROR_NONE;
6801 LOGE("id %d callback not found", cb_id);
6802 ret = CAMERA_ERROR_INVALID_PARAMETER;
6805 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);