2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
24 #include <muse_camera.h>
25 #include <muse_camera_msg.h>
26 #include <muse_core_ipc.h>
27 #include <muse_core_module.h>
28 #include <camera_private.h>
29 #include <muse_core.h>
31 #include <Elementary.h>
32 #include <tbm_surface_internal.h>
34 #include <Ecore_Wayland.h>
35 #include <wayland-client.h>
36 #include <tizen-extension-client-protocol.h>
37 #ifdef TIZEN_FEATURE_EVAS_RENDERER
38 #include <mm_evas_renderer.h>
39 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
45 #define LOG_TAG "TIZEN_N_CAMERA"
47 /* for device changed callback */
48 static GMutex g_cam_dev_state_changed_cb_lock;
49 static GList *g_cam_dev_state_changed_cb_list;
50 static int g_cam_dev_state_changed_cb_id;
51 static GDBusConnection *g_cam_dev_state_changed_cb_conn;
52 static guint g_cam_dev_state_changed_cb_subscribe_id;
55 static void __global(void *data, struct wl_registry *registry,
56 uint32_t name, const char *interface, uint32_t version)
58 struct tizen_surface **tz_surface = NULL;
65 tz_surface = (struct tizen_surface **)data;
68 LOGW("NULL interface");
72 /*LOGI("interface %s", interface);*/
74 if (strcmp(interface, "tizen_surface") == 0) {
75 LOGD("binding tizen surface for wayland");
77 *tz_surface = wl_registry_bind(registry, name, &tizen_surface_interface, version);
78 if (*tz_surface == NULL)
79 LOGE("failed to bind");
87 static void __global_remove(void *data, struct wl_registry *wl_registry, uint32_t name)
93 static const struct wl_registry_listener _camera_wl_registry_listener = {
98 void __parent_id_getter(void *data, struct tizen_resource *tizen_resource, uint32_t id)
105 *((unsigned int *)data) = id;
107 LOGD("[CLIENT] got parent_id [%u] from server", id);
112 static const struct tizen_resource_listener _camera_tz_resource_listener = {
116 int _camera_get_wl_info(Evas_Object *obj, camera_wl_info_s *wl_info)
118 int ret = CAMERA_ERROR_NONE;
119 Ecore_Wl_Window *window = NULL;
120 struct wl_display *display = NULL;
121 struct wl_display *display_wrapper = NULL;
122 struct wl_surface *surface = NULL;
123 struct wl_registry *registry = NULL;
124 struct wl_event_queue *queue = NULL;
125 struct tizen_surface *tz_surface = NULL;
126 struct tizen_resource *tz_resource = NULL;
128 if (!obj || !wl_info) {
129 LOGE("NULL parameter %p %p", obj, wl_info);
130 return CAMERA_ERROR_INVALID_OPERATION;
133 window = elm_win_wl_window_get(obj);
135 LOGE("failed to get wayland window");
136 ret = CAMERA_ERROR_INVALID_OPERATION;
140 surface = (struct wl_surface *)ecore_wl_window_surface_get(window);
142 LOGE("failed to get wayland surface");
143 ret = CAMERA_ERROR_INVALID_OPERATION;
147 display = (struct wl_display *)ecore_wl_display_get();
149 LOGE("failed to get wayland display");
150 ret = CAMERA_ERROR_INVALID_OPERATION;
154 display_wrapper = wl_proxy_create_wrapper(display);
155 if (!display_wrapper) {
156 LOGE("failed to create wl display wrapper");
157 ret = CAMERA_ERROR_INVALID_OPERATION;
161 queue = wl_display_create_queue(display);
163 LOGE("failed to create wl display queue");
164 ret = CAMERA_ERROR_INVALID_OPERATION;
168 wl_proxy_set_queue((struct wl_proxy *)display_wrapper, queue);
170 registry = wl_display_get_registry(display_wrapper);
172 LOGE("failed to get wayland registry");
173 ret = CAMERA_ERROR_INVALID_OPERATION;
177 wl_registry_add_listener(registry, &_camera_wl_registry_listener, &tz_surface);
179 wl_display_dispatch_queue(display, queue);
180 wl_display_roundtrip_queue(display, queue);
183 LOGE("failed to get tizen surface");
184 ret = CAMERA_ERROR_INVALID_OPERATION;
188 /* Get parent_id which is unique in a entire systemw. */
189 tz_resource = tizen_surface_get_tizen_resource(tz_surface, surface);
191 LOGE("failed to get tizen resurce");
192 ret = CAMERA_ERROR_INVALID_OPERATION;
196 wl_info->parent_id = 0;
198 tizen_resource_add_listener(tz_resource, &_camera_tz_resource_listener, &wl_info->parent_id);
200 wl_display_roundtrip_queue(display, queue);
202 if (wl_info->parent_id > 0) {
204 Ecore_Evas *ecore_evas = NULL;
205 ret = CAMERA_ERROR_NONE;
207 wl_info->evas_obj = obj;
209 evas_object_geometry_get(obj, &wl_info->window_x, &wl_info->window_y,
210 &wl_info->window_width, &wl_info->window_height);
212 ecore_evas = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
214 rotation = ecore_evas_rotation_get(ecore_evas);
215 if (rotation == 90 || rotation == 270) {
216 int temp = wl_info->window_width;
218 LOGD("swap width and height %d, %d", wl_info->window_width, wl_info->window_height);
220 wl_info->window_width = wl_info->window_height;
221 wl_info->window_height = temp;
224 LOGW("failed to get ecore_evas.. skip rotation check");
227 LOGD("evas object : %p, rotation : %d, parent id : %u, window : %d,%d,%dx%d",
228 wl_info->evas_obj, rotation, wl_info->parent_id,
229 wl_info->window_x, wl_info->window_y,
230 wl_info->window_width, wl_info->window_height);
232 ret = CAMERA_ERROR_INVALID_OPERATION;
233 LOGE("failed to get parent id");
238 tizen_surface_destroy(tz_surface);
243 tizen_resource_destroy(tz_resource);
248 wl_registry_destroy(registry);
253 wl_event_queue_destroy(queue);
257 if (display_wrapper) {
258 wl_proxy_wrapper_destroy(display_wrapper);
259 display_wrapper = NULL;
266 static void __camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value)
269 api < 0 || api >= MUSE_CAMERA_API_MAX) {
270 LOGE("invalid param %p %d", cb_info, api);
274 g_mutex_lock(&(cb_info->api_mutex[api]));
275 cb_info->api_waiting[api] += value;
276 g_mutex_unlock(&(cb_info->api_mutex[api]));
278 /*LOGD("api %d, value %d, waiting %d",
279 api, value, cb_info->api_waiting[api]);*/
285 static void __camera_device_state_changed_cb(GDBusConnection *connection,
286 const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
287 const gchar *signal_name, GVariant *param, gpointer user_data)
290 camera_device_e device = CAMERA_DEVICE_CAMERA0;
291 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
292 GList *tmp_list = NULL;
293 camera_cb_info *info = NULL;
295 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
297 if (!g_cam_dev_state_changed_cb_list || !param) {
298 LOGW("no callback or NULL param %p", param);
302 /* get device and state */
303 g_variant_get(param, "(i)", &value);
305 device = value >> 16;
306 state = 0x0000ffff & value;
308 LOGD("device %d, state %d", device, state);
310 tmp_list = g_cam_dev_state_changed_cb_list;
313 info = (camera_cb_info *)tmp_list->data;
316 if (info->callback) {
317 LOGD("start id[%d] callback", info->id);
318 ((camera_device_state_changed_cb)info->callback)(device, state, info->user_data);
319 LOGD("returned id[%d] callback", info->id);
321 LOGW("NULL callback for id %d", info->id);
325 tmp_list = tmp_list->next;
329 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
335 static int _camera_import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle)
337 tbm_bo tmp_bo = NULL;
338 tbm_bo_handle tmp_bo_handle = {NULL, };
340 if (!bufmgr || !bo || !bo_handle || !tbm_key) {
341 LOGE("invalid parameter - %p %p %p, key %d",
342 bufmgr, bo, bo_handle, tbm_key);
346 tmp_bo = tbm_bo_import(bufmgr, tbm_key);
347 if (tmp_bo == NULL) {
348 LOGE("import failed - key %d", tbm_key);
352 tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
353 if (tmp_bo_handle.ptr == NULL) {
354 LOGE("map failed %p", tmp_bo);
355 tbm_bo_unref(tmp_bo);
360 tbm_bo_unmap(tmp_bo);
362 /* set bo and bo_handle */
364 *bo_handle = tmp_bo_handle;
369 static void _camera_release_imported_bo(tbm_bo *bo)
382 static int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
384 int ret = CAMERA_ERROR_NONE;
387 /*LOGD("Enter api : %d", api);*/
389 if (!cb_info->is_server_connected) {
390 LOGE("server is disconnected");
391 return CAMERA_ERROR_SERVICE_DISCONNECTED;
394 g_mutex_lock(&(cb_info->api_mutex[api]));
396 if (cb_info->api_activating[api] == 0) {
397 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
398 if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
399 ret = cb_info->api_ret[api];
400 cb_info->api_activating[api] = 0;
402 /*LOGD("return value : 0x%x", ret);*/
404 ret = CAMERA_ERROR_INVALID_OPERATION;
405 LOGE("api %d was TIMED OUT!", api);
408 ret = cb_info->api_ret[api];
409 cb_info->api_activating[api] = 0;
411 /*LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);*/
414 g_mutex_unlock(&(cb_info->api_mutex[api]));
416 if (ret != CAMERA_ERROR_NONE) {
417 LOGE("api %d : error 0x%x", api, ret);
419 if (ret == CAMERA_ERROR_SOUND_POLICY)
420 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
421 else if (ret == CAMERA_ERROR_SOUND_POLICY_BY_CALL)
422 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
423 else if (ret == CAMERA_ERROR_SOUND_POLICY_BY_ALARM)
424 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
431 static void _camera_msg_send(int api, camera_cb_info_s *cb_info,
432 int *ret, int timeout)
438 LOGE("NULL info - api %d", api);
441 *ret = CAMERA_ERROR_INVALID_PARAMETER;
446 msg = muse_core_msg_json_factory_new(api, NULL);
448 LOGE("msg failed: api %d", api);
451 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
456 /*LOGD("send msg %s", msg);*/
458 if (cb_info->is_server_connected) {
459 __camera_update_api_waiting(cb_info, api, 1);
461 g_mutex_lock(&cb_info->fd_lock);
462 send_ret = muse_core_ipc_send_msg(cb_info->fd, msg);
463 g_mutex_unlock(&cb_info->fd_lock);
467 LOGE("msg send failed");
469 *ret = CAMERA_ERROR_INVALID_OPERATION;
472 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
475 __camera_update_api_waiting(cb_info, api, -1);
477 muse_core_msg_json_factory_free(msg);
483 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
484 int *ret, camera_msg_param *param, int timeout)
489 if (!cb_info || !param) {
490 LOGE("invalid pointer : api %d - %p %p", api, cb_info, param);
493 *ret = CAMERA_ERROR_INVALID_PARAMETER;
498 /*LOGD("type %d, name %s", param->type, param->name);*/
500 switch (param->type) {
502 msg = muse_core_msg_json_factory_new(api,
503 param->type, param->name, param->value.value_INT,
506 case MUSE_TYPE_STRING:
507 msg = muse_core_msg_json_factory_new(api,
508 param->type, param->name, param->value.value_STRING,
512 LOGE("unknown type %d", param->type);
517 LOGE("msg failed: api %d", api);
520 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
525 /*LOGD("send msg %s", msg);*/
527 if (cb_info->is_server_connected) {
528 __camera_update_api_waiting(cb_info, api, 1);
530 g_mutex_lock(&cb_info->fd_lock);
531 send_ret = muse_core_ipc_send_msg(cb_info->fd, msg);
532 g_mutex_unlock(&cb_info->fd_lock);
536 LOGE("msg send failed");
539 *ret = CAMERA_ERROR_INVALID_OPERATION;
542 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
545 __camera_update_api_waiting(cb_info, api, -1);
547 muse_core_msg_json_factory_free(msg);
553 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
555 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
556 in_format >= MM_PIXEL_FORMAT_NUM ||
557 out_format == NULL) {
558 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
559 return CAMERA_ERROR_INVALID_PARAMETER;
563 case MM_PIXEL_FORMAT_NV12:
564 case MM_PIXEL_FORMAT_NV12T:
565 *out_format = TBM_FORMAT_NV12;
567 case MM_PIXEL_FORMAT_NV16:
568 *out_format = TBM_FORMAT_NV16;
570 case MM_PIXEL_FORMAT_NV21:
571 *out_format = TBM_FORMAT_NV21;
573 case MM_PIXEL_FORMAT_YUYV:
574 *out_format = TBM_FORMAT_YUYV;
576 case MM_PIXEL_FORMAT_UYVY:
577 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
578 *out_format = TBM_FORMAT_UYVY;
580 case MM_PIXEL_FORMAT_422P:
581 *out_format = TBM_FORMAT_YUV422;
583 case MM_PIXEL_FORMAT_I420:
584 *out_format = TBM_FORMAT_YUV420;
586 case MM_PIXEL_FORMAT_YV12:
587 *out_format = TBM_FORMAT_YVU420;
589 case MM_PIXEL_FORMAT_RGB565:
590 *out_format = TBM_FORMAT_RGB565;
592 case MM_PIXEL_FORMAT_RGB888:
593 *out_format = TBM_FORMAT_RGB888;
595 case MM_PIXEL_FORMAT_RGBA:
596 *out_format = TBM_FORMAT_RGBA8888;
598 case MM_PIXEL_FORMAT_ARGB:
599 *out_format = TBM_FORMAT_ARGB8888;
602 LOGE("invalid in_format %d", in_format);
603 return CAMERA_ERROR_INVALID_PARAMETER;
606 return CAMERA_ERROR_NONE;
610 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
612 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
613 in_format >= MM_PIXEL_FORMAT_NUM ||
615 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
616 return CAMERA_ERROR_INVALID_PARAMETER;
620 case MM_PIXEL_FORMAT_NV12:
621 case MM_PIXEL_FORMAT_NV12T:
622 *mimetype = MEDIA_FORMAT_NV12;
624 case MM_PIXEL_FORMAT_NV16:
625 *mimetype = MEDIA_FORMAT_NV16;
627 case MM_PIXEL_FORMAT_NV21:
628 *mimetype = MEDIA_FORMAT_NV21;
630 case MM_PIXEL_FORMAT_YUYV:
631 *mimetype = MEDIA_FORMAT_YUYV;
633 case MM_PIXEL_FORMAT_UYVY:
634 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
635 *mimetype = MEDIA_FORMAT_UYVY;
637 case MM_PIXEL_FORMAT_422P:
638 *mimetype = MEDIA_FORMAT_422P;
640 case MM_PIXEL_FORMAT_I420:
641 *mimetype = MEDIA_FORMAT_I420;
643 case MM_PIXEL_FORMAT_YV12:
644 *mimetype = MEDIA_FORMAT_YV12;
646 case MM_PIXEL_FORMAT_RGB565:
647 *mimetype = MEDIA_FORMAT_RGB565;
649 case MM_PIXEL_FORMAT_RGB888:
650 *mimetype = MEDIA_FORMAT_RGB888;
652 case MM_PIXEL_FORMAT_RGBA:
653 *mimetype = MEDIA_FORMAT_RGBA;
655 case MM_PIXEL_FORMAT_ARGB:
656 *mimetype = MEDIA_FORMAT_ARGB;
659 LOGE("invalid in_format %d", in_format);
660 return CAMERA_ERROR_INVALID_PARAMETER;
663 return CAMERA_ERROR_NONE;
666 void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_key,
667 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame)
670 unsigned char *buf_pos = NULL;
672 if (stream == NULL || buffer_bo_handle == NULL || frame == NULL) {
673 LOGE("invalid parameter - stream:%p, buffer_bo_handle:%p", stream, buffer_bo_handle);
678 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
679 frame->format = MM_PIXEL_FORMAT_UYVY;
681 frame->format = stream->format;
683 frame->width = stream->width;
684 frame->height = stream->height;
685 frame->timestamp = stream->timestamp;
686 frame->num_of_planes = stream->num_planes;
688 if (num_buffer_key == 0) {
690 if (!data_bo_handle || !data_bo_handle->ptr) {
691 LOGE("NULL pointer");
695 buf_pos = data_bo_handle->ptr;
697 if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) {
698 frame->data.encoded_plane.data = buf_pos;
699 frame->data.encoded_plane.size = stream->data.encoded.length_data;
700 total_size = stream->data.encoded.length_data;
702 switch (stream->num_planes) {
704 frame->data.single_plane.yuv = buf_pos;
705 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
706 total_size = stream->data.yuv420.length_yuv;
709 frame->data.double_plane.y = buf_pos;
710 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
711 buf_pos += stream->data.yuv420sp.length_y;
712 frame->data.double_plane.uv = buf_pos;
713 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
714 total_size = stream->data.yuv420sp.length_y + \
715 stream->data.yuv420sp.length_uv;
718 frame->data.triple_plane.y = buf_pos;
719 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
720 buf_pos += stream->data.yuv420p.length_y;
721 frame->data.triple_plane.u = buf_pos;
722 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
723 buf_pos += stream->data.yuv420p.length_u;
724 frame->data.triple_plane.v = buf_pos;
725 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
726 total_size = stream->data.yuv420p.length_y + \
727 stream->data.yuv420p.length_u + \
728 stream->data.yuv420p.length_v;
736 switch (stream->num_planes) {
738 frame->data.single_plane.yuv = buffer_bo_handle[0].ptr;
739 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
740 total_size = stream->data.yuv420.length_yuv;
743 frame->data.double_plane.y = buffer_bo_handle[0].ptr;
744 if (stream->num_planes == (unsigned int)num_buffer_key)
745 frame->data.double_plane.uv = buffer_bo_handle[1].ptr;
747 frame->data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
748 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
749 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
750 total_size = stream->data.yuv420sp.length_y + \
751 stream->data.yuv420sp.length_uv;
754 frame->data.triple_plane.y = buffer_bo_handle[0].ptr;
755 if (stream->num_planes == (unsigned int)num_buffer_key) {
756 frame->data.triple_plane.u = buffer_bo_handle[1].ptr;
757 frame->data.triple_plane.v = buffer_bo_handle[2].ptr;
759 frame->data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y;
760 frame->data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u;
762 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
763 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
764 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
765 total_size = stream->data.yuv420p.length_y + \
766 stream->data.yuv420p.length_u + \
767 stream->data.yuv420p.length_v;
775 LOGD("format %d, %dx%d, size %d plane num %d",
776 frame.format, frame.width, frame.height, total_size, frame.num_of_planes);
782 int _camera_media_packet_data_create(int tbm_key, int num_buffer_key, tbm_bo bo,
783 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
786 int ret = CAMERA_ERROR_NONE;
787 camera_media_packet_data *tmp_mp_data = NULL;
789 if (*mp_data == NULL) {
790 tmp_mp_data = g_new0(camera_media_packet_data, 1);
792 tmp_mp_data->tbm_key = tbm_key;
793 tmp_mp_data->num_buffer_key = num_buffer_key;
794 tmp_mp_data->bo = bo;
795 tmp_mp_data->data_bo = data_bo;
796 tmp_mp_data->ref_cnt++;
798 for (i = 0 ; i < num_buffer_key ; i++)
799 tmp_mp_data->buffer_bo[i] = buffer_bo[i];
801 *mp_data = tmp_mp_data;
802 /*LOGD("mp_data %p", tmp_mp_data);*/
804 ret = CAMERA_ERROR_OUT_OF_MEMORY;
805 LOGE("failed to alloc media packet data");
808 ((camera_media_packet_data *)*mp_data)->ref_cnt++;
814 void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
818 camera_msg_param param;
820 if (!mp_data || !cb_info) {
821 LOGE("NULL pointer %p %p", mp_data, cb_info);
825 if (mp_data->ref_cnt > 1) {
827 LOGD("ref count %d", mp_data->ref_cnt);
829 /* release imported bo */
830 for (i = 0 ; i < mp_data->num_buffer_key ; i++) {
831 tbm_bo_unref(mp_data->buffer_bo[i]);
832 mp_data->buffer_bo[i] = NULL;
836 _camera_release_imported_bo(&mp_data->bo);
837 _camera_release_imported_bo(&mp_data->data_bo);
840 tbm_key = mp_data->tbm_key;
842 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
844 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
853 int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
854 camera_media_packet_data *mp_data, media_packet_h *packet)
856 media_packet_h pkt = NULL;
857 bool make_pkt_fmt = false;
858 tbm_surface_h tsurf = NULL;
859 tbm_surface_info_s tsurf_info;
860 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
861 uint32_t bo_format = 0;
864 int num_buffer_key = 0;
865 tbm_bo *buffer_bo = NULL;
867 if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) {
868 LOGE("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p",
869 cb_info, stream, mp_data, packet);
870 return CAMERA_ERROR_INVALID_PARAMETER;
873 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
874 buffer_bo = mp_data->buffer_bo;
875 num_buffer_key = mp_data->num_buffer_key;
877 /* create tbm surface */
878 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
879 tsurf_info.planes[i].stride = stream->stride[i];
881 /* get tbm surface format */
882 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
883 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
885 if (ret == CAMERA_ERROR_NONE) {
886 tsurf_info.width = stream->width;
887 tsurf_info.height = stream->height;
888 tsurf_info.format = bo_format;
889 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
890 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
892 if (num_buffer_key > 0) {
894 case TBM_FORMAT_NV12:
895 case TBM_FORMAT_NV21:
896 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
897 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
898 tsurf_info.planes[0].offset = 0;
899 if (num_buffer_key == 1)
900 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
901 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
903 case TBM_FORMAT_YUV420:
904 case TBM_FORMAT_YVU420:
905 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
906 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
907 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
908 tsurf_info.planes[0].offset = 0;
909 if (num_buffer_key == 1) {
910 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
911 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
913 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
915 case TBM_FORMAT_UYVY:
916 case TBM_FORMAT_YUYV:
917 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
918 tsurf_info.planes[0].offset = 0;
919 tsurf_info.size = tsurf_info.planes[0].size;
925 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_key);
926 } else if (mp_data->data_bo) {
928 case TBM_FORMAT_NV12:
929 case TBM_FORMAT_NV21:
930 tsurf_info.planes[0].size = stream->width * stream->height;
931 tsurf_info.planes[1].size = (tsurf_info.planes[0].size) >> 1;
932 tsurf_info.planes[0].offset = 0;
933 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
934 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
936 case TBM_FORMAT_YUV420:
937 case TBM_FORMAT_YVU420:
938 tsurf_info.planes[0].size = stream->width * stream->height;
939 tsurf_info.planes[1].size = (stream->width >> 1) * (stream->height >> 1);
940 tsurf_info.planes[2].size = tsurf_info.planes[1].size;
941 tsurf_info.planes[0].offset = 0;
942 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
943 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
944 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
946 case TBM_FORMAT_UYVY:
947 case TBM_FORMAT_YUYV:
948 tsurf_info.planes[0].size = (stream->width * stream->height) << 1;
949 tsurf_info.planes[0].offset = 0;
950 tsurf_info.size = tsurf_info.planes[0].size;
956 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1);
958 /*LOGD("tbm surface %p", tsurf);*/
962 /* check media packet format */
963 if (cb_info->pkt_fmt) {
964 int pkt_fmt_width = 0;
965 int pkt_fmt_height = 0;
966 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
968 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
969 if (pkt_fmt_mimetype != mimetype ||
970 pkt_fmt_width != stream->width ||
971 pkt_fmt_height != stream->height) {
972 LOGW("change fmt: current 0x%x, %dx%d",
973 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
974 media_format_unref(cb_info->pkt_fmt);
975 cb_info->pkt_fmt = NULL;
982 /* create packet format */
984 LOGW("make new pkt_fmt - 0x%x, %dx%d", mimetype, stream->width, stream->height);
985 ret = media_format_create(&cb_info->pkt_fmt);
986 if (ret == MEDIA_FORMAT_ERROR_NONE) {
987 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
988 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
989 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
990 LOGW("media_format_set : 0x%x", ret);
992 LOGW("media_format_create failed 0x%x", ret);
996 /* create media packet */
997 ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt,
998 tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
999 (void *)cb_info, &pkt);
1000 if (ret != MEDIA_PACKET_ERROR_NONE) {
1001 LOGE("media_packet_create failed 0x%x", ret);
1002 tbm_surface_destroy(tsurf);
1006 LOGE("tbm surface failed. %dx%d, format %d, num_buffer_key %d, data_bo %p",
1007 stream->width, stream->height, stream->format, num_buffer_key, mp_data->data_bo);
1011 /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
1012 /* set media packet data */
1013 ret = media_packet_set_extra(pkt, (void *)mp_data);
1014 if (ret != MEDIA_PACKET_ERROR_NONE) {
1015 LOGE("media_packet_set_extra failed");
1017 _camera_media_packet_data_release(mp_data, cb_info);
1020 media_packet_destroy(pkt);
1023 /* set timestamp : msec -> nsec */
1024 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
1025 LOGW("media_packet_set_pts failed");
1034 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
1037 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1038 camera_media_packet_data *mp_data = NULL;
1039 tbm_surface_h tsurf = NULL;
1041 if (!pkt || !cb_info) {
1042 LOGE("NULL pointer %p %p", pkt, cb_info);
1043 return MEDIA_PACKET_FINALIZE;
1046 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1047 if (ret != MEDIA_PACKET_ERROR_NONE) {
1048 LOGE("media_packet_get_extra failed 0x%x", ret);
1049 return MEDIA_PACKET_FINALIZE;
1052 /*LOGD("mp_data %p", mp_data);*/
1054 g_mutex_lock(&cb_info->mp_data_mutex);
1056 _camera_media_packet_data_release(mp_data, cb_info);
1059 g_mutex_unlock(&cb_info->mp_data_mutex);
1061 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1062 if (ret != MEDIA_PACKET_ERROR_NONE)
1063 LOGE("get tbm_surface failed 0x%x", ret);
1066 tbm_surface_destroy(tsurf);
1070 return MEDIA_PACKET_FINALIZE;
1073 static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event)
1079 tbm_bo_handle bo_handle = {NULL, };
1080 camera_msg_param param;
1082 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1083 LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event);
1087 /*LOGD("get camera msg %s, event %d", recv_msg, event);*/
1089 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1090 if (!(CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) &&
1091 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] == NULL &&
1092 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] == NULL) {
1093 LOGW("all preview callback from user are NULL");
1096 } else if (cb_info->user_cb[event] == NULL) {
1097 LOGW("user callback for event %d is not set", event);
1102 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1108 muse_camera_msg_get(previous, recv_msg);
1109 muse_camera_msg_get(current, recv_msg);
1110 muse_camera_msg_get(by_policy, recv_msg);
1112 LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
1113 previous, current, by_policy);
1115 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1116 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1119 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1123 muse_camera_msg_get(state, recv_msg);
1125 LOGD("FOCUS state - %d", state);
1127 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1130 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1131 LOGD("CAPTURE_COMPLETED");
1132 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1134 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1135 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1139 int num_buffer_key = 0;
1140 int buffer_key[BUFFER_MAX_PLANE_NUM] = {0, };
1142 unsigned char *buf_pos = NULL;
1144 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
1145 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
1146 tbm_bo data_bo = NULL;
1147 tbm_bo_handle data_bo_handle = {.ptr = NULL};
1149 camera_preview_data_s frame;
1150 camera_stream_data_s *stream = NULL;
1151 camera_media_packet_data *mp_data = NULL;
1152 media_packet_h pkt = NULL;
1153 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1154 media_packet_h pkt_evas = NULL;
1155 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1157 muse_camera_msg_get(tbm_key, recv_msg);
1158 muse_camera_msg_get(num_buffer_key, recv_msg);
1159 muse_camera_msg_get_array(buffer_key, recv_msg);
1160 muse_camera_msg_get(data_key, recv_msg);
1162 memset(&frame, 0x0, sizeof(camera_preview_data_s));
1165 LOGE("invalid key %d", tbm_key);
1169 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1172 /* import tbm data_bo and get virtual address */
1173 if (!_camera_import_tbm_key(cb_info->bufmgr, data_key, &data_bo, &data_bo_handle)) {
1174 LOGE("failed to import data key %d", data_key);
1175 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1180 /* import tbm bo and get virtual address */
1181 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
1182 LOGE("failed to import key %d", tbm_key);
1183 _camera_release_imported_bo(&data_bo);
1184 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1188 buf_pos = (unsigned char *)bo_handle.ptr;
1190 /* get stream info */
1191 stream = (camera_stream_data_s *)buf_pos;
1193 for (i = 0 ; i < num_buffer_key ; i++) {
1194 /* import buffer bo and get virtual address */
1195 if (!_camera_import_tbm_key(cb_info->bufmgr, buffer_key[i], &buffer_bo[i], &buffer_bo_handle[i])) {
1196 LOGE("failed to import buffer key %d", buffer_key[i]);
1198 /* release imported bo */
1199 _camera_release_imported_bo(&data_bo);
1200 _camera_release_imported_bo(&bo);
1202 for (i -= 1 ; i >= 0 ; i--)
1203 _camera_release_imported_bo(&buffer_bo[i]);
1205 /* send return buffer */
1206 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1212 /* call preview callback */
1213 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
1214 _camera_preview_frame_create(stream, num_buffer_key, buffer_bo_handle, &data_bo_handle, &frame);
1216 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
1217 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
1220 if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
1221 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1222 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
1224 if (ret == CAMERA_ERROR_NONE) {
1225 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt_evas);
1226 if (ret != CAMERA_ERROR_NONE) {
1227 LOGE("create pkt for evas failed");
1228 _camera_media_packet_data_release(mp_data, cb_info);
1232 #else /* TIZEN_FEATURE_EVAS_RENDERER */
1233 LOGW("evas renderer is not supported");
1234 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1237 /* call media packet callback */
1238 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
1239 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
1241 if (ret == CAMERA_ERROR_NONE) {
1242 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt);
1244 if (ret == CAMERA_ERROR_NONE) {
1245 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
1246 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
1248 _camera_media_packet_data_release(mp_data, cb_info);
1254 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1255 /* call evas renderer */
1257 g_mutex_lock(&cb_info->evas_mutex);
1258 if (cb_info->run_evas_render) {
1259 mm_evas_renderer_write(pkt_evas, cb_info->evas_info);
1261 LOGW("evas renderer is stopped, skip this buffer...");
1262 media_packet_destroy(pkt_evas);
1265 g_mutex_unlock(&cb_info->evas_mutex);
1267 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1269 /* send message for preview callback return */
1270 if (!CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS))
1271 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info, NULL, 0);
1273 if (mp_data == NULL) {
1274 /* release imported bo */
1275 for (i = 0 ; i < num_buffer_key ; i++)
1276 _camera_release_imported_bo(&buffer_bo[i]);
1278 /* unmap and unref tbm bo */
1279 _camera_release_imported_bo(&data_bo);
1280 _camera_release_imported_bo(&bo);
1283 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1285 /*LOGD("return buffer Done");*/
1289 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1293 muse_camera_msg_get(percent, recv_msg);
1295 LOGD("HDR progress - %d \%", percent);
1297 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1300 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1306 muse_camera_msg_get(policy, recv_msg);
1307 muse_camera_msg_get(previous, recv_msg);
1308 muse_camera_msg_get(current, recv_msg);
1310 LOGW("INTERRUPTED - policy %d, state previous %d, current %d",
1311 policy, previous, current);
1313 if (policy == CAMERA_POLICY_SOUND)
1314 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND is deprecated and will be removed from next release.");
1315 else if (policy == CAMERA_POLICY_SOUND_BY_CALL)
1316 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_CALL is deprecated and will be removed from next release.");
1317 else if (policy == CAMERA_POLICY_SOUND_BY_ALARM)
1318 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_ALARM is deprecated and will be removed from next release.");
1320 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1321 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1324 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1327 camera_detected_face_s *faces = NULL;
1329 muse_camera_msg_get(count, recv_msg);
1330 muse_camera_msg_get(tbm_key, recv_msg);
1332 if (count > 0 && tbm_key > 0) {
1333 LOGD("FACE_DETECTION - count %d, tbm_key %d", count, tbm_key);
1335 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle))
1339 faces = bo_handle.ptr;
1341 ((camera_face_detected_cb)cb_info->user_cb[event])(faces, count, cb_info->user_data[event]);
1347 for (i = 0 ; i < count ; i++) {
1348 LOGD("id[%2d] - score %d, position (%d,%d,%dx%d)",
1349 i, faces[i].score, faces[i].x, faces[i].y, faces[i].width, faces[i].height);
1355 _camera_release_imported_bo(&bo);
1358 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1359 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1361 /*LOGD("return buffer done");*/
1363 LOGE("invalid message - count %d, key %d", count, tbm_key);
1367 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1370 int current_state = 0;
1372 muse_camera_msg_get(error, recv_msg);
1373 muse_camera_msg_get(current_state, recv_msg);
1375 LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
1377 if (error == CAMERA_ERROR_SOUND_POLICY)
1378 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
1379 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_CALL)
1380 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
1381 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_ALARM)
1382 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
1384 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1385 (camera_state_e)current_state, cb_info->user_data[event]);
1388 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1390 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1391 muse_camera_msg_get(param1, recv_msg);
1392 muse_camera_msg_get(param2, recv_msg);
1394 /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/
1396 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1397 cb_info->user_cb[event] = NULL;
1398 cb_info->user_data[event] = NULL;
1399 LOGW("stop foreach callback for event %d", event);
1402 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1404 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1406 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1408 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1410 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1412 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1414 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1416 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1418 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1420 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1422 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1424 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1426 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1428 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1430 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1431 muse_camera_msg_get(param1, recv_msg);
1433 /*LOGD("event %d SUPPORTED %d ", event, param1);*/
1435 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1436 cb_info->user_cb[event] = NULL;
1437 cb_info->user_data[event] = NULL;
1438 LOGW("stop foreach callback for event %d", event);
1441 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1443 camera_image_data_s *rImage = NULL;
1444 camera_image_data_s *rPostview = NULL;
1445 camera_image_data_s *rThumbnail = NULL;
1446 unsigned char *buf_pos = NULL;
1447 int tbm_key_main = 0;
1448 int tbm_key_post = 0;
1449 int tbm_key_thumb = 0;
1450 tbm_bo bo_main = NULL;
1451 tbm_bo bo_post = NULL;
1452 tbm_bo bo_thumb = NULL;
1453 tbm_bo_handle bo_main_handle = {NULL, };
1454 tbm_bo_handle bo_post_handle = {NULL, };
1455 tbm_bo_handle bo_thumb_handle = {NULL, };
1457 muse_camera_msg_get(tbm_key_main, recv_msg);
1458 muse_camera_msg_get(tbm_key_post, recv_msg);
1459 muse_camera_msg_get(tbm_key_thumb, recv_msg);
1462 LOGD("camera capture callback came in. tbm_key_main %d, tbm_key_post %d, tbm_key_thumb %d",
1463 tbm_key_main, tbm_key_post, tbm_key_thumb);
1466 if (tbm_key_main <= 0) {
1467 LOGE("invalid key %d", tbm_key_main);
1471 /* import tbm bo and get virtual address */
1472 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_main, &bo_main, &bo_main_handle))
1475 buf_pos = (unsigned char *)bo_main_handle.ptr;
1476 rImage = (camera_image_data_s *)buf_pos;
1477 rImage->data = buf_pos + sizeof(camera_image_data_s);
1478 if (rImage->exif && rImage->exif_size > 0) {
1479 rImage->exif = rImage->data + rImage->size;
1481 rImage->exif = NULL;
1482 rImage->exif_size = 0;
1485 LOGD("image info %dx%d, size %d, EXIF info %p, size %d",
1486 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
1488 if (tbm_key_post > 0) {
1489 /* import tbm bo and get virtual address */
1490 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_post, &bo_post, &bo_post_handle))
1493 buf_pos = (unsigned char *)bo_post_handle.ptr;
1494 rPostview = (camera_image_data_s *)buf_pos;
1495 LOGD("rPostview->size : %d", rPostview->size);
1496 rPostview->data = buf_pos + sizeof(camera_image_data_s);
1499 if (tbm_key_thumb > 0) {
1500 /* import tbm bo and get virtual address */
1501 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_thumb, &bo_thumb, &bo_thumb_handle))
1504 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
1506 rThumbnail = (camera_image_data_s *)buf_pos;
1507 LOGD("rThumbnail->size : %d", rThumbnail->size);
1508 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
1511 ((camera_capturing_cb)cb_info->user_cb[event])(rImage, rPostview, rThumbnail, cb_info->user_data[event]);
1513 /* unmap and unref tbm bo */
1514 _camera_release_imported_bo(&bo_main);
1517 tbm_key = tbm_key_main;
1519 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1521 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1523 if (tbm_key_post > 0) {
1524 /* unmap and unref tbm bo */
1525 _camera_release_imported_bo(&bo_post);
1528 param.value.value_INT = tbm_key_post;
1529 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1532 if (tbm_key_thumb > 0) {
1533 /* unmap and unref tbm bo */
1534 _camera_release_imported_bo(&bo_thumb);
1537 param.value.value_INT = tbm_key_thumb;
1538 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1541 LOGD("return buffer done");
1544 default: /* MUSE_CAMERA_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR */
1545 LOGE("render error");
1552 static bool _camera_idle_event_callback(void *data)
1554 camera_cb_info_s *cb_info = NULL;
1555 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1557 if (cam_idle_event == NULL) {
1558 LOGE("cam_idle_event is NULL");
1563 g_mutex_lock(&cam_idle_event->event_mutex);
1565 cb_info = cam_idle_event->cb_info;
1566 if (cb_info == NULL) {
1567 LOGW("camera cb_info is NULL. event %d", cam_idle_event->event);
1568 goto IDLE_EVENT_CALLBACK_DONE;
1571 /* remove event from list */
1572 g_mutex_lock(&cb_info->idle_event_mutex);
1574 if (cb_info->idle_event_list)
1575 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1577 /*LOGD("remove camera idle event %p, %p", cam_idle_event, cb_info->idle_event_list);*/
1578 g_mutex_unlock(&cb_info->idle_event_mutex);
1581 _camera_client_user_callback(cam_idle_event->cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
1583 /* send signal for waiting thread */
1584 g_cond_signal(&cb_info->idle_event_cond);
1586 IDLE_EVENT_CALLBACK_DONE:
1587 /* unlock and release event */
1588 g_mutex_unlock(&cam_idle_event->event_mutex);
1589 g_mutex_clear(&cam_idle_event->event_mutex);
1591 g_free(cam_idle_event);
1592 cam_idle_event = NULL;
1597 static void *_camera_msg_handler_func(gpointer data)
1601 camera_message_s *cam_msg = NULL;
1602 camera_idle_event_s *cam_idle_event = NULL;
1603 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1604 camera_cb_info_s *cb_info = NULL;
1606 if (!handler_info || !handler_info->cb_info) {
1607 LOGE("NULL handler %p", handler_info);
1611 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1612 type = handler_info->type;
1614 LOGD("t:%d start", type);
1616 g_mutex_lock(&handler_info->mutex);
1618 while (g_atomic_int_get(&handler_info->running)) {
1619 if (g_queue_is_empty(handler_info->queue)) {
1620 /*LOGD("t:%d signal wait...", type);*/
1621 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1622 /*LOGD("t:%d signal received", type);*/
1624 if (g_atomic_int_get(&handler_info->running) == 0) {
1625 LOGD("t:%d stop event thread", type);
1630 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1632 g_mutex_unlock(&handler_info->mutex);
1634 if (cam_msg == NULL) {
1635 LOGE("t:%d NULL message", type);
1636 g_mutex_lock(&handler_info->mutex);
1642 if (api < MUSE_CAMERA_API_MAX) {
1645 g_mutex_lock(&cb_info->api_mutex[api]);
1647 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1648 if (cb_info->api_waiting[api] > 0) {
1649 cb_info->api_ret[api] = ret;
1650 cb_info->api_activating[api] = 1;
1652 /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
1654 g_cond_signal(&cb_info->api_cond[api]);
1656 LOGW("no waiting for this api [%d]", api);
1659 LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1662 g_mutex_unlock(&cb_info->api_mutex[api]);
1663 } else if (api == MUSE_CAMERA_CB_EVENT) {
1664 switch (cam_msg->event_class) {
1665 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1666 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event);
1668 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1669 cam_idle_event = g_new0(camera_idle_event_s, 1);
1670 if (cam_idle_event == NULL) {
1671 LOGE("t:%d cam_idle_event alloc failed", type);
1675 cam_idle_event->event = cam_msg->event;
1676 cam_idle_event->cb_info = cb_info;
1677 g_mutex_init(&cam_idle_event->event_mutex);
1678 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg) - 1);
1680 /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, cam_msg->event, cam_idle_event);*/
1682 g_mutex_lock(&cb_info->idle_event_mutex);
1683 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1684 g_mutex_unlock(&cb_info->idle_event_mutex);
1686 g_idle_add_full(G_PRIORITY_DEFAULT,
1687 (GSourceFunc)_camera_idle_event_callback,
1688 (gpointer)cam_idle_event,
1692 LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
1696 LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1702 g_mutex_lock(&handler_info->mutex);
1705 /* remove remained event */
1706 while (!g_queue_is_empty(handler_info->queue)) {
1707 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1709 LOGD("t:%d remove camera message %p", type, cam_msg);
1713 LOGW("t:%d NULL camera message", type);
1717 g_mutex_unlock(&handler_info->mutex);
1719 LOGD("t:%d return", type);
1725 static void _camera_remove_idle_event_all(camera_cb_info_s *cb_info)
1727 camera_idle_event_s *cam_idle_event = NULL;
1728 gboolean ret = TRUE;
1730 gint64 end_time = 0;
1732 if (cb_info == NULL) {
1733 LOGE("cb_info is NULL");
1737 g_mutex_lock(&cb_info->idle_event_mutex);
1739 if (cb_info->idle_event_list == NULL) {
1740 LOGD("No remained idle event");
1741 g_mutex_unlock(&cb_info->idle_event_mutex);
1745 list = cb_info->idle_event_list;
1748 cam_idle_event = list->data;
1749 list = g_list_next(list);
1751 if (!cam_idle_event) {
1752 LOGW("Fail to remove idle event. The event is NULL");
1756 if (g_mutex_trylock(&cam_idle_event->event_mutex)) {
1757 ret = g_idle_remove_by_data(cam_idle_event);
1759 LOGD("remove idle event [%p], ret[%d]", cam_idle_event, ret);
1762 cam_idle_event->cb_info = NULL;
1763 LOGW("idle event %p will be called later", cam_idle_event);
1766 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1768 g_mutex_unlock(&cam_idle_event->event_mutex);
1771 g_mutex_clear(&cam_idle_event->event_mutex);
1773 g_free(cam_idle_event);
1774 cam_idle_event = NULL;
1776 LOGD("remove idle event done");
1782 LOGW("event lock failed. it's being called...");
1784 end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
1786 if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
1787 LOGW("signal received");
1792 g_list_free(cb_info->idle_event_list);
1793 cb_info->idle_event_list = NULL;
1795 g_mutex_unlock(&cb_info->idle_event_mutex);
1801 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg)
1803 camera_message_s *cam_msg = NULL;
1805 if (!cb_info || !msg) {
1806 LOGE("NULL pointer %p %p", cb_info, msg);
1810 cam_msg = g_new0(camera_message_s, 1);
1812 LOGE("failed to alloc cam_msg for [%s]", msg);
1817 cam_msg->event = event;
1818 cam_msg->event_class = event_class;
1820 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1822 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1824 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1825 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1826 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1827 g_cond_signal(&cb_info->preview_cb_info.cond);
1828 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1829 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1830 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1831 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1832 g_cond_signal(&cb_info->capture_cb_info.cond);
1833 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1835 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1836 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1837 g_cond_signal(&cb_info->msg_handler_info.cond);
1838 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1847 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg)
1849 int ret = CAMERA_ERROR_NONE;
1853 int event_class = -1;
1857 if (!cb_info || !msg) {
1858 LOGE("invalid ptr %p %p", cb_info, msg);
1862 /*LOGD("msg [%s]", msg);*/
1864 if (!muse_camera_msg_get(api, msg)) {
1865 LOGE("failed to get camera api");
1869 if (api == MUSE_CAMERA_CB_EVENT) {
1870 if (!muse_camera_msg_get(event, msg) ||
1871 !muse_camera_msg_get(event_class, msg)) {
1872 LOGE("failed to get camera event or event_class [%s]", msg);
1876 if (!muse_camera_msg_get(api_class, msg)) {
1877 LOGE("failed to get camera api_class [%s]", msg);
1882 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1883 if (api >= MUSE_CAMERA_API_MAX) {
1884 LOGE("invalid api %d", api);
1888 if (!muse_camera_msg_get(ret, msg)) {
1889 LOGE("failed to get camera ret");
1893 g_mutex_lock(&cb_info->api_mutex[api]);
1896 case MUSE_CAMERA_API_CREATE:
1897 if (ret != CAMERA_ERROR_NONE) {
1898 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1899 LOGE("camera create error 0x%x. close client cb handler", ret);
1902 case MUSE_CAMERA_API_DESTROY:
1903 if (ret == CAMERA_ERROR_NONE) {
1904 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1905 LOGD("camera destroy done. close client cb handler");
1909 muse_camera_msg_get(get_type, msg);
1910 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1911 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1912 muse_camera_msg_get(get_index, msg);
1915 case MUSE_CAMERA_GET_TYPE_INT:
1916 muse_core_msg_json_deserialize("get_value", msg, NULL, &cb_info->get_int[get_index], NULL, MUSE_TYPE_INT);
1918 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1919 muse_core_msg_json_deserialize("get_value0", msg, NULL, &cb_info->get_int_pair[get_index][0], NULL, MUSE_TYPE_INT);
1920 muse_core_msg_json_deserialize("get_value1", msg, NULL, &cb_info->get_int_pair[get_index][1], NULL, MUSE_TYPE_INT);
1922 case MUSE_CAMERA_GET_TYPE_ARRAY:
1923 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
1924 muse_core_msg_json_deserialize("get_value",
1925 msg, NULL, cb_info->get_display_roi_area, NULL, MUSE_TYPE_ARRAY);
1926 LOGD("get display roi %d,%d,%dx%d",
1927 cb_info->get_display_roi_area[0],
1928 cb_info->get_display_roi_area[1],
1929 cb_info->get_display_roi_area[2],
1930 cb_info->get_display_roi_area[3]);
1932 muse_core_msg_json_deserialize("get_value",
1933 msg, NULL, cb_info->get_geotag, NULL, MUSE_TYPE_ARRAY);
1934 LOGD("get geotag %lf, %lf, %lf",
1935 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
1938 case MUSE_CAMERA_GET_TYPE_STRING:
1939 muse_core_msg_json_deserialize("get_value", msg, NULL, cb_info->get_string[get_index], NULL, MUSE_TYPE_STRING);
1942 LOGW("unknown type %d", get_type);
1949 if (cb_info->api_waiting[api] > 0) {
1950 cb_info->api_ret[api] = ret;
1951 cb_info->api_activating[api] = 1;
1953 g_cond_signal(&cb_info->api_cond[api]);
1955 LOGW("no waiting for this api [%d]", api);
1958 g_mutex_unlock(&cb_info->api_mutex[api]);
1959 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
1960 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg);
1962 LOGW("unknown camera api %d, class %d", api, api_class);
1969 static void *_camera_msg_recv_func(gpointer data)
1971 int recv_length = 0;
1972 int single_length = 0;
1973 int remained_length = 0;
1974 char *recv_msg = NULL;
1975 char *single_msg = NULL;
1976 char *remained_msg = NULL;
1980 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
1983 LOGE("cb_info NULL");
1989 single_msg = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
1991 LOGE("single_msg malloc failed");
1995 recv_msg = cb_info->recv_msg;
1997 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
1998 recv_length = muse_core_ipc_recv_msg(cb_info->fd, recv_msg);
1999 if (recv_length <= 0) {
2000 cb_info->is_server_connected = FALSE;
2001 LOGE("receive msg failed - server disconnected");
2009 /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
2011 /* Need to split the combined entering msgs */
2012 for (cur_pos = 0 ; cur_pos < recv_length ; cur_pos++) {
2013 if (recv_msg[cur_pos] == '}') {
2014 single_length = cur_pos - prev_pos + 1;
2016 if (single_length < MUSE_CAMERA_MSG_MAX_LENGTH) {
2017 /* check remained msg */
2018 if (remained_length > 0) {
2020 strncpy(single_msg, remained_msg, remained_length);
2021 strncpy(single_msg + remained_length, recv_msg + prev_pos, single_length);
2022 single_msg[remained_length + single_length] = '\0';
2025 remained_msg = NULL;
2027 strncpy(single_msg, recv_msg + prev_pos, single_length);
2028 single_msg[single_length] = '\0';
2029 LOGE("lost msg [%s], skip...", single_msg);
2032 remained_length = 0;
2034 strncpy(single_msg, recv_msg + prev_pos, single_length);
2035 single_msg[single_length] = '\0';
2038 if (single_msg[0] == '{') {
2040 /*LOGD("splitted msg : [%s], Index : %d", single_msg, num_msg);*/
2041 /* process each message */
2042 __camera_process_msg(cb_info, single_msg);
2044 LOGE("invalid msg [%s]", single_msg);
2047 LOGE("too long message [len %d] skip...", single_length);
2050 prev_pos = cur_pos + 1;
2054 /* check incompleted message */
2055 if (recv_msg[recv_length - 1] != '}') {
2056 remained_length = recv_length - prev_pos;
2058 LOGW("incompleted message [len %d]", remained_length);
2060 remained_msg = (char *)malloc(remained_length + 1);
2062 strncpy(remained_msg, recv_msg + prev_pos, remained_length);
2063 remained_msg[remained_length] = '\0';
2065 LOGE("failed to alloc for remained msg");
2068 remained_length = 0;
2072 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
2074 if (!cb_info->is_server_connected) {
2075 /* send error msg for server disconnection */
2076 char *error_msg = muse_core_msg_json_factory_new(MUSE_CAMERA_CB_EVENT,
2077 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
2078 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
2082 LOGE("error_msg failed");
2083 goto CB_HANDLER_EXIT;
2086 __camera_add_msg_to_queue(cb_info,
2087 MUSE_CAMERA_CB_EVENT,
2088 MUSE_CAMERA_EVENT_TYPE_ERROR,
2089 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
2092 muse_core_msg_json_factory_free(error_msg);
2095 LOGE("add error msg for service disconnection done");
2106 remained_msg = NULL;
2113 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2114 int type, const char *thread_name, camera_cb_info_s *cb_info)
2116 if (!handler_info || !thread_name || !cb_info) {
2117 LOGE("t:%d NULL %p %p %p",
2118 type, handler_info, thread_name, cb_info);
2124 handler_info->type = type;
2125 handler_info->queue = g_queue_new();
2126 if (handler_info->queue == NULL) {
2127 LOGE("t:%d queue failed", type);
2131 g_mutex_init(&handler_info->mutex);
2132 g_cond_init(&handler_info->cond);
2134 handler_info->cb_info = (void *)cb_info;
2135 g_atomic_int_set(&handler_info->running, 1);
2137 handler_info->thread = g_thread_try_new(thread_name,
2138 _camera_msg_handler_func, (gpointer)handler_info, NULL);
2139 if (handler_info->thread == NULL) {
2140 LOGE("t:%d thread failed", type);
2142 g_mutex_clear(&handler_info->mutex);
2143 g_cond_clear(&handler_info->cond);
2144 g_queue_free(handler_info->queue);
2145 handler_info->queue = NULL;
2150 LOGD("t:%d done", type);
2156 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2160 if (!handler_info) {
2161 LOGE("NULL handler");
2165 if (!handler_info->thread) {
2166 LOGW("thread is not created");
2170 type = handler_info->type;
2172 LOGD("t:%d thread %p", type, handler_info->thread);
2174 g_mutex_lock(&handler_info->mutex);
2175 g_atomic_int_set(&handler_info->running, 0);
2176 g_cond_signal(&handler_info->cond);
2177 g_mutex_unlock(&handler_info->mutex);
2179 g_thread_join(handler_info->thread);
2180 handler_info->thread = NULL;
2182 g_mutex_clear(&handler_info->mutex);
2183 g_cond_clear(&handler_info->cond);
2184 g_queue_free(handler_info->queue);
2185 handler_info->queue = NULL;
2187 LOGD("t:%d done", type);
2193 static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
2195 camera_cb_info_s *cb_info = NULL;
2198 g_return_val_if_fail(sockfd > 0, NULL);
2200 cb_info = g_new0(camera_cb_info_s, 1);
2201 if (cb_info == NULL) {
2202 LOGE("cb_info failed");
2206 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2208 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2209 g_mutex_init(&cb_info->api_mutex[i]);
2210 g_cond_init(&cb_info->api_cond[i]);
2213 g_mutex_init(&cb_info->fd_lock);
2214 g_mutex_init(&cb_info->idle_event_mutex);
2215 g_cond_init(&cb_info->idle_event_cond);
2216 g_mutex_init(&cb_info->mp_data_mutex);
2217 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2218 g_mutex_init(&cb_info->evas_mutex);
2219 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2221 /* message handler thread */
2222 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2223 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2224 LOGE("msg_handler_info failed");
2228 /* message handler thread for preview callback */
2229 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2230 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2231 LOGE("preview_cb_info failed");
2235 /* message handler thread for capture callback */
2236 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2237 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2238 LOGE("capture_cb_info failed");
2242 cb_info->fd = sockfd;
2243 cb_info->preview_cb_flag = 0;
2244 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2245 cb_info->evas_info = NULL;
2246 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2248 /* message receive thread */
2249 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2250 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2251 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2252 if (cb_info->msg_recv_thread == NULL) {
2253 LOGE("message receive thread creation failed");
2257 cb_info->is_server_connected = TRUE;
2263 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2264 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2265 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2267 g_mutex_clear(&cb_info->fd_lock);
2268 g_mutex_clear(&cb_info->idle_event_mutex);
2269 g_cond_clear(&cb_info->idle_event_cond);
2270 g_mutex_clear(&cb_info->mp_data_mutex);
2271 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2272 g_mutex_clear(&cb_info->evas_mutex);
2273 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2275 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2276 g_mutex_clear(&cb_info->api_mutex[i]);
2277 g_cond_clear(&cb_info->api_cond[i]);
2287 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2291 g_return_if_fail(cb_info != NULL);
2293 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2295 g_thread_join(cb_info->msg_recv_thread);
2296 cb_info->msg_recv_thread = NULL;
2298 LOGD("msg_recv thread removed");
2300 /* destroy msg handler threads */
2301 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2302 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2303 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2305 g_mutex_clear(&cb_info->fd_lock);
2306 g_mutex_clear(&cb_info->idle_event_mutex);
2307 g_cond_clear(&cb_info->idle_event_cond);
2308 g_mutex_clear(&cb_info->mp_data_mutex);
2309 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2310 g_mutex_clear(&cb_info->evas_mutex);
2311 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2313 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2314 g_mutex_clear(&cb_info->api_mutex[i]);
2315 g_cond_clear(&cb_info->api_cond[i]);
2318 if (cb_info->fd > -1) {
2319 muse_core_connection_close(cb_info->fd);
2323 if (cb_info->bufmgr) {
2324 tbm_bufmgr_deinit(cb_info->bufmgr);
2325 cb_info->bufmgr = NULL;
2327 if (cb_info->pkt_fmt) {
2328 media_format_unref(cb_info->pkt_fmt);
2329 cb_info->pkt_fmt = NULL;
2332 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2333 if (cb_info->evas_info)
2334 mm_evas_renderer_destroy(&cb_info->evas_info);
2335 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2337 cb_info->preview_cb_flag = 0;
2346 int _camera_start_evas_rendering(camera_h camera)
2348 int ret = CAMERA_ERROR_NONE;
2349 camera_cli_s *pc = (camera_cli_s *)camera;
2351 if (!pc || !pc->cb_info) {
2352 LOGE("NULL handle");
2353 return CAMERA_ERROR_INVALID_PARAMETER;
2358 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2359 LOGE("EVAS surface is not set");
2360 return CAMERA_ERROR_NONE;
2363 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2364 g_mutex_lock(&pc->cb_info->evas_mutex);
2366 /* set evas render flag as RUN */
2367 pc->cb_info->run_evas_render = true;
2368 ret = CAMERA_ERROR_NONE;
2370 g_mutex_unlock(&pc->cb_info->evas_mutex);
2371 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2372 LOGW("evas renderer is not supported");
2373 ret = CAMERA_ERROR_NOT_SUPPORTED;
2374 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2380 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2382 int ret = CAMERA_ERROR_NONE;
2383 camera_cli_s *pc = (camera_cli_s *)camera;
2385 if (!pc || !pc->cb_info) {
2386 LOGE("NULL handle");
2387 return CAMERA_ERROR_INVALID_PARAMETER;
2390 LOGD("stop - keep screen %d", keep_screen);
2392 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2393 LOGE("EVAS surface is not set");
2394 return CAMERA_ERROR_NONE;
2397 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2398 g_mutex_lock(&pc->cb_info->evas_mutex);
2400 /* set evas render flag as STOP and release buffers */
2401 pc->cb_info->run_evas_render = false;
2403 ret = mm_evas_renderer_retrieve_all_packets(pc->cb_info->evas_info, keep_screen);
2404 if (ret != MM_ERROR_NONE) {
2405 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2406 ret = CAMERA_ERROR_INVALID_OPERATION;
2409 g_mutex_unlock(&pc->cb_info->evas_mutex);
2410 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2411 LOGW("evas renderer is not supported");
2412 ret = CAMERA_ERROR_NOT_SUPPORTED;
2413 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2419 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2421 int ret = CAMERA_ERROR_NONE;
2424 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2426 /* create muse connection */
2427 if (!key || !value) {
2428 LOGE("NULL pointer");
2429 return CAMERA_ERROR_INVALID_PARAMETER;
2432 sock_fd = muse_core_client_new();
2434 LOGE("muse_core_client_new failed");
2435 return CAMERA_ERROR_INVALID_OPERATION;
2438 msg = muse_core_msg_json_factory_new(api,
2439 MUSE_TYPE_INT, "module", MUSE_CAMERA,
2440 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2444 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2448 ret = muse_core_ipc_send_msg(sock_fd, msg);
2450 muse_core_msg_json_factory_free(msg);
2454 LOGE("send msg failed");
2455 ret = CAMERA_ERROR_INVALID_OPERATION;
2459 ret = muse_core_ipc_recv_msg(sock_fd, recv_msg);
2461 LOGE("recv msg failed %d", errno);
2462 ret = CAMERA_ERROR_INVALID_OPERATION;
2466 if (!muse_camera_msg_get(ret, recv_msg)) {
2467 LOGE("failed to get return value from msg [%s]", recv_msg);
2468 ret = CAMERA_ERROR_INVALID_OPERATION;
2472 if (ret == CAMERA_ERROR_NONE)
2473 muse_core_msg_json_deserialize(key, recv_msg, NULL, value, NULL, MUSE_TYPE_ANY);
2475 LOGD("api %d - value %d", api, *value);
2479 muse_core_connection_close(sock_fd);
2487 int camera_create(camera_device_e device, camera_h *camera)
2490 char *send_msg = NULL;
2492 int ret = CAMERA_ERROR_NONE;
2494 camera_cli_s *pc = NULL;
2495 tbm_bufmgr bufmgr = NULL;
2497 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2498 muse_core_api_module_e muse_module = MUSE_CAMERA;
2499 int device_type = (int)device;
2502 LOGE("NULL pointer");
2503 return CAMERA_ERROR_INVALID_PARAMETER;
2506 sock_fd = muse_core_client_new();
2508 LOGE("muse_core_client_new failed - returned fd %d", sock_fd);
2509 ret = CAMERA_ERROR_INVALID_OPERATION;
2515 send_msg = muse_core_msg_json_factory_new(api,
2516 MUSE_TYPE_INT, "module", muse_module,
2517 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2518 MUSE_TYPE_INT, "pid", pid,
2523 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2527 send_ret = muse_core_ipc_send_msg(sock_fd, send_msg);
2529 muse_core_msg_json_factory_free(send_msg);
2533 LOGE("send msg failed %d", errno);
2534 ret = CAMERA_ERROR_INVALID_OPERATION;
2538 pc = g_new0(camera_cli_s, 1);
2540 LOGE("camera_cli_s alloc failed");
2541 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2545 bufmgr = tbm_bufmgr_init(-1);
2546 if (bufmgr == NULL) {
2547 LOGE("get tbm bufmgr failed");
2548 ret = CAMERA_ERROR_INVALID_OPERATION;
2552 pc->cb_info = _camera_client_callback_new(sock_fd);
2553 if (pc->cb_info == NULL) {
2554 LOGE("cb_info alloc failed");
2555 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2561 LOGD("cb info : %d", pc->cb_info->fd);
2563 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2565 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2567 if (ret == CAMERA_ERROR_NONE) {
2568 intptr_t handle = 0;
2569 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2571 LOGE("Receiving Handle Failed!!");
2572 ret = CAMERA_ERROR_INVALID_OPERATION;
2576 pc->remote_handle = handle;
2577 pc->cb_info->bufmgr = bufmgr;
2579 ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL);
2580 if (ret != CAMERA_ERROR_NONE) {
2581 LOGE("init display failed 0x%x", ret);
2585 LOGD("camera create 0x%x", pc->remote_handle);
2586 *camera = (camera_h)pc;
2595 tbm_bufmgr_deinit(bufmgr);
2600 muse_core_connection_close(sock_fd);
2606 _camera_client_callback_destroy(pc->cb_info);
2613 LOGE("camera create error : 0x%x", ret);
2619 int camera_change_device(camera_h camera, camera_device_e device)
2622 int ret = CAMERA_ERROR_NONE;
2623 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2624 camera_cli_s *pc = (camera_cli_s *)camera;
2625 camera_msg_param param;
2627 if (!pc || !pc->cb_info) {
2628 LOGE("NULL handle");
2629 return CAMERA_ERROR_INVALID_PARAMETER;
2632 CAMERA_MSG_PARAM_SET(param, INT, device);
2634 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2636 if (ret == CAMERA_ERROR_NONE) {
2637 /* reset callback and user data */
2638 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2639 pc->cb_info->user_cb[i] = NULL;
2640 pc->cb_info->user_data[i] = NULL;
2642 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
2649 int camera_destroy(camera_h camera)
2651 int ret = CAMERA_ERROR_NONE;
2652 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2653 camera_cli_s *pc = (camera_cli_s *)camera;
2655 if (!pc || !pc->cb_info) {
2656 LOGE("NULL handle");
2657 return CAMERA_ERROR_INVALID_PARAMETER;
2662 if (pc->cb_info->is_server_connected)
2663 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2665 LOGW("server disconnected. release resource without send message.");
2667 if (ret == CAMERA_ERROR_NONE) {
2668 _camera_remove_idle_event_all(pc->cb_info);
2669 _camera_client_callback_destroy(pc->cb_info);
2679 int camera_start_preview(camera_h camera)
2681 int ret = CAMERA_ERROR_NONE;
2682 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2683 camera_cli_s *pc = (camera_cli_s *)camera;
2685 if (!pc || !pc->cb_info) {
2686 LOGE("NULL handle");
2687 return CAMERA_ERROR_INVALID_PARAMETER;
2692 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2693 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2694 ret = _camera_start_evas_rendering(camera);
2695 if (ret != CAMERA_ERROR_NONE) {
2696 LOGE("stop preview because of error");
2697 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, pc->cb_info, NULL, 0);
2701 LOGD("ret : 0x%x", ret);
2707 int camera_stop_preview(camera_h camera)
2709 int ret = CAMERA_ERROR_NONE;
2710 camera_cli_s *pc = (camera_cli_s *)camera;
2711 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2712 camera_state_e current_state = CAMERA_STATE_NONE;
2714 if (!pc || !pc->cb_info) {
2715 LOGE("NULL handle");
2716 return CAMERA_ERROR_INVALID_PARAMETER;
2721 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2722 ret = camera_get_state(camera, ¤t_state);
2723 if (ret != CAMERA_ERROR_NONE) {
2724 LOGE("failed to get current state 0x%x", ret);
2728 if (current_state == CAMERA_STATE_PREVIEW) {
2729 ret = _camera_stop_evas_rendering(camera, false);
2730 if (ret != CAMERA_ERROR_NONE)
2735 /* send stop preview message */
2736 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2738 if (ret != CAMERA_ERROR_NONE &&
2739 current_state == CAMERA_STATE_PREVIEW) {
2740 LOGW("restart evas rendering");
2741 _camera_start_evas_rendering(camera);
2744 LOGD("ret : 0x%x", ret);
2750 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2752 int ret = CAMERA_ERROR_NONE;
2753 camera_cli_s *pc = (camera_cli_s *)camera;
2754 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2756 if (!pc || !pc->cb_info) {
2757 LOGE("NULL handle");
2758 return CAMERA_ERROR_INVALID_PARAMETER;
2763 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2764 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2766 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2767 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2769 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2771 LOGD("ret : 0x%x", ret);
2777 bool camera_is_supported_continuous_capture(camera_h camera)
2779 int ret = CAMERA_ERROR_NONE;
2780 camera_cli_s *pc = (camera_cli_s *)camera;
2781 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2783 if (!pc || !pc->cb_info) {
2784 LOGE("NULL handle");
2785 return CAMERA_ERROR_INVALID_PARAMETER;
2790 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2793 LOGE("error is occurred 0x%x", ret);
2797 LOGD("ret : %d", ret);
2803 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)
2805 int ret = CAMERA_ERROR_NONE;
2806 camera_cli_s *pc = (camera_cli_s *)camera;
2807 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2808 camera_msg_param param;
2811 if (!pc || !pc->cb_info) {
2812 LOGE("NULL handle");
2813 return CAMERA_ERROR_INVALID_PARAMETER;
2818 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2819 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2821 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2822 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2824 value = (count << 16) | interval;
2825 CAMERA_MSG_PARAM_SET(param, INT, value);
2827 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2829 LOGD("ret : 0x%x", ret);
2835 int camera_stop_continuous_capture(camera_h camera)
2837 int ret = CAMERA_ERROR_NONE;
2838 camera_cli_s *pc = (camera_cli_s *)camera;
2839 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2841 if (!pc || !pc->cb_info) {
2842 LOGE("NULL handle");
2843 return CAMERA_ERROR_INVALID_PARAMETER;
2848 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2850 LOGD("ret : 0x%x", ret);
2856 bool camera_is_supported_face_detection(camera_h camera)
2858 int ret = CAMERA_ERROR_NONE;
2859 camera_cli_s *pc = (camera_cli_s *)camera;
2860 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2862 if (!pc || !pc->cb_info) {
2863 LOGE("NULL handle");
2864 return CAMERA_ERROR_INVALID_PARAMETER;
2869 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2872 LOGE("error is occurred 0x%x", ret);
2876 LOGD("ret : %d", ret);
2882 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2884 int ret = CAMERA_ERROR_NONE;
2885 camera_cli_s *pc = (camera_cli_s *)camera;
2886 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2888 if (!pc || !pc->cb_info) {
2889 LOGE("NULL handle");
2890 return CAMERA_ERROR_INVALID_PARAMETER;
2895 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2898 LOGE("error is occurred 0x%x", ret);
2902 LOGD("ret : %d", ret);
2908 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2910 int ret = CAMERA_ERROR_NONE;
2911 camera_cli_s *pc = (camera_cli_s *)camera;
2912 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2914 if (!pc || !pc->cb_info) {
2915 LOGE("NULL handle");
2916 return CAMERA_ERROR_INVALID_PARAMETER;
2921 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2924 LOGE("error is occurred 0x%x", ret);
2928 LOGD("ret : %d", ret);
2933 int camera_get_device_count(camera_h camera, int *device_count)
2935 int ret = CAMERA_ERROR_NONE;
2936 camera_cli_s *pc = (camera_cli_s *)camera;
2937 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2939 if (!pc || !pc->cb_info) {
2940 LOGE("NULL handle");
2941 return CAMERA_ERROR_INVALID_PARAMETER;
2946 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2948 if (ret == CAMERA_ERROR_NONE)
2949 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2951 LOGD("ret : 0x%x", ret);
2956 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2958 int ret = CAMERA_ERROR_NONE;
2959 camera_cli_s *pc = (camera_cli_s *)camera;
2960 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2962 if (!pc || !pc->cb_info) {
2963 LOGE("NULL handle");
2964 return CAMERA_ERROR_INVALID_PARAMETER;
2969 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2970 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2972 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2974 LOGD("ret : 0x%x", ret);
2979 int camera_stop_face_detection(camera_h camera)
2981 int ret = CAMERA_ERROR_NONE;
2982 camera_cli_s *pc = (camera_cli_s *)camera;
2983 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
2985 if (!pc || !pc->cb_info) {
2986 LOGE("NULL handle");
2987 return CAMERA_ERROR_INVALID_PARAMETER;
2992 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2994 LOGD("ret : 0x%x", ret);
2999 int camera_get_state(camera_h camera, camera_state_e *state)
3001 int ret = CAMERA_ERROR_NONE;
3002 camera_cli_s *pc = (camera_cli_s *)camera;
3003 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
3005 if (!pc || !pc->cb_info || !state) {
3006 LOGE("NULL pointer %p %p", pc, state);
3007 return CAMERA_ERROR_INVALID_PARAMETER;
3012 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3014 if (ret == CAMERA_ERROR_NONE)
3015 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
3017 LOGD("ret : 0x%x", ret);
3022 int camera_start_focusing(camera_h camera, bool continuous)
3024 int ret = CAMERA_ERROR_NONE;
3025 camera_cli_s *pc = (camera_cli_s *)camera;
3026 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
3027 camera_msg_param param;
3028 int is_continuous = (int)continuous;
3030 if (!pc || !pc->cb_info) {
3031 LOGE("NULL handle");
3032 return CAMERA_ERROR_INVALID_PARAMETER;
3037 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
3039 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3041 LOGD("ret : 0x%x", ret);
3046 int camera_cancel_focusing(camera_h camera)
3048 int ret = CAMERA_ERROR_NONE;
3049 camera_cli_s *pc = (camera_cli_s *)camera;
3050 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3052 if (!pc || !pc->cb_info) {
3053 LOGE("NULL handle");
3054 return CAMERA_ERROR_INVALID_PARAMETER;
3057 LOGD("Enter, remote_handle : %x", pc->remote_handle);
3059 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3061 LOGD("ret : 0x%x", ret);
3066 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3068 int ret = CAMERA_ERROR_NONE;
3069 void *set_display_handle = NULL;
3070 Evas_Object *obj = NULL;
3071 const char *object_type = NULL;
3072 camera_cli_s *pc = (camera_cli_s *)camera;
3073 camera_cb_info_s *cb_info = NULL;
3074 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3075 camera_state_e current_state = CAMERA_STATE_NONE;
3076 camera_msg_param param;
3080 if (!pc || !pc->cb_info) {
3081 LOGE("NULL handle");
3082 return CAMERA_ERROR_INVALID_PARAMETER;
3085 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
3086 LOGE("invalid type %d", type);
3087 return CAMERA_ERROR_INVALID_PARAMETER;
3090 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
3091 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
3092 return CAMERA_ERROR_INVALID_PARAMETER;
3095 cb_info = (camera_cb_info_s *)pc->cb_info;
3097 ret = camera_get_state(camera, ¤t_state);
3098 if (ret != CAMERA_ERROR_NONE) {
3099 LOGE("failed to get current state 0x%x", ret);
3103 if (current_state != CAMERA_STATE_CREATED) {
3104 LOGE("INVALID_STATE : current %d", current_state);
3105 return CAMERA_ERROR_INVALID_STATE;
3108 LOGD("Enter - display : %p", display);
3110 if (type == CAMERA_DISPLAY_TYPE_NONE) {
3111 set_display_handle = 0;
3112 LOGD("display type NONE");
3114 obj = (Evas_Object *)display;
3115 object_type = evas_object_type_get(obj);
3117 if (type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
3118 /* get wayland parent id */
3119 if (_camera_get_wl_info(obj, &pc->wl_info) != CAMERA_ERROR_NONE) {
3120 LOGE("failed to get wayland info");
3121 return CAMERA_ERROR_INVALID_OPERATION;
3124 set_display_handle = (void *)&pc->wl_info;
3125 LOGD("display type OVERLAY : handle %p", set_display_handle);
3126 } else if (type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
3127 /* evas object surface */
3128 set_display_handle = (void *)display;
3129 LOGD("display type EVAS : handle %p", set_display_handle);
3131 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3132 g_mutex_lock(&cb_info->evas_mutex);
3134 if (cb_info->evas_info) {
3135 LOGW("destroy existed evas renderer %p", cb_info->evas_info);
3136 ret = mm_evas_renderer_destroy(&cb_info->evas_info);
3137 if (ret != MM_ERROR_NONE) {
3138 LOGE("failed to destroy evas renderer %p", cb_info->evas_info);
3139 g_mutex_unlock(&cb_info->evas_mutex);
3140 return CAMERA_ERROR_INVALID_OPERATION;
3144 /* create evas renderer */
3145 ret = mm_evas_renderer_create(&cb_info->evas_info, (Evas_Object *)set_display_handle);
3146 if (ret == MM_ERROR_NONE) {
3147 camera_flip_e flip = CAMERA_FLIP_NONE;
3148 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3149 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3156 camera_get_display_flip(camera, &flip);
3157 camera_get_display_mode(camera, &mode);
3158 camera_get_display_rotation(camera, &rotation);
3159 camera_is_display_visible(camera, &visible);
3160 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3162 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
3163 flip, mode, rotation, visible, x, y, width, height);
3165 ret = mm_evas_renderer_set_flip(cb_info->evas_info, flip);
3166 ret |= mm_evas_renderer_set_geometry(cb_info->evas_info, mode);
3167 ret |= mm_evas_renderer_set_rotation(cb_info->evas_info, rotation);
3168 ret |= mm_evas_renderer_set_visible(cb_info->evas_info, visible);
3170 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
3171 ret |= mm_evas_renderer_set_roi_area(cb_info->evas_info, x, y, width, height);
3174 g_mutex_unlock(&cb_info->evas_mutex);
3176 if (ret != MM_ERROR_NONE) {
3177 LOGE("mm_evas_renderer error 0x%x", ret);
3178 return CAMERA_ERROR_INVALID_OPERATION;
3180 #else /* TIZEN_FEATURE_EVAS_RENDERER */
3181 LOGE("EVAS surface is not supported");
3182 return CAMERA_ERROR_NOT_SUPPORTED;
3183 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3185 LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type);
3186 return CAMERA_ERROR_INVALID_PARAMETER;
3189 LOGE("failed to get evas object type from %p", obj);
3190 return CAMERA_ERROR_INVALID_PARAMETER;
3194 pc->display_handle = (intptr_t)set_display_handle;
3196 if (type == CAMERA_DISPLAY_TYPE_OVERLAY) {
3199 length = sizeof(camera_wl_info_s) / sizeof(int) + \
3200 (sizeof(camera_wl_info_s) % sizeof(int) ? 1 : 0);
3202 msg = muse_core_msg_json_factory_new(api,
3203 MUSE_TYPE_INT, "type", type,
3204 MUSE_TYPE_ARRAY, "wl_info", length, (int *)&pc->wl_info,
3207 LOGE("msg creation failed: api %d", api);
3208 return CAMERA_ERROR_OUT_OF_MEMORY;
3211 if (pc->cb_info->is_server_connected) {
3212 __camera_update_api_waiting(pc->cb_info, api, 1);
3214 g_mutex_lock(&pc->cb_info->fd_lock);
3215 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
3216 g_mutex_unlock(&pc->cb_info->fd_lock);
3220 LOGE("message send failed");
3221 ret = CAMERA_ERROR_INVALID_OPERATION;
3223 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
3226 __camera_update_api_waiting(pc->cb_info, api, -1);
3228 muse_core_msg_json_factory_free(msg);
3230 LOGD("wayland parent id : %d, window %d,%d,%dx%d",
3231 pc->wl_info.parent_id, pc->wl_info.window_x, pc->wl_info.window_y,
3232 pc->wl_info.window_width, pc->wl_info.window_height);
3234 CAMERA_MSG_PARAM_SET(param, INT, type);
3236 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3239 if (ret != CAMERA_ERROR_NONE)
3240 LOGE("set display error 0x%x", ret);
3241 else if (type == CAMERA_DISPLAY_TYPE_EVAS)
3242 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3248 int camera_set_preview_resolution(camera_h camera, int width, int height)
3250 int ret = CAMERA_ERROR_NONE;
3251 camera_state_e current_state = CAMERA_STATE_NONE;
3252 camera_cli_s *pc = (camera_cli_s *)camera;
3253 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3254 camera_msg_param param;
3257 if (!pc || !pc->cb_info) {
3258 LOGE("NULL handle");
3259 return CAMERA_ERROR_INVALID_PARAMETER;
3262 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3263 ret = camera_get_state(camera, ¤t_state);
3264 if (ret != CAMERA_ERROR_NONE) {
3265 LOGE("failed to get current state 0x%x", ret);
3269 if (current_state == CAMERA_STATE_PREVIEW) {
3270 ret = _camera_stop_evas_rendering(camera, true);
3271 if (ret != CAMERA_ERROR_NONE)
3276 value = (width << 16) | height;
3277 CAMERA_MSG_PARAM_SET(param, INT, value);
3279 LOGD("%dx%d -> 0x%x", width, height, value);
3281 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3283 LOGD("ret : 0x%x", ret);
3285 if (current_state == CAMERA_STATE_PREVIEW) {
3286 LOGW("restart evas rendering");
3287 _camera_start_evas_rendering(camera);
3294 int camera_set_capture_resolution(camera_h camera, int width, int height)
3296 int ret = CAMERA_ERROR_NONE;
3297 camera_cli_s *pc = (camera_cli_s *)camera;
3298 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3299 camera_msg_param param;
3302 if (!pc || !pc->cb_info) {
3303 LOGE("NULL handle");
3304 return CAMERA_ERROR_INVALID_PARAMETER;
3309 value = (width << 16) | height;
3310 CAMERA_MSG_PARAM_SET(param, INT, value);
3312 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3314 LOGD("ret : 0x%x", ret);
3320 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3322 int ret = CAMERA_ERROR_NONE;
3323 int set_format = (int)format;
3324 camera_cli_s *pc = (camera_cli_s *)camera;
3325 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3326 camera_msg_param param;
3328 if (!pc || !pc->cb_info) {
3329 LOGE("NULL handle");
3330 return CAMERA_ERROR_INVALID_PARAMETER;
3333 LOGD("Enter - format %d", set_format);
3335 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3337 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3339 LOGD("ret : 0x%x", ret);
3345 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3347 int ret = CAMERA_ERROR_NONE;
3348 int set_format = (int)format;
3349 camera_msg_param param;
3350 camera_cli_s *pc = (camera_cli_s *)camera;
3351 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3353 if (!pc || !pc->cb_info) {
3354 LOGE("NULL handle");
3355 return CAMERA_ERROR_INVALID_PARAMETER;
3358 LOGD("Enter - capture_format %d", set_format);
3360 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3362 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3364 LOGD("ret : 0x%x", ret);
3370 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3372 int ret = CAMERA_ERROR_NONE;
3373 camera_cli_s *pc = (camera_cli_s *)camera;
3374 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3376 if (!pc || !pc->cb_info || !width || !height) {
3377 LOGE("NULL pointer %p %p %p", pc, width, height);
3378 return CAMERA_ERROR_INVALID_PARAMETER;
3383 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3385 if (ret == CAMERA_ERROR_NONE) {
3386 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3387 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3390 LOGD("ret : 0x%x", ret);
3396 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3398 int ret = CAMERA_ERROR_NONE;
3399 int set_rotation = (int)rotation;
3400 camera_cli_s *pc = (camera_cli_s *)camera;
3401 camera_msg_param param;
3403 if (!pc || !pc->cb_info) {
3404 LOGE("NULL handle");
3405 return CAMERA_ERROR_INVALID_PARAMETER;
3408 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3409 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3410 g_mutex_lock(&pc->cb_info->evas_mutex);
3412 ret = mm_evas_renderer_set_rotation(pc->cb_info->evas_info, rotation);
3414 g_mutex_unlock(&pc->cb_info->evas_mutex);
3416 if (ret != MM_ERROR_NONE) {
3417 LOGE("failed to set rotation for evas surface 0x%x", ret);
3418 return CAMERA_ERROR_INVALID_OPERATION;
3421 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3423 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3425 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3431 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3433 int ret = CAMERA_ERROR_NONE;
3434 camera_cli_s *pc = (camera_cli_s *)camera;
3436 if (!pc || !pc->cb_info || !rotation) {
3437 LOGE("NULL pointer %p %p", pc, rotation);
3438 return CAMERA_ERROR_INVALID_PARAMETER;
3441 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3443 if (ret == CAMERA_ERROR_NONE)
3444 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3450 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3452 int ret = CAMERA_ERROR_NONE;
3453 int set_flip = (int)flip;
3454 camera_cli_s *pc = (camera_cli_s *)camera;
3455 camera_msg_param param;
3457 if (!pc || !pc->cb_info) {
3458 LOGE("NULL handle");
3459 return CAMERA_ERROR_INVALID_PARAMETER;
3462 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3463 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3464 g_mutex_lock(&pc->cb_info->evas_mutex);
3466 ret = mm_evas_renderer_set_flip(pc->cb_info->evas_info, flip);
3468 g_mutex_unlock(&pc->cb_info->evas_mutex);
3470 if (ret != MM_ERROR_NONE) {
3471 LOGE("failed to set flip for evas surface 0x%x", ret);
3472 return CAMERA_ERROR_INVALID_OPERATION;
3475 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3477 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3479 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3485 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3487 int ret = CAMERA_ERROR_NONE;
3488 camera_cli_s *pc = (camera_cli_s *)camera;
3490 if (!pc || !pc->cb_info || !flip) {
3491 LOGE("NULL pointer %p %p", pc, flip);
3492 return CAMERA_ERROR_INVALID_PARAMETER;
3495 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3497 if (ret == CAMERA_ERROR_NONE)
3498 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3504 int camera_set_display_visible(camera_h camera, bool visible)
3506 int ret = CAMERA_ERROR_NONE;
3507 int set_visible = (int)visible;
3508 camera_cli_s *pc = (camera_cli_s *)camera;
3509 camera_msg_param param;
3511 if (!pc || !pc->cb_info) {
3512 LOGE("NULL handle");
3513 return CAMERA_ERROR_INVALID_PARAMETER;
3516 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3517 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3518 g_mutex_lock(&pc->cb_info->evas_mutex);
3520 ret = mm_evas_renderer_set_visible(pc->cb_info->evas_info, visible);
3522 g_mutex_unlock(&pc->cb_info->evas_mutex);
3524 if (ret != MM_ERROR_NONE) {
3525 LOGE("failed to set visible for evas surface 0x%x", ret);
3526 return CAMERA_ERROR_INVALID_OPERATION;
3529 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3531 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3533 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3539 int camera_is_display_visible(camera_h camera, bool *visible)
3541 int ret = CAMERA_ERROR_NONE;
3542 camera_cli_s *pc = (camera_cli_s *)camera;
3544 if (!pc || !pc->cb_info || !visible) {
3545 LOGE("NULL pointer %p %p", pc, visible);
3546 return CAMERA_ERROR_INVALID_PARAMETER;
3549 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3551 if (ret == CAMERA_ERROR_NONE)
3552 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3558 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3560 int ret = CAMERA_ERROR_NONE;
3561 int set_mode = (int)mode;
3562 camera_cli_s *pc = (camera_cli_s *)camera;
3563 camera_msg_param param;
3565 if (!pc || !pc->cb_info) {
3566 LOGE("NULL handle");
3567 return CAMERA_ERROR_INVALID_PARAMETER;
3570 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3571 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3572 g_mutex_lock(&pc->cb_info->evas_mutex);
3574 ret = mm_evas_renderer_set_geometry(pc->cb_info->evas_info, mode);
3576 g_mutex_unlock(&pc->cb_info->evas_mutex);
3578 if (ret != MM_ERROR_NONE) {
3579 LOGE("failed to set geometry for evas surface 0x%x", ret);
3580 return CAMERA_ERROR_INVALID_OPERATION;
3583 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3585 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3587 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3593 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3595 int ret = CAMERA_ERROR_NONE;
3596 camera_cli_s *pc = (camera_cli_s *)camera;
3598 if (!pc || !pc->cb_info || !mode) {
3599 LOGE("NULL pointer %p %p", pc, mode);
3600 return CAMERA_ERROR_INVALID_PARAMETER;
3603 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3605 if (ret == CAMERA_ERROR_NONE)
3606 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3612 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3614 int ret = CAMERA_ERROR_NONE;
3615 int set_hint = (int)hint;
3616 camera_cli_s *pc = (camera_cli_s *)camera;
3617 camera_msg_param param;
3619 if (!pc || !pc->cb_info) {
3620 LOGE("NULL handle");
3621 return CAMERA_ERROR_INVALID_PARAMETER;
3624 LOGD("Enter - hint %d", set_hint);
3626 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3628 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3634 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3636 int ret = CAMERA_ERROR_NONE;
3637 camera_cli_s *pc = (camera_cli_s *)camera;
3638 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3640 if (!pc || !pc->cb_info || !hint) {
3641 LOGE("NULL pointer %p %p", pc, hint);
3642 return CAMERA_ERROR_INVALID_PARAMETER;
3645 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3647 if (ret == CAMERA_ERROR_NONE) {
3648 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3649 LOGD("display reuse hint %d", *hint);
3656 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3658 int ret = CAMERA_ERROR_NONE;
3659 camera_cli_s *pc = (camera_cli_s *)camera;
3660 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3662 if (!pc || !pc->cb_info || !width || !height) {
3663 LOGE("NULL pointer %p %p %p", pc, width, height);
3664 return CAMERA_ERROR_INVALID_PARAMETER;
3669 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3671 if (ret == CAMERA_ERROR_NONE) {
3672 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3673 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3676 LOGD("ret : 0x%x", ret);
3682 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3684 int ret = CAMERA_ERROR_NONE;
3685 camera_cli_s *pc = (camera_cli_s *)camera;
3686 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3688 if (!pc || !pc->cb_info || !format) {
3689 LOGE("NULL pointer %p %p", pc, format);
3690 return CAMERA_ERROR_INVALID_PARAMETER;
3695 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3697 if (ret == CAMERA_ERROR_NONE)
3698 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3700 LOGD("ret : 0x%x", ret);
3706 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3708 int ret = CAMERA_ERROR_NONE;
3709 camera_cli_s *pc = (camera_cli_s *)camera;
3710 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3712 if (!pc || !pc->cb_info || !format) {
3713 LOGE("NULL pointer %p %p", pc, format);
3714 return CAMERA_ERROR_INVALID_PARAMETER;
3719 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3721 if (ret == CAMERA_ERROR_NONE)
3722 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3724 LOGD("ret : 0x%x", ret);
3730 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3732 int ret = CAMERA_ERROR_NONE;
3733 camera_cli_s *pc = (camera_cli_s *)camera;
3734 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3736 if (!pc || !pc->cb_info || !facing_direction) {
3737 LOGE("NULL pointer %p %p", pc, facing_direction);
3738 return CAMERA_ERROR_INVALID_PARAMETER;
3743 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3745 if (ret == CAMERA_ERROR_NONE)
3746 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3748 LOGD("ret : 0x%x", ret);
3754 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3756 int ret = CAMERA_ERROR_NONE;
3757 camera_cli_s *pc = (camera_cli_s *)camera;
3758 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3760 if (!pc || !pc->cb_info || !callback) {
3761 LOGE("NULL pointer %p %p", pc, callback);
3762 return CAMERA_ERROR_INVALID_PARAMETER;
3767 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3769 if (ret == CAMERA_ERROR_NONE) {
3770 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3771 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3772 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3775 LOGD("ret : 0x%x", ret);
3781 int camera_unset_preview_cb(camera_h camera)
3783 int ret = CAMERA_ERROR_NONE;
3784 camera_cli_s *pc = (camera_cli_s *)camera;
3785 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3787 if (!pc || !pc->cb_info) {
3788 LOGE("NULL handle");
3789 return CAMERA_ERROR_INVALID_PARAMETER;
3794 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3795 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3797 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3799 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3801 LOGD("ret : 0x%x", ret);
3807 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3809 int ret = CAMERA_ERROR_NONE;
3810 camera_cli_s *pc = (camera_cli_s *)camera;
3811 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3813 if (!pc || !pc->cb_info) {
3814 LOGE("NULL handle");
3815 return CAMERA_ERROR_INVALID_PARAMETER;
3818 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3819 LOGE("NOT SUPPORTED");
3820 return CAMERA_ERROR_NOT_SUPPORTED;
3823 if (callback == NULL) {
3824 LOGE("NULL callback");
3825 return CAMERA_ERROR_INVALID_PARAMETER;
3830 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3832 if (ret == CAMERA_ERROR_NONE) {
3833 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3834 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3837 LOGD("ret : 0x%x", ret);
3843 int camera_unset_media_packet_preview_cb(camera_h camera)
3845 int ret = CAMERA_ERROR_NONE;
3846 camera_cli_s *pc = (camera_cli_s *)camera;
3847 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3849 if (!pc || !pc->cb_info) {
3850 LOGE("NULL handle");
3851 return CAMERA_ERROR_INVALID_PARAMETER;
3856 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3857 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3859 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3861 LOGD("ret : 0x%x", ret);
3867 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3869 int ret = CAMERA_ERROR_NONE;
3870 camera_cli_s *pc = (camera_cli_s *)camera;
3871 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3873 if (!pc || !pc->cb_info || !callback) {
3874 LOGE("NULL pointer %p %p", pc, callback);
3875 return CAMERA_ERROR_INVALID_PARAMETER;
3880 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3882 if (ret == CAMERA_ERROR_NONE) {
3883 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3884 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3887 LOGD("ret : 0x%x", ret);
3893 int camera_unset_state_changed_cb(camera_h camera)
3895 int ret = CAMERA_ERROR_NONE;
3896 camera_cli_s *pc = (camera_cli_s *)camera;
3897 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3899 if (!pc || !pc->cb_info) {
3900 LOGE("NULL handle");
3901 return CAMERA_ERROR_INVALID_PARAMETER;
3906 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3907 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3909 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3911 LOGD("ret : 0x%x", ret);
3917 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3919 int ret = CAMERA_ERROR_NONE;
3920 camera_cli_s *pc = (camera_cli_s *)camera;
3921 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3923 if (!pc || !pc->cb_info || !callback) {
3924 LOGE("NULL pointer %p %p", pc, callback);
3925 return CAMERA_ERROR_INVALID_PARAMETER;
3930 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3932 if (ret == CAMERA_ERROR_NONE) {
3933 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3934 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3937 LOGD("ret : 0x%x", ret);
3943 int camera_unset_interrupted_cb(camera_h camera)
3945 int ret = CAMERA_ERROR_NONE;
3946 camera_cli_s *pc = (camera_cli_s *)camera;
3947 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3949 if (!pc || !pc->cb_info) {
3950 LOGE("NULL handle");
3951 return CAMERA_ERROR_INVALID_PARAMETER;
3956 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3957 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3959 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3961 LOGD("ret : 0x%x", ret);
3967 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
3969 int ret = CAMERA_ERROR_NONE;
3970 camera_cli_s *pc = (camera_cli_s *)camera;
3971 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3973 if (!pc || !pc->cb_info || !callback) {
3974 LOGE("NULL pointer %p %p", pc, callback);
3975 return CAMERA_ERROR_INVALID_PARAMETER;
3980 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3982 if (ret == CAMERA_ERROR_NONE) {
3983 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3984 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3987 LOGD("ret : 0x%x", ret);
3993 int camera_unset_focus_changed_cb(camera_h camera)
3995 int ret = CAMERA_ERROR_NONE;
3996 camera_cli_s *pc = (camera_cli_s *)camera;
3997 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
3999 if (!pc || !pc->cb_info) {
4000 LOGE("NULL handle");
4001 return CAMERA_ERROR_INVALID_PARAMETER;
4006 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4007 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4009 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4011 LOGD("ret : 0x%x", ret);
4017 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
4019 int ret = CAMERA_ERROR_NONE;
4020 camera_cli_s *pc = (camera_cli_s *)camera;
4021 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
4023 if (!pc || !pc->cb_info || !callback) {
4024 LOGE("NULL pointer %p %p", pc, callback);
4025 return CAMERA_ERROR_INVALID_PARAMETER;
4030 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4032 if (ret == CAMERA_ERROR_NONE) {
4033 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4034 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4037 LOGD("ret : 0x%x", ret);
4043 int camera_unset_error_cb(camera_h camera)
4045 int ret = CAMERA_ERROR_NONE;
4046 camera_cli_s *pc = (camera_cli_s *)camera;
4047 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4049 if (!pc || !pc->cb_info) {
4050 LOGE("NULL handle");
4051 return CAMERA_ERROR_INVALID_PARAMETER;
4056 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4057 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4059 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4061 LOGD("ret : 0x%x", ret);
4067 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4069 int ret = CAMERA_ERROR_NONE;
4070 camera_cli_s *pc = (camera_cli_s *)camera;
4071 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4073 if (!pc || !pc->cb_info || !foreach_cb) {
4074 LOGE("NULL pointer %p %p", pc, foreach_cb);
4075 return CAMERA_ERROR_INVALID_PARAMETER;
4080 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4081 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4083 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4085 LOGD("ret : 0x%x", ret);
4091 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4093 int ret = CAMERA_ERROR_NONE;
4094 camera_cli_s *pc = (camera_cli_s *)camera;
4095 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4097 if (!pc || !pc->cb_info || !foreach_cb) {
4098 LOGE("NULL pointer %p %p", pc, foreach_cb);
4099 return CAMERA_ERROR_INVALID_PARAMETER;
4104 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4105 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4107 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4109 LOGD("ret : 0x%x", ret);
4115 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, 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_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4121 if (!pc || !pc->cb_info || !foreach_cb) {
4122 LOGE("NULL pointer %p %p", pc, foreach_cb);
4123 return CAMERA_ERROR_INVALID_PARAMETER;
4128 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4129 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4131 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4133 LOGD("ret : 0x%x", ret);
4139 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4141 int ret = CAMERA_ERROR_NONE;
4142 camera_cli_s *pc = (camera_cli_s *)camera;
4143 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4145 if (!pc || !pc->cb_info || !foreach_cb) {
4146 LOGE("NULL pointer %p %p", pc, foreach_cb);
4147 return CAMERA_ERROR_INVALID_PARAMETER;
4152 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4153 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4155 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4157 LOGD("ret : 0x%x", ret);
4163 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4165 int ret = CAMERA_ERROR_NONE;
4166 camera_cli_s *pc = (camera_cli_s *)camera;
4167 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4169 if (!pc || !pc->cb_info || !width || !height) {
4170 LOGE("NULL pointer %p %p %p", pc, width, height);
4171 return CAMERA_ERROR_INVALID_PARAMETER;
4175 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4177 if (ret == CAMERA_ERROR_NONE) {
4178 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4179 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4182 LOGD("ret : 0x%x", ret);
4188 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4190 int ret = CAMERA_ERROR_NONE;
4191 camera_cli_s *pc = (camera_cli_s *)camera;
4192 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4194 if (!pc || !pc->cb_info || !angle) {
4195 LOGE("NULL pointer %p %p", pc, angle);
4196 return CAMERA_ERROR_INVALID_PARAMETER;
4201 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4203 if (ret == CAMERA_ERROR_NONE)
4204 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4206 LOGD("ret : 0x%x", ret);
4212 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4214 int ret = CAMERA_ERROR_NONE;
4215 camera_cli_s *pc = (camera_cli_s *)camera;
4216 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4217 camera_msg_param param;
4218 int set_mode = (int)mode;
4220 if (!pc || !pc->cb_info) {
4221 LOGE("NULL handle");
4222 return CAMERA_ERROR_INVALID_PARAMETER;
4227 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4229 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4231 LOGD("ret : 0x%x", ret);
4237 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4239 int ret = CAMERA_ERROR_NONE;
4240 camera_cli_s *pc = (camera_cli_s *)camera;
4241 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4243 if (!pc || !pc->cb_info || !mode) {
4244 LOGE("NULL pointer %p %p", pc, mode);
4245 return CAMERA_ERROR_INVALID_PARAMETER;
4250 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4252 if (ret == CAMERA_ERROR_NONE)
4253 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4255 LOGD("ret : 0x%x", ret);
4261 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4263 int ret = CAMERA_ERROR_NONE;
4264 camera_cli_s *pc = (camera_cli_s *)camera;
4265 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4267 if (!pc || !pc->cb_info || !foreach_cb) {
4268 LOGE("NULL pointer %p %p", pc, foreach_cb);
4269 return CAMERA_ERROR_INVALID_PARAMETER;
4274 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4275 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4277 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4279 LOGD("Finish, return :%x", ret);
4285 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4287 int ret = CAMERA_ERROR_NONE;
4288 camera_cli_s *pc = (camera_cli_s *)camera;
4289 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4290 camera_msg_param param;
4291 int set_fps = (int)fps;
4293 if (!pc || !pc->cb_info) {
4294 LOGE("NULL handle");
4295 return CAMERA_ERROR_INVALID_PARAMETER;
4300 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4302 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4304 LOGD("ret : 0x%x", ret);
4310 int camera_attr_set_image_quality(camera_h camera, int quality)
4312 int ret = CAMERA_ERROR_NONE;
4313 camera_cli_s *pc = (camera_cli_s *)camera;
4314 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4315 camera_msg_param param;
4317 if (!pc || !pc->cb_info) {
4318 LOGE("NULL handle");
4319 return CAMERA_ERROR_INVALID_PARAMETER;
4324 CAMERA_MSG_PARAM_SET(param, INT, quality);
4326 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4328 LOGD("ret : 0x%x", ret);
4334 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4336 int ret = CAMERA_ERROR_NONE;
4337 camera_cli_s *pc = (camera_cli_s *)camera;
4338 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4340 if (!pc || !pc->cb_info || !fps) {
4341 LOGE("NULL pointer %p %p", pc, fps);
4342 return CAMERA_ERROR_INVALID_PARAMETER;
4347 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4349 if (ret == CAMERA_ERROR_NONE)
4350 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4352 LOGD("ret : 0x%x", ret);
4358 int camera_attr_get_image_quality(camera_h camera, int *quality)
4360 int ret = CAMERA_ERROR_NONE;
4361 camera_cli_s *pc = (camera_cli_s *)camera;
4362 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4364 if (!pc || !pc->cb_info || !quality) {
4365 LOGE("NULL pointer %p %p", pc, quality);
4366 return CAMERA_ERROR_INVALID_PARAMETER;
4371 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4373 if (ret == CAMERA_ERROR_NONE)
4374 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4376 LOGD("ret : 0x%x", ret);
4382 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4384 int ret = CAMERA_ERROR_NONE;
4385 camera_cli_s *pc = (camera_cli_s *)camera;
4386 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4388 if (!pc || !pc->cb_info || !bitrate) {
4389 LOGE("NULL pointer %p %p", pc, bitrate);
4390 return CAMERA_ERROR_INVALID_PARAMETER;
4395 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4397 if (ret == CAMERA_ERROR_NONE)
4398 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4400 LOGD("ret : 0x%x", ret);
4406 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4408 int ret = CAMERA_ERROR_NONE;
4409 camera_cli_s *pc = (camera_cli_s *)camera;
4410 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4411 camera_msg_param param;
4412 int set_bitrate = bitrate;
4414 if (!pc || !pc->cb_info) {
4415 LOGE("NULL handle");
4416 return CAMERA_ERROR_INVALID_PARAMETER;
4421 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4423 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4425 LOGD("ret : 0x%x", ret);
4431 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4433 int ret = CAMERA_ERROR_NONE;
4434 camera_cli_s *pc = (camera_cli_s *)camera;
4435 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4437 if (!pc || !pc->cb_info || !interval) {
4438 LOGE("NULL pointer %p %p", pc, interval);
4439 return CAMERA_ERROR_INVALID_PARAMETER;
4444 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4446 if (ret == CAMERA_ERROR_NONE)
4447 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4449 LOGD("ret : 0x%x", ret);
4455 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4457 int ret = CAMERA_ERROR_NONE;
4458 camera_cli_s *pc = (camera_cli_s *)camera;
4459 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4460 camera_msg_param param;
4461 int set_gop_interval = interval;
4463 if (!pc || !pc->cb_info) {
4464 LOGE("NULL handle");
4465 return CAMERA_ERROR_INVALID_PARAMETER;
4470 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4472 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4474 LOGD("ret : 0x%x", ret);
4480 int camera_attr_set_zoom(camera_h camera, int zoom)
4482 int ret = CAMERA_ERROR_NONE;
4483 camera_cli_s *pc = (camera_cli_s *)camera;
4484 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4485 camera_msg_param param;
4487 if (!pc || !pc->cb_info) {
4488 LOGE("NULL handle");
4489 return CAMERA_ERROR_INVALID_PARAMETER;
4492 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4494 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4496 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4498 LOGD("ret : 0x%x", ret);
4504 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4506 int ret = CAMERA_ERROR_NONE;
4507 camera_cli_s *pc = (camera_cli_s *)camera;
4508 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4509 camera_msg_param param;
4510 int set_mode = (int)mode;
4512 if (!pc || !pc->cb_info) {
4513 LOGE("NULL handle");
4514 return CAMERA_ERROR_INVALID_PARAMETER;
4517 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4519 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4521 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4527 int camera_attr_set_af_area(camera_h camera, int x, int y)
4529 int ret = CAMERA_ERROR_NONE;
4530 camera_cli_s *pc = (camera_cli_s *)camera;
4531 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4532 camera_msg_param param;
4535 if (!pc || !pc->cb_info) {
4536 LOGE("NULL handle");
4537 return CAMERA_ERROR_INVALID_PARAMETER;
4540 LOGD("Enter - %d,%d", x, y);
4542 value = (x << 16) | y;
4543 CAMERA_MSG_PARAM_SET(param, INT, value);
4545 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4547 LOGD("ret : 0x%x", ret);
4553 int camera_attr_clear_af_area(camera_h camera)
4555 int ret = CAMERA_ERROR_NONE;
4556 camera_cli_s *pc = (camera_cli_s *)camera;
4557 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4559 if (!pc || !pc->cb_info) {
4560 LOGE("NULL handle");
4561 return CAMERA_ERROR_INVALID_PARAMETER;
4566 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4568 LOGD("ret : 0x%x", ret);
4574 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4576 int ret = CAMERA_ERROR_NONE;
4577 camera_cli_s *pc = (camera_cli_s *)camera;
4578 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4579 camera_msg_param param;
4580 int set_mode = (int)mode;
4582 if (!pc || !pc->cb_info) {
4583 LOGE("NULL handle");
4584 return CAMERA_ERROR_INVALID_PARAMETER;
4589 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4591 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4593 LOGD("ret : 0x%x", ret);
4599 int camera_attr_set_exposure(camera_h camera, int value)
4601 int ret = CAMERA_ERROR_NONE;
4602 camera_cli_s *pc = (camera_cli_s *)camera;
4603 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4604 camera_msg_param param;
4606 if (!pc || !pc->cb_info) {
4607 LOGE("NULL handle");
4608 return CAMERA_ERROR_INVALID_PARAMETER;
4613 CAMERA_MSG_PARAM_SET(param, INT, value);
4615 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4617 LOGD("ret : 0x%x", ret);
4623 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4625 int ret = CAMERA_ERROR_NONE;
4626 camera_cli_s *pc = (camera_cli_s *)camera;
4627 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4628 camera_msg_param param;
4629 int set_iso = (int)iso;
4631 if (!pc || !pc->cb_info) {
4632 LOGE("NULL handle");
4633 return CAMERA_ERROR_INVALID_PARAMETER;
4638 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4640 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4642 LOGD("ret : 0x%x", ret);
4648 int camera_attr_set_brightness(camera_h camera, int level)
4650 int ret = CAMERA_ERROR_NONE;
4651 camera_cli_s *pc = (camera_cli_s *)camera;
4652 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4653 camera_msg_param param;
4655 if (!pc || !pc->cb_info) {
4656 LOGE("NULL handle");
4657 return CAMERA_ERROR_INVALID_PARAMETER;
4662 CAMERA_MSG_PARAM_SET(param, INT, level);
4664 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4666 LOGD("ret : 0x%x", ret);
4672 int camera_attr_set_contrast(camera_h camera, int level)
4674 int ret = CAMERA_ERROR_NONE;
4675 camera_cli_s *pc = (camera_cli_s *)camera;
4676 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4677 camera_msg_param param;
4679 if (!pc || !pc->cb_info) {
4680 LOGE("NULL handle");
4681 return CAMERA_ERROR_INVALID_PARAMETER;
4686 CAMERA_MSG_PARAM_SET(param, INT, level);
4688 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4690 LOGD("ret : 0x%x", ret);
4696 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4698 int ret = CAMERA_ERROR_NONE;
4699 camera_cli_s *pc = (camera_cli_s *)camera;
4700 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4701 camera_msg_param param;
4702 int set_whitebalance = (int)wb;
4704 if (!pc || !pc->cb_info) {
4705 LOGE("NULL handle");
4706 return CAMERA_ERROR_INVALID_PARAMETER;
4711 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4713 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4715 LOGD("ret : 0x%x", ret);
4721 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4723 int ret = CAMERA_ERROR_NONE;
4724 camera_cli_s *pc = (camera_cli_s *)camera;
4725 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4726 camera_msg_param param;
4727 int set_effect = (int)effect;
4729 if (!pc || !pc->cb_info) {
4730 LOGE("NULL handle");
4731 return CAMERA_ERROR_INVALID_PARAMETER;
4736 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4738 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4740 LOGD("ret : 0x%x", ret);
4746 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4748 int ret = CAMERA_ERROR_NONE;
4749 camera_cli_s *pc = (camera_cli_s *)camera;
4750 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4751 camera_msg_param param;
4752 int set_mode = (int)mode;
4754 if (!pc || !pc->cb_info) {
4755 LOGE("NULL handle");
4756 return CAMERA_ERROR_INVALID_PARAMETER;
4761 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4763 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4765 LOGD("ret : 0x%x", ret);
4771 int camera_attr_enable_tag(camera_h camera, bool enable)
4773 int ret = CAMERA_ERROR_NONE;
4774 camera_cli_s *pc = (camera_cli_s *)camera;
4775 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4776 camera_msg_param param;
4777 int set_enable = (int)enable;
4779 if (!pc || !pc->cb_info) {
4780 LOGE("NULL handle");
4781 return CAMERA_ERROR_INVALID_PARAMETER;
4786 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
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_tag_image_description(camera_h camera, const char *description)
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_TAG_IMAGE_DESCRIPTION;
4801 camera_msg_param param;
4803 if (!pc || !pc->cb_info || !description) {
4804 LOGE("NULL pointer %p %p", pc, description);
4805 return CAMERA_ERROR_INVALID_PARAMETER;
4810 CAMERA_MSG_PARAM_SET(param, STRING, description);
4812 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4814 LOGD("ret : 0x%x", ret);
4820 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4822 int ret = CAMERA_ERROR_NONE;
4823 camera_cli_s *pc = (camera_cli_s *)camera;
4824 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4825 camera_msg_param param;
4826 int set_orientation = (int)orientation;
4828 if (!pc || !pc->cb_info) {
4829 LOGE("NULL handle");
4830 return CAMERA_ERROR_INVALID_PARAMETER;
4835 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4837 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4839 LOGD("ret : 0x%x", ret);
4845 int camera_attr_set_tag_software(camera_h camera, const char *software)
4847 int ret = CAMERA_ERROR_NONE;
4848 camera_cli_s *pc = (camera_cli_s *)camera;
4849 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4850 camera_msg_param param;
4852 if (!pc || !pc->cb_info || !software) {
4853 LOGE("NULL pointer %p %p", pc, software);
4854 return CAMERA_ERROR_INVALID_PARAMETER;
4857 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4859 CAMERA_MSG_PARAM_SET(param, STRING, software);
4861 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4863 LOGD("ret : 0x%x", ret);
4869 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4871 int ret = CAMERA_ERROR_NONE;
4872 camera_cli_s *pc = (camera_cli_s *)camera;
4873 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4874 double set_geotag[3] = {latitude, longitude, altitude};
4879 if (!pc || !pc->cb_info) {
4880 LOGE("NULL handle");
4881 return CAMERA_ERROR_INVALID_PARAMETER;
4886 length = sizeof(set_geotag) / sizeof(int) + \
4887 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4889 msg = muse_core_msg_json_factory_new(api,
4890 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4893 LOGE("msg creation failed: api %d", api);
4894 return CAMERA_ERROR_OUT_OF_MEMORY;
4897 if (pc->cb_info->is_server_connected) {
4898 __camera_update_api_waiting(pc->cb_info, api, 1);
4900 g_mutex_lock(&pc->cb_info->fd_lock);
4901 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
4902 g_mutex_unlock(&pc->cb_info->fd_lock);
4906 LOGE("message send failed");
4907 ret = CAMERA_ERROR_INVALID_OPERATION;
4909 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
4912 __camera_update_api_waiting(pc->cb_info, api, -1);
4914 muse_core_msg_json_factory_free(msg);
4916 LOGD("ret : 0x%x", ret);
4922 int camera_attr_remove_geotag(camera_h camera)
4924 int ret = CAMERA_ERROR_NONE;
4925 camera_cli_s *pc = (camera_cli_s *)camera;
4926 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4928 if (!pc || !pc->cb_info) {
4929 LOGE("NULL handle");
4930 return CAMERA_ERROR_INVALID_PARAMETER;
4935 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4937 LOGD("ret : 0x%x", ret);
4943 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4945 int ret = CAMERA_ERROR_NONE;
4946 camera_cli_s *pc = (camera_cli_s *)camera;
4947 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
4948 camera_msg_param param;
4949 int set_mode = (int)mode;
4951 if (!pc || !pc->cb_info) {
4952 LOGE("NULL handle");
4953 return CAMERA_ERROR_INVALID_PARAMETER;
4958 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4960 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4962 LOGD("ret : 0x%x", ret);
4968 int camera_attr_get_zoom(camera_h camera, int *zoom)
4970 int ret = CAMERA_ERROR_NONE;
4971 camera_cli_s *pc = (camera_cli_s *)camera;
4972 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4974 if (!pc || !pc->cb_info || !zoom) {
4975 LOGE("NULL pointer %p %p", pc, zoom);
4976 return CAMERA_ERROR_INVALID_PARAMETER;
4981 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4983 if (ret == CAMERA_ERROR_NONE)
4984 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
4986 LOGD("ret : 0x%x", ret);
4992 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
4994 int ret = CAMERA_ERROR_NONE;
4995 camera_cli_s *pc = (camera_cli_s *)camera;
4996 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
4998 if (!pc || !pc->cb_info || !min || !max) {
4999 LOGE("NULL pointer %p %p %p", pc, min, max);
5000 return CAMERA_ERROR_INVALID_PARAMETER;
5005 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5007 if (ret == CAMERA_ERROR_NONE) {
5008 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
5009 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
5012 LOGD("ret : 0x%x", ret);
5018 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
5020 int ret = CAMERA_ERROR_NONE;
5021 camera_cli_s *pc = (camera_cli_s *)camera;
5022 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
5024 if (!pc || !pc->cb_info || !mode) {
5025 LOGE("NULL pointer %p %p", pc, mode);
5026 return CAMERA_ERROR_INVALID_PARAMETER;
5031 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5033 if (ret == CAMERA_ERROR_NONE)
5034 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5036 LOGD("ret : 0x%x", ret);
5042 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5044 int ret = CAMERA_ERROR_NONE;
5045 camera_cli_s *pc = (camera_cli_s *)camera;
5046 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5048 if (!pc || !pc->cb_info || !mode) {
5049 LOGE("NULL pointer %p %p", pc, mode);
5050 return CAMERA_ERROR_INVALID_PARAMETER;
5055 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5057 if (ret == CAMERA_ERROR_NONE)
5058 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5060 LOGD("ret : 0x%x", ret);
5066 int camera_attr_get_exposure(camera_h camera, int *value)
5068 int ret = CAMERA_ERROR_NONE;
5069 camera_cli_s *pc = (camera_cli_s *)camera;
5070 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5072 if (!pc || !pc->cb_info || !value) {
5073 LOGE("NULL pointer %p %p", pc, value);
5074 return CAMERA_ERROR_INVALID_PARAMETER;
5079 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5081 if (ret == CAMERA_ERROR_NONE)
5082 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5084 LOGD("ret : 0x%x", ret);
5090 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5092 int ret = CAMERA_ERROR_NONE;
5093 camera_cli_s *pc = (camera_cli_s *)camera;
5094 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5096 if (!pc || !pc->cb_info || !min || !max) {
5097 LOGE("NULL pointer %p %p %p", pc, min, max);
5098 return CAMERA_ERROR_INVALID_PARAMETER;
5103 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5105 if (ret == CAMERA_ERROR_NONE) {
5106 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5107 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5110 LOGD("ret : 0x%x", ret);
5116 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5118 int ret = CAMERA_ERROR_NONE;
5119 camera_cli_s *pc = (camera_cli_s *)camera;
5120 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5122 if (!pc || !pc->cb_info || !iso) {
5123 LOGE("NULL pointer %p %p", pc, iso);
5124 return CAMERA_ERROR_INVALID_PARAMETER;
5129 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5131 if (ret == CAMERA_ERROR_NONE)
5132 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5134 LOGD("ret : 0x%x", ret);
5140 int camera_attr_get_brightness(camera_h camera, int *level)
5142 int ret = CAMERA_ERROR_NONE;
5143 camera_cli_s *pc = (camera_cli_s *)camera;
5144 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5146 if (!pc || !pc->cb_info || !level) {
5147 LOGE("NULL pointer %p %p", pc, level);
5148 return CAMERA_ERROR_INVALID_PARAMETER;
5153 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5155 if (ret == CAMERA_ERROR_NONE)
5156 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5158 LOGD("ret : 0x%x", ret);
5164 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5166 int ret = CAMERA_ERROR_NONE;
5167 camera_cli_s *pc = (camera_cli_s *)camera;
5168 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5170 if (!pc || !pc->cb_info || !min || !max) {
5171 LOGE("NULL pointer %p %p %p", pc, min, max);
5172 return CAMERA_ERROR_INVALID_PARAMETER;
5177 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5179 if (ret == CAMERA_ERROR_NONE) {
5180 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5181 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5184 LOGD("ret : 0x%x", ret);
5190 int camera_attr_get_contrast(camera_h camera, int *level)
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_CONTRAST;
5196 if (!pc || !pc->cb_info || !level) {
5197 LOGE("NULL pointer %p %p", pc, level);
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 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5208 LOGD("ret : 0x%x", ret);
5214 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5216 int ret = CAMERA_ERROR_NONE;
5217 camera_cli_s *pc = (camera_cli_s *)camera;
5218 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5220 if (!pc || !pc->cb_info || !min || !max) {
5221 LOGE("NULL pointer %p %p %p", pc, min, max);
5222 return CAMERA_ERROR_INVALID_PARAMETER;
5227 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5229 if (ret == CAMERA_ERROR_NONE) {
5230 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5231 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5232 LOGD("min %d, max %d", *min, *max);
5235 LOGD("ret : 0x%x", ret);
5241 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5243 int ret = CAMERA_ERROR_NONE;
5244 camera_cli_s *pc = (camera_cli_s *)camera;
5245 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5247 if (!pc || !pc->cb_info || !wb) {
5248 LOGE("NULL pointer %p %p", pc, wb);
5249 return CAMERA_ERROR_INVALID_PARAMETER;
5254 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5256 if (ret == CAMERA_ERROR_NONE)
5257 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5259 LOGD("ret : 0x%x", ret);
5265 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5267 int ret = CAMERA_ERROR_NONE;
5268 camera_cli_s *pc = (camera_cli_s *)camera;
5269 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5271 if (!pc || !pc->cb_info || !effect) {
5272 LOGE("NULL pointer %p %p", pc, effect);
5273 return CAMERA_ERROR_INVALID_PARAMETER;
5278 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5280 if (ret == CAMERA_ERROR_NONE)
5281 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5283 LOGD("ret : 0x%x", ret);
5289 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5291 int ret = CAMERA_ERROR_NONE;
5292 camera_cli_s *pc = (camera_cli_s *)camera;
5293 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5295 if (!pc || !pc->cb_info || !mode) {
5296 LOGE("NULL pointer %p %p", pc, mode);
5297 return CAMERA_ERROR_INVALID_PARAMETER;
5302 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5304 if (ret == CAMERA_ERROR_NONE)
5305 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5307 LOGD("ret : 0x%x", ret);
5313 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5315 int ret = CAMERA_ERROR_NONE;
5316 camera_cli_s *pc = (camera_cli_s *)camera;
5317 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5319 if (!pc || !pc->cb_info || !enable) {
5320 LOGE("NULL pointer %p %p", pc, enable);
5321 return CAMERA_ERROR_INVALID_PARAMETER;
5326 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5328 if (ret == CAMERA_ERROR_NONE)
5329 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5331 LOGD("ret : 0x%x", ret);
5337 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5339 int ret = CAMERA_ERROR_NONE;
5340 camera_cli_s *pc = (camera_cli_s *)camera;
5341 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5343 if (!pc || !pc->cb_info || !description) {
5344 LOGE("NULL pointer %p %p", pc, description);
5345 return CAMERA_ERROR_INVALID_PARAMETER;
5350 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5352 if (ret == CAMERA_ERROR_NONE)
5353 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5355 LOGD("ret : 0x%x", ret);
5361 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5363 int ret = CAMERA_ERROR_NONE;
5364 camera_cli_s *pc = (camera_cli_s *)camera;
5365 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5367 if (!pc || !pc->cb_info || !orientation) {
5368 LOGE("NULL pointer %p %p", pc, orientation);
5369 return CAMERA_ERROR_INVALID_PARAMETER;
5374 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5376 if (ret == CAMERA_ERROR_NONE)
5377 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5379 LOGD("ret : 0x%x", ret);
5385 int camera_attr_get_tag_software(camera_h camera, char **software)
5387 int ret = CAMERA_ERROR_NONE;
5388 camera_cli_s *pc = (camera_cli_s *)camera;
5389 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5391 if (!pc || !pc->cb_info || !software) {
5392 LOGE("NULL pointer %p %p", pc, software);
5393 return CAMERA_ERROR_INVALID_PARAMETER;
5398 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5400 if (ret == CAMERA_ERROR_NONE)
5401 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5403 LOGD("ret : 0x%x", ret);
5409 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5411 int ret = CAMERA_ERROR_NONE;
5412 camera_cli_s *pc = (camera_cli_s *)camera;
5413 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5415 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5416 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5417 return CAMERA_ERROR_INVALID_PARAMETER;
5422 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5424 if (ret == CAMERA_ERROR_NONE) {
5425 *latitude = pc->cb_info->get_geotag[0];
5426 *longitude = pc->cb_info->get_geotag[1];
5427 *altitude = pc->cb_info->get_geotag[2];
5430 LOGD("ret : 0x%x", ret);
5436 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5438 int ret = CAMERA_ERROR_NONE;
5439 camera_cli_s *pc = (camera_cli_s *)camera;
5440 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5442 if (!pc || !pc->cb_info || !mode) {
5443 LOGE("NULL pointer %p %p", pc, mode);
5444 return CAMERA_ERROR_INVALID_PARAMETER;
5449 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5451 if (ret == CAMERA_ERROR_NONE)
5452 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5454 LOGD("ret : 0x%x", ret);
5460 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5462 int ret = CAMERA_ERROR_NONE;
5463 int get_flash_state = 0;
5466 LOGE("NULL pointer");
5467 return CAMERA_ERROR_INVALID_PARAMETER;
5470 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5471 (int)device, "get_flash_state", &get_flash_state);
5473 if (ret == CAMERA_ERROR_NONE) {
5474 *state = (camera_flash_state_e)get_flash_state;
5475 LOGD("flash state %d", *state);
5477 LOGE("failed 0x%x", ret);
5484 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5486 int ret = CAMERA_ERROR_NONE;
5487 camera_cli_s *pc = (camera_cli_s *)camera;
5488 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5490 if (!pc || !pc->cb_info || !foreach_cb) {
5491 LOGE("NULL pointer %p %p", pc, foreach_cb);
5492 return CAMERA_ERROR_INVALID_PARAMETER;
5497 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5498 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5500 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5502 LOGD("ret : 0x%x", ret);
5508 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5510 int ret = CAMERA_ERROR_NONE;
5511 camera_cli_s *pc = (camera_cli_s *)camera;
5512 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5514 if (!pc || !pc->cb_info || !foreach_cb) {
5515 LOGE("NULL pointer %p %p", pc, foreach_cb);
5516 return CAMERA_ERROR_INVALID_PARAMETER;
5521 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5522 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5524 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5526 LOGD("ret : 0x%x", ret);
5532 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5534 int ret = CAMERA_ERROR_NONE;
5535 camera_cli_s *pc = (camera_cli_s *)camera;
5536 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5538 if (!pc || !pc->cb_info || !foreach_cb) {
5539 LOGE("NULL pointer %p %p", pc, foreach_cb);
5540 return CAMERA_ERROR_INVALID_PARAMETER;
5545 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5546 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5548 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5550 LOGD("ret : 0x%x", ret);
5556 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5558 int ret = CAMERA_ERROR_NONE;
5559 camera_cli_s *pc = (camera_cli_s *)camera;
5560 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5562 if (!pc || !pc->cb_info || !foreach_cb) {
5563 LOGE("NULL pointer %p %p", pc, foreach_cb);
5564 return CAMERA_ERROR_INVALID_PARAMETER;
5569 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5570 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5572 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5574 LOGD("ret : 0x%x", ret);
5580 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5582 int ret = CAMERA_ERROR_NONE;
5583 camera_cli_s *pc = (camera_cli_s *)camera;
5584 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5586 if (!pc || !pc->cb_info || !foreach_cb) {
5587 LOGE("NULL pointer %p %p", pc, foreach_cb);
5588 return CAMERA_ERROR_INVALID_PARAMETER;
5593 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5594 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5596 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5598 LOGD("ret : 0x%x", ret);
5604 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5606 int ret = CAMERA_ERROR_NONE;
5607 camera_cli_s *pc = (camera_cli_s *)camera;
5608 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5610 if (!pc || !pc->cb_info || !foreach_cb) {
5611 LOGE("NULL pointer %p %p", pc, foreach_cb);
5612 return CAMERA_ERROR_INVALID_PARAMETER;
5617 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5618 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5620 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5622 LOGD("ret : 0x%x", ret);
5628 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5630 int ret = CAMERA_ERROR_NONE;
5631 camera_cli_s *pc = (camera_cli_s *)camera;
5632 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5634 if (!pc || !pc->cb_info || !foreach_cb) {
5635 LOGE("NULL pointer %p %p", pc, foreach_cb);
5636 return CAMERA_ERROR_INVALID_PARAMETER;
5641 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5642 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5644 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5646 LOGD("ret : 0x%x", ret);
5652 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5654 int ret = CAMERA_ERROR_NONE;
5655 camera_cli_s *pc = (camera_cli_s *)camera;
5656 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5658 if (!pc || !pc->cb_info || !foreach_cb) {
5659 LOGE("NULL pointer %p %p", pc, foreach_cb);
5660 return CAMERA_ERROR_INVALID_PARAMETER;
5665 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5666 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5668 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5670 LOGD("Enter, handle :%x", pc->remote_handle);
5676 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)
5678 int ret = CAMERA_ERROR_NONE;
5679 camera_cli_s *pc = (camera_cli_s *)camera;
5680 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5681 camera_msg_param param;
5684 if (!pc || !pc->cb_info || !foreach_cb) {
5685 LOGE("NULL pointer %p %p", pc, foreach_cb);
5686 return CAMERA_ERROR_INVALID_PARAMETER;
5691 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5692 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5694 value = (width << 16) | height;
5695 CAMERA_MSG_PARAM_SET(param, INT, value);
5697 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5699 LOGD("ret : 0x%x", ret);
5705 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5707 int ret = CAMERA_ERROR_NONE;
5708 camera_cli_s *pc = (camera_cli_s *)camera;
5709 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5711 if (!pc || !pc->cb_info || !foreach_cb) {
5712 LOGE("NULL pointer %p %p", pc, foreach_cb);
5713 return CAMERA_ERROR_INVALID_PARAMETER;
5718 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5719 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5721 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5723 LOGD("ret : 0x%x", ret);
5729 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5731 int ret = CAMERA_ERROR_NONE;
5732 camera_cli_s *pc = (camera_cli_s *)camera;
5733 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5735 if (!pc || !pc->cb_info || !foreach_cb) {
5736 LOGE("NULL pointer %p %p", pc, foreach_cb);
5737 return CAMERA_ERROR_INVALID_PARAMETER;
5742 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5743 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5745 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5747 LOGD("ret : 0x%x", ret);
5753 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5755 int ret = CAMERA_ERROR_NONE;
5756 camera_cli_s *pc = (camera_cli_s *)camera;
5757 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5758 camera_msg_param param;
5759 int set_rotation = (int)rotation;
5761 if (!pc || !pc->cb_info) {
5762 LOGE("NULL handle");
5763 return CAMERA_ERROR_INVALID_PARAMETER;
5768 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5770 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5772 LOGD("ret : 0x%x", ret);
5778 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5780 int ret = CAMERA_ERROR_NONE;
5781 camera_cli_s *pc = (camera_cli_s *)camera;
5782 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5784 if (!pc || !pc->cb_info || !rotation) {
5785 LOGE("NULL pointer %p %p", pc, rotation);
5786 return CAMERA_ERROR_INVALID_PARAMETER;
5791 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5793 if (ret == CAMERA_ERROR_NONE)
5794 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5796 LOGD("ret : 0x%x", ret);
5802 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5804 int ret = CAMERA_ERROR_NONE;
5805 camera_cli_s *pc = (camera_cli_s *)camera;
5806 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5807 camera_msg_param param;
5808 int set_flip = (int)flip;
5810 if (!pc || !pc->cb_info) {
5811 LOGE("NULL handle");
5812 return CAMERA_ERROR_INVALID_PARAMETER;
5817 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5819 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5821 LOGD("ret : 0x%x", ret);
5827 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5829 int ret = CAMERA_ERROR_NONE;
5830 camera_cli_s *pc = (camera_cli_s *)camera;
5831 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5833 if (!pc || !pc->cb_info || !flip) {
5834 LOGE("NULL pointer %p %p", pc, flip);
5835 return CAMERA_ERROR_INVALID_PARAMETER;
5840 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5842 if (ret == CAMERA_ERROR_NONE)
5843 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5845 LOGD("ret : 0x%x", ret);
5850 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5852 int ret = CAMERA_ERROR_NONE;
5853 camera_cli_s *pc = (camera_cli_s *)camera;
5854 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5855 camera_msg_param param;
5856 int set_mode = (int)mode;
5858 if (!pc || !pc->cb_info) {
5859 LOGE("NULL handle");
5860 return CAMERA_ERROR_INVALID_PARAMETER;
5865 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5867 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5869 LOGD("ret : 0x%x", ret);
5875 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5877 int ret = CAMERA_ERROR_NONE;
5878 camera_cli_s *pc = (camera_cli_s *)camera;
5879 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5881 if (!pc || !pc->cb_info || !mode) {
5882 LOGE("NULL pointer %p %p", pc, mode);
5883 return CAMERA_ERROR_INVALID_PARAMETER;
5888 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5890 if (ret == CAMERA_ERROR_NONE)
5891 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
5893 LOGD("ret : 0x%x", ret);
5899 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5901 int ret = CAMERA_ERROR_NONE;
5902 camera_cli_s *pc = (camera_cli_s *)camera;
5903 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
5905 if (!pc || !pc->cb_info) {
5906 LOGE("NULL handle");
5907 return CAMERA_ERROR_INVALID_PARAMETER;
5912 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5915 LOGE("error is occurred 0x%x", ret);
5919 LOGD("ret : %d", ret);
5925 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5927 int ret = CAMERA_ERROR_NONE;
5928 camera_cli_s *pc = (camera_cli_s *)camera;
5929 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5931 if (!pc || !pc->cb_info) {
5932 LOGE("NULL handle");
5933 return CAMERA_ERROR_INVALID_PARAMETER;
5938 if (!camera_attr_is_supported_hdr_capture(camera)) {
5939 LOGE("HDR not supported");
5940 return CAMERA_ERROR_NOT_SUPPORTED;
5944 LOGE("NULL callback");
5945 return CAMERA_ERROR_INVALID_PARAMETER;
5948 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5949 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5951 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5953 LOGD("ret : 0x%x", ret);
5959 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5961 int ret = CAMERA_ERROR_NONE;
5962 camera_cli_s *pc = (camera_cli_s *)camera;
5963 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5965 if (!pc || !pc->cb_info) {
5966 LOGE("NULL handle");
5967 return CAMERA_ERROR_INVALID_PARAMETER;
5972 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5973 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5975 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5977 LOGD("ret : 0x%x", ret);
5983 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
5985 int ret = CAMERA_ERROR_NONE;
5986 camera_cli_s *pc = (camera_cli_s *)camera;
5987 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
5988 camera_msg_param param;
5989 int set_enable = (int)enable;
5991 if (!pc || !pc->cb_info) {
5992 LOGE("NULL handle");
5993 return CAMERA_ERROR_INVALID_PARAMETER;
5998 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6000 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6002 LOGD("ret : 0x%x", ret);
6008 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6010 int ret = CAMERA_ERROR_NONE;
6011 camera_cli_s *pc = (camera_cli_s *)camera;
6012 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6014 if (!pc || !pc->cb_info || !enabled) {
6015 LOGE("NULL pointer %p %p", pc, enabled);
6016 return CAMERA_ERROR_INVALID_PARAMETER;
6021 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6023 if (ret == CAMERA_ERROR_NONE)
6024 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6026 LOGD("ret : 0x%x", ret);
6032 bool camera_attr_is_supported_anti_shake(camera_h camera)
6034 int ret = CAMERA_ERROR_NONE;
6035 camera_cli_s *pc = (camera_cli_s *)camera;
6036 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6038 if (!pc || !pc->cb_info) {
6039 LOGE("NULL handle");
6040 return CAMERA_ERROR_INVALID_PARAMETER;
6045 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6048 LOGE("error is occurred 0x%x", ret);
6052 LOGD("ret : %d", ret);
6058 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6060 int ret = CAMERA_ERROR_NONE;
6061 camera_cli_s *pc = (camera_cli_s *)camera;
6062 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6063 camera_msg_param param;
6064 int set_enable = (int)enable;
6066 if (!pc || !pc->cb_info) {
6067 LOGE("NULL handle");
6068 return CAMERA_ERROR_INVALID_PARAMETER;
6073 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6075 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6077 LOGD("ret : 0x%x", ret);
6083 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6085 int ret = CAMERA_ERROR_NONE;
6086 camera_cli_s *pc = (camera_cli_s *)camera;
6087 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6089 if (!pc || !pc->cb_info || !enabled) {
6090 LOGE("NULL pointer %p %p", pc, enabled);
6091 return CAMERA_ERROR_INVALID_PARAMETER;
6096 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6098 if (ret == CAMERA_ERROR_NONE)
6099 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6101 LOGD("ret : 0x%x", ret);
6107 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6109 int ret = CAMERA_ERROR_NONE;
6110 camera_cli_s *pc = (camera_cli_s *)camera;
6111 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6113 if (!pc || !pc->cb_info) {
6114 LOGE("NULL handle");
6115 return CAMERA_ERROR_INVALID_PARAMETER;
6120 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6123 LOGE("error is occurred 0x%x", ret);
6127 LOGD("ret : %d", ret);
6133 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6135 int ret = CAMERA_ERROR_NONE;
6136 camera_cli_s *pc = (camera_cli_s *)camera;
6137 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6138 camera_msg_param param;
6139 int set_enable = (int)enable;
6141 if (!pc || !pc->cb_info) {
6142 LOGE("NULL handle");
6143 return CAMERA_ERROR_INVALID_PARAMETER;
6148 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6150 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6152 LOGD("ret : 0x%x", ret);
6158 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6160 int ret = CAMERA_ERROR_NONE;
6161 camera_cli_s *pc = (camera_cli_s *)camera;
6162 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6164 if (!pc || !pc->cb_info || !enabled) {
6165 LOGE("NULL pointer %p %p", pc, enabled);
6166 return CAMERA_ERROR_INVALID_PARAMETER;
6171 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6173 if (ret == CAMERA_ERROR_NONE)
6174 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6176 LOGD("ret : 0x%x", ret);
6182 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6184 int ret = CAMERA_ERROR_NONE;
6185 camera_cli_s *pc = (camera_cli_s *)camera;
6186 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6188 if (!pc || !pc->cb_info) {
6189 LOGE("NULL handle");
6190 return CAMERA_ERROR_INVALID_PARAMETER;
6195 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6198 LOGE("error is occurred 0x%x", ret);
6202 LOGD("ret : %d", ret);
6208 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6210 int ret = CAMERA_ERROR_NONE;
6211 camera_cli_s *pc = (camera_cli_s *)camera;
6212 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6213 camera_msg_param param;
6214 int set_disable = (int)disable;
6216 if (!pc || !pc->cb_info) {
6217 LOGE("NULL handle");
6218 return CAMERA_ERROR_INVALID_PARAMETER;
6223 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6225 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6227 LOGD("ret : 0x%x", ret);
6233 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6235 int ret = CAMERA_ERROR_NONE;
6236 camera_cli_s *pc = (camera_cli_s *)camera;
6237 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6238 camera_msg_param param;
6239 int set_move_type = (int)move_type;
6242 if (!pc || !pc->cb_info) {
6243 LOGE("NULL handle");
6244 return CAMERA_ERROR_INVALID_PARAMETER;
6249 value = (set_move_type << 16) | pan_step;
6250 CAMERA_MSG_PARAM_SET(param, INT, value);
6252 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6254 LOGD("ret : 0x%x", ret);
6260 int camera_attr_get_pan(camera_h camera, int *pan_step)
6262 int ret = CAMERA_ERROR_NONE;
6263 camera_cli_s *pc = (camera_cli_s *)camera;
6264 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6266 if (!pc || !pc->cb_info || !pan_step) {
6267 LOGE("NULL pointer %p %p", pc, pan_step);
6268 return CAMERA_ERROR_INVALID_PARAMETER;
6273 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6275 if (ret == CAMERA_ERROR_NONE)
6276 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6278 LOGD("ret : 0x%x", ret);
6284 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6286 int ret = CAMERA_ERROR_NONE;
6287 camera_cli_s *pc = (camera_cli_s *)camera;
6288 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6290 if (!pc || !pc->cb_info || !min || !max) {
6291 LOGE("NULL pointer %p %p", pc, min, max);
6292 return CAMERA_ERROR_INVALID_PARAMETER;
6297 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6299 if (ret == CAMERA_ERROR_NONE) {
6300 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6301 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6304 LOGD("ret : 0x%x", ret);
6310 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6312 int ret = CAMERA_ERROR_NONE;
6313 camera_cli_s *pc = (camera_cli_s *)camera;
6314 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6315 camera_msg_param param;
6316 int set_move_type = (int)move_type;
6319 if (!pc || !pc->cb_info) {
6320 LOGE("NULL handle");
6321 return CAMERA_ERROR_INVALID_PARAMETER;
6326 value = (set_move_type << 16) | tilt_step;
6327 CAMERA_MSG_PARAM_SET(param, INT, value);
6329 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6331 LOGD("ret : 0x%x", ret);
6337 int camera_attr_get_tilt(camera_h camera, int *tilt_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_GET_TILT;
6343 if (!pc || !pc->cb_info || !tilt_step) {
6344 LOGE("NULL pointer %p %p", pc, tilt_step);
6345 return CAMERA_ERROR_INVALID_PARAMETER;
6350 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6352 if (ret == CAMERA_ERROR_NONE)
6353 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6355 LOGD("ret : 0x%x", ret);
6361 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6363 int ret = CAMERA_ERROR_NONE;
6364 camera_cli_s *pc = (camera_cli_s *)camera;
6365 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6367 if (!pc || !pc->cb_info || !min || !max) {
6368 LOGE("NULL pointer %p %p %p", pc, min, max);
6369 return CAMERA_ERROR_INVALID_PARAMETER;
6374 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6376 if (ret == CAMERA_ERROR_NONE) {
6377 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6378 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6381 LOGD("ret : 0x%x", ret);
6387 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6389 int ret = CAMERA_ERROR_NONE;
6390 camera_cli_s *pc = (camera_cli_s *)camera;
6391 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6392 camera_msg_param param;
6393 int set_ptz_type = (int)ptz_type;
6395 if (!pc || !pc->cb_info) {
6396 LOGE("NULL handle");
6397 return CAMERA_ERROR_INVALID_PARAMETER;
6402 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6404 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6406 LOGD("ret : 0x%x", ret);
6412 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6414 int ret = CAMERA_ERROR_NONE;
6415 camera_cli_s *pc = (camera_cli_s *)camera;
6416 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6418 if (!pc || !pc->cb_info || !foreach_cb) {
6419 LOGE("NULL pointer %p %p", pc, foreach_cb);
6420 return CAMERA_ERROR_INVALID_PARAMETER;
6425 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6426 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6428 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6430 LOGD("ret : 0x%x", ret);
6436 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6438 int ret = CAMERA_ERROR_NONE;
6439 camera_cli_s *pc = (camera_cli_s *)camera;
6440 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6441 int set_display_roi_area[4] = {x, y, width, height};
6446 if (!pc || !pc->cb_info) {
6447 LOGE("NULL handle");
6448 return CAMERA_ERROR_INVALID_PARAMETER;
6453 #ifdef TIZEN_FEATURE_EVAS_RENDERER
6454 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6455 g_mutex_lock(&pc->cb_info->evas_mutex);
6457 ret = mm_evas_renderer_set_roi_area(pc->cb_info->evas_info, x, y, width, height);
6459 g_mutex_unlock(&pc->cb_info->evas_mutex);
6461 if (ret != MM_ERROR_NONE) {
6462 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6463 return CAMERA_ERROR_INVALID_OPERATION;
6466 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
6468 length = sizeof(set_display_roi_area) / sizeof(int) + \
6469 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6471 msg = muse_core_msg_json_factory_new(api,
6472 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6475 LOGE("msg creation failed: api %d", api);
6476 return CAMERA_ERROR_OUT_OF_MEMORY;
6479 if (pc->cb_info->is_server_connected) {
6480 __camera_update_api_waiting(pc->cb_info, api, 1);
6482 g_mutex_lock(&pc->cb_info->fd_lock);
6483 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
6484 g_mutex_unlock(&pc->cb_info->fd_lock);
6488 LOGE("message send failed");
6489 ret = CAMERA_ERROR_INVALID_OPERATION;
6491 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6494 __camera_update_api_waiting(pc->cb_info, api, -1);
6496 muse_core_msg_json_factory_free(msg);
6498 LOGD("ret : 0x%x", ret);
6504 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6506 camera_cli_s *pc = (camera_cli_s *)camera;
6507 int ret = CAMERA_ERROR_NONE;
6508 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6510 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6511 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6512 return CAMERA_ERROR_INVALID_PARAMETER;
6517 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6519 if (ret == CAMERA_ERROR_NONE) {
6520 *x = pc->cb_info->get_display_roi_area[0];
6521 *y = pc->cb_info->get_display_roi_area[1];
6522 *width = pc->cb_info->get_display_roi_area[2];
6523 *height = pc->cb_info->get_display_roi_area[3];
6526 LOGD("ret : 0x%x", ret);
6532 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6534 int ret = CAMERA_ERROR_NONE;
6535 int get_device_state = 0;
6538 LOGE("NULL pointer");
6539 return CAMERA_ERROR_INVALID_PARAMETER;
6542 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6543 (int)device, "get_device_state", &get_device_state);
6545 if (ret == CAMERA_ERROR_NONE) {
6546 *state = (camera_device_state_e)get_device_state;
6547 LOGD("device state %d", *state);
6549 LOGE("failed 0x%x", ret);
6556 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6558 int ret = CAMERA_ERROR_NONE;
6559 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6560 camera_cb_info *info = NULL;
6562 if (!callback || !cb_id) {
6563 LOGE("invalid pointer %p %p", callback, cb_id);
6564 return CAMERA_ERROR_INVALID_PARAMETER;
6567 /* check camera support */
6568 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6569 if (ret != CAMERA_ERROR_NONE) {
6570 LOGE("get device state failed");
6574 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6576 info = g_new0(camera_cb_info, 1);
6578 LOGE("info failed");
6579 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6583 info->id = ++g_cam_dev_state_changed_cb_id;
6584 info->callback = (void *)callback;
6585 info->user_data = user_data;
6589 /* subscribe dbus signal for camera state change */
6590 if (!g_cam_dev_state_changed_cb_conn) {
6591 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6592 if (!g_cam_dev_state_changed_cb_conn) {
6593 LOGE("failed to get gdbus connection");
6594 ret = CAMERA_ERROR_INVALID_OPERATION;
6598 LOGD("subscribe signal %s - %s - %s",
6599 MM_CAMCORDER_DBUS_OBJECT,
6600 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6601 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6603 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6604 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6605 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6606 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6607 LOGE("failed to get gdbus connection");
6608 ret = CAMERA_ERROR_INVALID_OPERATION;
6612 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6615 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6617 LOGD("callback id %d", info->id);
6620 if (ret != CAMERA_ERROR_NONE) {
6626 if (g_cam_dev_state_changed_cb_conn) {
6627 g_object_unref(g_cam_dev_state_changed_cb_conn);
6628 g_cam_dev_state_changed_cb_conn = NULL;
6632 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6638 int camera_remove_device_state_changed_cb(int cb_id)
6640 int ret = CAMERA_ERROR_NONE;
6641 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6642 GList *tmp_list = NULL;
6643 camera_cb_info *info = NULL;
6645 /* check camera support */
6646 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6647 if (ret != CAMERA_ERROR_NONE) {
6648 LOGE("get device state failed");
6652 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6654 if (!g_cam_dev_state_changed_cb_list) {
6655 LOGE("there is no callback info");
6656 ret = CAMERA_ERROR_INVALID_OPERATION;
6660 tmp_list = g_cam_dev_state_changed_cb_list;
6663 info = tmp_list->data;
6664 tmp_list = tmp_list->next;
6671 if (info->id == cb_id) {
6672 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6677 if (!g_cam_dev_state_changed_cb_list) {
6678 /* no remained callback */
6679 if (g_cam_dev_state_changed_cb_conn) {
6680 /* unsubscribe signal */
6681 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6682 g_cam_dev_state_changed_cb_subscribe_id = 0;
6684 /* unref connection */
6685 g_object_unref(g_cam_dev_state_changed_cb_conn);
6686 g_cam_dev_state_changed_cb_conn = NULL;
6690 LOGD("id %d callback removed", cb_id);
6691 ret = CAMERA_ERROR_NONE;
6697 LOGE("id %d callback not found", cb_id);
6698 ret = CAMERA_ERROR_INVALID_PARAMETER;
6701 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);