2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
24 #include <muse_camera.h>
25 #include <muse_camera_msg.h>
26 #include <camera_private.h>
27 #include <muse_core.h>
28 #include <muse_client.h>
30 #include <Elementary.h>
31 #include <tbm_surface_internal.h>
33 #include <Ecore_Wayland.h>
34 #include <wayland-client.h>
35 #include <tizen-extension-client-protocol.h>
36 #ifdef TIZEN_FEATURE_EVAS_RENDERER
37 #include <mm_evas_renderer.h>
38 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
44 #define LOG_TAG "TIZEN_N_CAMERA"
46 /* for device changed callback */
47 static GMutex g_cam_dev_state_changed_cb_lock;
48 static GList *g_cam_dev_state_changed_cb_list;
49 static int g_cam_dev_state_changed_cb_id;
50 static GDBusConnection *g_cam_dev_state_changed_cb_conn;
51 static guint g_cam_dev_state_changed_cb_subscribe_id;
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 ecore_wl_window_video_has(window, EINA_TRUE);
142 surface = (struct wl_surface *)ecore_wl_window_surface_get(window);
144 LOGE("failed to get wayland surface");
145 ret = CAMERA_ERROR_INVALID_OPERATION;
149 display = (struct wl_display *)ecore_wl_display_get();
151 LOGE("failed to get wayland display");
152 ret = CAMERA_ERROR_INVALID_OPERATION;
156 display_wrapper = wl_proxy_create_wrapper(display);
157 if (!display_wrapper) {
158 LOGE("failed to create wl display wrapper");
159 ret = CAMERA_ERROR_INVALID_OPERATION;
163 queue = wl_display_create_queue(display);
165 LOGE("failed to create wl display queue");
166 ret = CAMERA_ERROR_INVALID_OPERATION;
170 wl_proxy_set_queue((struct wl_proxy *)display_wrapper, queue);
172 registry = wl_display_get_registry(display_wrapper);
174 LOGE("failed to get wayland registry");
175 ret = CAMERA_ERROR_INVALID_OPERATION;
179 wl_registry_add_listener(registry, &_camera_wl_registry_listener, &tz_surface);
181 wl_display_dispatch_queue(display, queue);
182 wl_display_roundtrip_queue(display, queue);
185 LOGE("failed to get tizen surface");
186 ret = CAMERA_ERROR_INVALID_OPERATION;
190 /* Get parent_id which is unique in a entire systemw. */
191 tz_resource = tizen_surface_get_tizen_resource(tz_surface, surface);
193 LOGE("failed to get tizen resurce");
194 ret = CAMERA_ERROR_INVALID_OPERATION;
198 wl_info->parent_id = 0;
200 tizen_resource_add_listener(tz_resource, &_camera_tz_resource_listener, &wl_info->parent_id);
202 wl_display_roundtrip_queue(display, queue);
204 if (wl_info->parent_id > 0) {
206 Ecore_Evas *ecore_evas = NULL;
207 ret = CAMERA_ERROR_NONE;
209 wl_info->evas_obj = obj;
211 evas_object_geometry_get(obj, &wl_info->window_x, &wl_info->window_y,
212 &wl_info->window_width, &wl_info->window_height);
214 ecore_evas = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
216 rotation = ecore_evas_rotation_get(ecore_evas);
217 if (rotation == 90 || rotation == 270) {
218 int temp = wl_info->window_width;
220 LOGD("swap width and height %d, %d", wl_info->window_width, wl_info->window_height);
222 wl_info->window_width = wl_info->window_height;
223 wl_info->window_height = temp;
226 LOGW("failed to get ecore_evas.. skip rotation check");
229 LOGD("evas object : %p, rotation : %d, parent id : %u, window : %d,%d,%dx%d",
230 wl_info->evas_obj, rotation, wl_info->parent_id,
231 wl_info->window_x, wl_info->window_y,
232 wl_info->window_width, wl_info->window_height);
234 ret = CAMERA_ERROR_INVALID_OPERATION;
235 LOGE("failed to get parent id");
240 tizen_surface_destroy(tz_surface);
245 tizen_resource_destroy(tz_resource);
250 wl_registry_destroy(registry);
255 wl_event_queue_destroy(queue);
259 if (display_wrapper) {
260 wl_proxy_wrapper_destroy(display_wrapper);
261 display_wrapper = NULL;
269 static void __camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value)
272 api < 0 || api >= MUSE_CAMERA_API_MAX) {
273 LOGE("invalid param %p %d", cb_info, api);
277 g_mutex_lock(&(cb_info->api_mutex[api]));
278 cb_info->api_waiting[api] += value;
279 g_mutex_unlock(&(cb_info->api_mutex[api]));
281 /*LOGD("api %d, value %d, waiting %d",
282 api, value, cb_info->api_waiting[api]);*/
288 static void __camera_device_state_changed_cb(GDBusConnection *connection,
289 const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
290 const gchar *signal_name, GVariant *param, gpointer user_data)
293 camera_device_e device = CAMERA_DEVICE_CAMERA0;
294 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
295 GList *tmp_list = NULL;
296 camera_cb_info *info = NULL;
298 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
300 if (!g_cam_dev_state_changed_cb_list || !param) {
301 LOGW("no callback or NULL param %p", param);
305 /* get device and state */
306 g_variant_get(param, "(i)", &value);
308 device = value >> 16;
309 state = 0x0000ffff & value;
311 LOGD("device %d, state %d", device, state);
313 tmp_list = g_cam_dev_state_changed_cb_list;
316 info = (camera_cb_info *)tmp_list->data;
319 if (info->callback) {
320 LOGD("start id[%d] callback", info->id);
321 ((camera_device_state_changed_cb)info->callback)(device, state, info->user_data);
322 LOGD("returned id[%d] callback", info->id);
324 LOGW("NULL callback for id %d", info->id);
328 tmp_list = tmp_list->next;
332 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
338 static int _camera_import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle)
340 tbm_bo tmp_bo = NULL;
341 tbm_bo_handle tmp_bo_handle = {NULL, };
343 if (!bufmgr || !bo || !bo_handle || !tbm_key) {
344 LOGE("invalid parameter - %p %p %p, key %d",
345 bufmgr, bo, bo_handle, tbm_key);
349 tmp_bo = tbm_bo_import(bufmgr, tbm_key);
350 if (tmp_bo == NULL) {
351 LOGE("import failed - key %d", tbm_key);
355 tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
356 if (tmp_bo_handle.ptr == NULL) {
357 LOGE("map failed %p", tmp_bo);
358 tbm_bo_unref(tmp_bo);
363 tbm_bo_unmap(tmp_bo);
365 /* set bo and bo_handle */
367 *bo_handle = tmp_bo_handle;
372 static void _camera_release_imported_bo(tbm_bo *bo)
385 static int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
387 int ret = CAMERA_ERROR_NONE;
390 /*LOGD("Enter api : %d", api);*/
392 if (!cb_info->is_server_connected) {
393 LOGE("server is disconnected");
394 return CAMERA_ERROR_SERVICE_DISCONNECTED;
397 g_mutex_lock(&(cb_info->api_mutex[api]));
399 if (cb_info->api_activating[api] == 0) {
400 if (time_out == CAMERA_CB_NO_TIMEOUT) {
401 LOGW("wait for api %d", api);
402 g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
403 ret = cb_info->api_ret[api];
404 cb_info->api_activating[api] = 0;
405 LOGW("api %d returned 0x%x", api, ret);
407 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
408 if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
409 ret = cb_info->api_ret[api];
410 cb_info->api_activating[api] = 0;
411 /*LOGD("return value : 0x%x", ret);*/
413 ret = CAMERA_ERROR_INVALID_OPERATION;
414 LOGE("api %d was TIMED OUT!", api);
418 ret = cb_info->api_ret[api];
419 cb_info->api_activating[api] = 0;
421 /*LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);*/
424 g_mutex_unlock(&(cb_info->api_mutex[api]));
426 if (ret != CAMERA_ERROR_NONE) {
427 LOGE("api %d : error 0x%x", api, ret);
429 if (ret == CAMERA_ERROR_SOUND_POLICY)
430 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
431 else if (ret == CAMERA_ERROR_SOUND_POLICY_BY_CALL)
432 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
433 else if (ret == CAMERA_ERROR_SOUND_POLICY_BY_ALARM)
434 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
441 static void _camera_msg_send(int api, camera_cb_info_s *cb_info,
442 int *ret, int timeout)
448 LOGE("NULL info - api %d", api);
451 *ret = CAMERA_ERROR_INVALID_PARAMETER;
456 msg = muse_core_msg_new(api, NULL);
458 LOGE("msg failed: api %d", api);
461 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
466 /*LOGD("send msg %s", msg);*/
468 if (cb_info->is_server_connected) {
469 __camera_update_api_waiting(cb_info, api, 1);
471 g_mutex_lock(&cb_info->fd_lock);
472 send_ret = muse_core_msg_send(cb_info->fd, msg);
473 g_mutex_unlock(&cb_info->fd_lock);
477 LOGE("msg send failed");
479 *ret = CAMERA_ERROR_INVALID_OPERATION;
482 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
485 __camera_update_api_waiting(cb_info, api, -1);
487 muse_core_msg_free(msg);
493 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
494 int *ret, camera_msg_param *param, int timeout)
499 if (!cb_info || !param) {
500 LOGE("invalid pointer : api %d - %p %p", api, cb_info, param);
503 *ret = CAMERA_ERROR_INVALID_PARAMETER;
508 /*LOGD("type %d, name %s", param->type, param->name);*/
510 switch (param->type) {
512 msg = muse_core_msg_new(api,
513 param->type, param->name, param->value.value_INT,
516 case MUSE_TYPE_STRING:
517 msg = muse_core_msg_new(api,
518 param->type, param->name, param->value.value_STRING,
522 LOGE("unknown type %d", param->type);
527 LOGE("msg failed: api %d", api);
530 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
535 /*LOGD("send msg %s", msg);*/
537 if (cb_info->is_server_connected) {
538 __camera_update_api_waiting(cb_info, api, 1);
540 g_mutex_lock(&cb_info->fd_lock);
541 send_ret = muse_core_msg_send(cb_info->fd, msg);
542 g_mutex_unlock(&cb_info->fd_lock);
546 LOGE("msg send failed");
549 *ret = CAMERA_ERROR_INVALID_OPERATION;
552 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
555 __camera_update_api_waiting(cb_info, api, -1);
557 muse_core_msg_free(msg);
563 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
565 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
566 in_format >= MM_PIXEL_FORMAT_NUM ||
567 out_format == NULL) {
568 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
569 return CAMERA_ERROR_INVALID_PARAMETER;
573 case MM_PIXEL_FORMAT_NV12:
574 case MM_PIXEL_FORMAT_NV12T:
575 *out_format = TBM_FORMAT_NV12;
578 case MM_PIXEL_FORMAT_NV16:
579 *out_format = TBM_FORMAT_NV16;
581 case MM_PIXEL_FORMAT_NV21:
582 *out_format = TBM_FORMAT_NV21;
584 case MM_PIXEL_FORMAT_YUYV:
585 *out_format = TBM_FORMAT_YUYV;
587 case MM_PIXEL_FORMAT_UYVY:
588 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
589 *out_format = TBM_FORMAT_UYVY;
591 case MM_PIXEL_FORMAT_422P:
592 *out_format = TBM_FORMAT_YUV422;
594 case MM_PIXEL_FORMAT_I420:
595 *out_format = TBM_FORMAT_YUV420;
597 case MM_PIXEL_FORMAT_YV12:
598 *out_format = TBM_FORMAT_YVU420;
600 case MM_PIXEL_FORMAT_RGB565:
601 *out_format = TBM_FORMAT_RGB565;
603 case MM_PIXEL_FORMAT_RGB888:
604 *out_format = TBM_FORMAT_RGB888;
606 case MM_PIXEL_FORMAT_RGBA:
607 *out_format = TBM_FORMAT_RGBA8888;
609 case MM_PIXEL_FORMAT_ARGB:
610 *out_format = TBM_FORMAT_ARGB8888;
613 LOGE("invalid in_format %d", in_format);
614 return CAMERA_ERROR_INVALID_PARAMETER;
618 return CAMERA_ERROR_NONE;
622 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
624 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
625 in_format >= MM_PIXEL_FORMAT_NUM ||
627 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
628 return CAMERA_ERROR_INVALID_PARAMETER;
632 case MM_PIXEL_FORMAT_NV12:
633 case MM_PIXEL_FORMAT_NV12T:
634 *mimetype = MEDIA_FORMAT_NV12;
637 case MM_PIXEL_FORMAT_NV16:
638 *mimetype = MEDIA_FORMAT_NV16;
640 case MM_PIXEL_FORMAT_NV21:
641 *mimetype = MEDIA_FORMAT_NV21;
643 case MM_PIXEL_FORMAT_YUYV:
644 *mimetype = MEDIA_FORMAT_YUYV;
646 case MM_PIXEL_FORMAT_UYVY:
647 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
648 *mimetype = MEDIA_FORMAT_UYVY;
650 case MM_PIXEL_FORMAT_422P:
651 *mimetype = MEDIA_FORMAT_422P;
653 case MM_PIXEL_FORMAT_I420:
654 *mimetype = MEDIA_FORMAT_I420;
656 case MM_PIXEL_FORMAT_YV12:
657 *mimetype = MEDIA_FORMAT_YV12;
659 case MM_PIXEL_FORMAT_RGB565:
660 *mimetype = MEDIA_FORMAT_RGB565;
662 case MM_PIXEL_FORMAT_RGB888:
663 *mimetype = MEDIA_FORMAT_RGB888;
665 case MM_PIXEL_FORMAT_RGBA:
666 *mimetype = MEDIA_FORMAT_RGBA;
668 case MM_PIXEL_FORMAT_ARGB:
669 *mimetype = MEDIA_FORMAT_ARGB;
672 LOGE("invalid in_format %d", in_format);
673 return CAMERA_ERROR_INVALID_PARAMETER;
677 return CAMERA_ERROR_NONE;
680 void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_key,
681 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame)
684 unsigned char *buf_pos = NULL;
686 if (stream == NULL || buffer_bo_handle == NULL || frame == NULL) {
687 LOGE("invalid parameter - stream:%p, buffer_bo_handle:%p", stream, buffer_bo_handle);
692 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
693 frame->format = MM_PIXEL_FORMAT_UYVY;
695 frame->format = stream->format;
697 frame->width = stream->width;
698 frame->height = stream->height;
699 frame->timestamp = stream->timestamp;
700 frame->num_of_planes = stream->num_planes;
702 if (num_buffer_key == 0) {
705 if (!data_bo_handle || !data_bo_handle->ptr) {
706 LOGE("NULL pointer");
710 buf_pos = data_bo_handle->ptr;
712 if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) {
713 frame->data.encoded_plane.data = buf_pos;
714 frame->data.encoded_plane.size = stream->data.encoded.length_data;
715 total_size = stream->data.encoded.length_data;
717 switch (stream->num_planes) {
719 frame->data.single_plane.yuv = buf_pos;
720 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
721 total_size = stream->data.yuv420.length_yuv;
724 frame->data.double_plane.y = buf_pos;
725 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
726 buf_pos += stream->data.yuv420sp.length_y;
727 frame->data.double_plane.uv = buf_pos;
728 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
729 total_size = stream->data.yuv420sp.length_y + \
730 stream->data.yuv420sp.length_uv;
733 frame->data.triple_plane.y = buf_pos;
734 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
735 buf_pos += stream->data.yuv420p.length_y;
736 frame->data.triple_plane.u = buf_pos;
737 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
738 buf_pos += stream->data.yuv420p.length_u;
739 frame->data.triple_plane.v = buf_pos;
740 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
741 total_size = stream->data.yuv420p.length_y + \
742 stream->data.yuv420p.length_u + \
743 stream->data.yuv420p.length_v;
752 switch (stream->num_planes) {
755 frame->data.single_plane.yuv = buffer_bo_handle[0].ptr;
756 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
757 total_size = stream->data.yuv420.length_yuv;
761 frame->data.double_plane.y = buffer_bo_handle[0].ptr;
762 if (stream->num_planes == (unsigned int)num_buffer_key)
763 frame->data.double_plane.uv = buffer_bo_handle[1].ptr;
765 frame->data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
766 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
767 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
768 total_size = stream->data.yuv420sp.length_y + \
769 stream->data.yuv420sp.length_uv;
773 frame->data.triple_plane.y = buffer_bo_handle[0].ptr;
774 if (stream->num_planes == (unsigned int)num_buffer_key) {
775 frame->data.triple_plane.u = buffer_bo_handle[1].ptr;
776 frame->data.triple_plane.v = buffer_bo_handle[2].ptr;
778 frame->data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y;
779 frame->data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u;
781 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
782 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
783 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
784 total_size = stream->data.yuv420p.length_y + \
785 stream->data.yuv420p.length_u + \
786 stream->data.yuv420p.length_v;
795 LOGD("format %d, %dx%d, size %d plane num %d",
796 frame.format, frame.width, frame.height, total_size, frame.num_of_planes);
802 int _camera_media_packet_data_create(int tbm_key, int num_buffer_key, tbm_bo bo,
803 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
806 int ret = CAMERA_ERROR_NONE;
807 camera_media_packet_data *tmp_mp_data = NULL;
809 if (*mp_data == NULL) {
810 tmp_mp_data = g_new0(camera_media_packet_data, 1);
812 tmp_mp_data->tbm_key = tbm_key;
813 tmp_mp_data->num_buffer_key = num_buffer_key;
814 tmp_mp_data->bo = bo;
815 tmp_mp_data->data_bo = data_bo;
816 tmp_mp_data->ref_cnt++;
818 for (i = 0 ; i < num_buffer_key ; i++)
819 tmp_mp_data->buffer_bo[i] = buffer_bo[i];
821 *mp_data = tmp_mp_data;
822 /*LOGD("mp_data %p", tmp_mp_data);*/
824 ret = CAMERA_ERROR_OUT_OF_MEMORY;
825 LOGE("failed to alloc media packet data");
828 ((camera_media_packet_data *)*mp_data)->ref_cnt++;
834 void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
838 camera_msg_param param;
840 if (!mp_data || !cb_info) {
841 LOGE("NULL pointer %p %p", mp_data, cb_info);
845 if (mp_data->ref_cnt > 1) {
847 LOGD("ref count %d", mp_data->ref_cnt);
849 /* release imported bo */
850 for (i = 0 ; i < mp_data->num_buffer_key ; i++) {
851 tbm_bo_unref(mp_data->buffer_bo[i]);
852 mp_data->buffer_bo[i] = NULL;
856 _camera_release_imported_bo(&mp_data->bo);
857 _camera_release_imported_bo(&mp_data->data_bo);
860 tbm_key = mp_data->tbm_key;
862 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
864 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
873 int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
874 camera_media_packet_data *mp_data, media_packet_h *packet)
876 media_packet_h pkt = NULL;
877 bool make_pkt_fmt = false;
878 tbm_surface_h tsurf = NULL;
879 tbm_surface_info_s tsurf_info;
880 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
881 uint32_t bo_format = 0;
884 int num_buffer_key = 0;
885 tbm_bo *buffer_bo = NULL;
887 if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) {
888 LOGE("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p",
889 cb_info, stream, mp_data, packet);
890 return CAMERA_ERROR_INVALID_PARAMETER;
893 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
894 buffer_bo = mp_data->buffer_bo;
895 num_buffer_key = mp_data->num_buffer_key;
897 /* create tbm surface */
898 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
899 tsurf_info.planes[i].stride = stream->stride[i];
901 /* get tbm surface format */
902 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
903 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
905 if (ret == CAMERA_ERROR_NONE) {
906 tsurf_info.width = stream->width;
907 tsurf_info.height = stream->height;
908 tsurf_info.format = bo_format;
909 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
910 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
912 if (num_buffer_key > 0) {
914 case TBM_FORMAT_NV12:
915 case TBM_FORMAT_NV21:
916 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
917 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
918 tsurf_info.planes[0].offset = 0;
919 if (num_buffer_key == 1)
920 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
921 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
924 case TBM_FORMAT_YUV420:
925 case TBM_FORMAT_YVU420:
926 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
927 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
928 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
929 tsurf_info.planes[0].offset = 0;
930 if (num_buffer_key == 1) {
931 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
932 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
934 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
936 case TBM_FORMAT_UYVY:
937 case TBM_FORMAT_YUYV:
938 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
939 tsurf_info.planes[0].offset = 0;
940 tsurf_info.size = tsurf_info.planes[0].size;
947 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_key);
948 } else if (mp_data->data_bo) {
951 case TBM_FORMAT_NV12:
952 case TBM_FORMAT_NV21:
953 tsurf_info.planes[0].size = stream->width * stream->height;
954 tsurf_info.planes[1].size = (tsurf_info.planes[0].size) >> 1;
955 tsurf_info.planes[0].offset = 0;
956 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
957 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
959 case TBM_FORMAT_YUV420:
960 case TBM_FORMAT_YVU420:
961 tsurf_info.planes[0].size = stream->width * stream->height;
962 tsurf_info.planes[1].size = (stream->width >> 1) * (stream->height >> 1);
963 tsurf_info.planes[2].size = tsurf_info.planes[1].size;
964 tsurf_info.planes[0].offset = 0;
965 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
966 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
967 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
969 case TBM_FORMAT_UYVY:
970 case TBM_FORMAT_YUYV:
971 tsurf_info.planes[0].size = (stream->width * stream->height) << 1;
972 tsurf_info.planes[0].offset = 0;
973 tsurf_info.size = tsurf_info.planes[0].size;
979 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1);
982 /*LOGD("tbm surface %p", tsurf);*/
986 /* check media packet format */
987 if (cb_info->pkt_fmt) {
988 int pkt_fmt_width = 0;
989 int pkt_fmt_height = 0;
990 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
992 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
993 if (pkt_fmt_mimetype != mimetype ||
994 pkt_fmt_width != stream->width ||
995 pkt_fmt_height != stream->height) {
996 LOGW("change fmt: current 0x%x, %dx%d",
997 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
998 media_format_unref(cb_info->pkt_fmt);
999 cb_info->pkt_fmt = NULL;
1000 make_pkt_fmt = true;
1003 make_pkt_fmt = true;
1006 /* create packet format */
1008 LOGW("make new pkt_fmt - 0x%x, %dx%d", mimetype, stream->width, stream->height);
1009 ret = media_format_create(&cb_info->pkt_fmt);
1010 if (ret == MEDIA_FORMAT_ERROR_NONE) {
1011 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
1012 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
1013 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
1014 LOGW("media_format_set : 0x%x", ret);
1016 LOGW("media_format_create failed 0x%x", ret);
1020 /* create media packet */
1021 ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt,
1022 tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
1023 (void *)cb_info, &pkt);
1024 if (ret != MEDIA_PACKET_ERROR_NONE) {
1025 LOGE("media_packet_create failed 0x%x", ret);
1026 tbm_surface_destroy(tsurf);
1030 LOGE("tbm surface failed. %dx%d, format %d, num_buffer_key %d, data_bo %p",
1031 stream->width, stream->height, stream->format, num_buffer_key, mp_data->data_bo);
1035 /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
1036 /* set media packet data */
1037 ret = media_packet_set_extra(pkt, (void *)mp_data);
1038 if (ret != MEDIA_PACKET_ERROR_NONE) {
1039 LOGE("media_packet_set_extra failed");
1041 _camera_media_packet_data_release(mp_data, cb_info);
1044 media_packet_destroy(pkt);
1047 /* set timestamp : msec -> nsec */
1048 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
1049 LOGW("media_packet_set_pts failed");
1058 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
1061 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1062 camera_media_packet_data *mp_data = NULL;
1063 tbm_surface_h tsurf = NULL;
1065 if (!pkt || !cb_info) {
1066 LOGE("NULL pointer %p %p", pkt, cb_info);
1067 return MEDIA_PACKET_FINALIZE;
1070 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1071 if (ret != MEDIA_PACKET_ERROR_NONE) {
1072 LOGE("media_packet_get_extra failed 0x%x", ret);
1073 return MEDIA_PACKET_FINALIZE;
1076 /*LOGD("mp_data %p", mp_data);*/
1078 g_mutex_lock(&cb_info->mp_data_mutex);
1080 _camera_media_packet_data_release(mp_data, cb_info);
1083 g_mutex_unlock(&cb_info->mp_data_mutex);
1085 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1086 if (ret != MEDIA_PACKET_ERROR_NONE)
1087 LOGE("get tbm_surface failed 0x%x", ret);
1090 tbm_surface_destroy(tsurf);
1094 return MEDIA_PACKET_FINALIZE;
1097 static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event)
1103 tbm_bo_handle bo_handle = {NULL, };
1104 camera_msg_param param;
1106 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1107 LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event);
1111 /*LOGD("get camera msg %s, event %d", recv_msg, event);*/
1113 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1114 if (!(CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) &&
1115 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] == NULL &&
1116 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] == NULL) {
1117 /* return preview callback */
1118 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info, NULL, 0);
1121 muse_camera_msg_get(tbm_key, recv_msg);
1122 LOGW("all preview callback from user are NULL - return key %d", tbm_key);
1124 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1125 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1129 } else if (cb_info->user_cb[event] == NULL) {
1130 LOGW("user callback for event %d is not set", event);
1135 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1141 muse_camera_msg_get(previous, recv_msg);
1142 muse_camera_msg_get(current, recv_msg);
1143 muse_camera_msg_get(by_policy, recv_msg);
1145 LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
1146 previous, current, by_policy);
1148 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1149 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1152 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1156 muse_camera_msg_get(state, recv_msg);
1158 LOGD("FOCUS state - %d", state);
1160 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1163 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1164 LOGD("CAPTURE_COMPLETED");
1165 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1167 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1168 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1172 int num_buffer_key = 0;
1173 int buffer_key[BUFFER_MAX_PLANE_NUM] = {0, };
1175 unsigned char *buf_pos = NULL;
1177 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
1178 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
1179 tbm_bo data_bo = NULL;
1180 tbm_bo_handle data_bo_handle = {.ptr = NULL};
1182 camera_preview_data_s frame;
1183 camera_stream_data_s *stream = NULL;
1184 camera_media_packet_data *mp_data = NULL;
1185 media_packet_h pkt = NULL;
1186 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1187 media_packet_h pkt_evas = NULL;
1188 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1190 muse_camera_msg_get(tbm_key, recv_msg);
1191 muse_camera_msg_get(num_buffer_key, recv_msg);
1192 muse_camera_msg_get_array(buffer_key, recv_msg);
1193 muse_camera_msg_get(data_key, recv_msg);
1195 memset(&frame, 0x0, sizeof(camera_preview_data_s));
1198 LOGE("invalid key %d", tbm_key);
1202 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1204 if (num_buffer_key < 0 || num_buffer_key > BUFFER_MAX_PLANE_NUM) {
1205 LOGE("invalid num buffer key %d", num_buffer_key);
1206 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1211 /* import tbm data_bo and get virtual address */
1212 if (!_camera_import_tbm_key(cb_info->bufmgr, data_key, &data_bo, &data_bo_handle)) {
1213 LOGE("failed to import data key %d", data_key);
1214 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1219 /* import tbm bo and get virtual address */
1220 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
1221 LOGE("failed to import key %d", tbm_key);
1222 _camera_release_imported_bo(&data_bo);
1223 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1227 buf_pos = (unsigned char *)bo_handle.ptr;
1229 /* get stream info */
1230 stream = (camera_stream_data_s *)buf_pos;
1232 for (i = 0 ; i < num_buffer_key ; i++) {
1233 /* import buffer bo and get virtual address */
1234 if (!_camera_import_tbm_key(cb_info->bufmgr, buffer_key[i], &buffer_bo[i], &buffer_bo_handle[i])) {
1235 LOGE("failed to import buffer key %d", buffer_key[i]);
1237 /* release imported bo */
1238 _camera_release_imported_bo(&data_bo);
1239 _camera_release_imported_bo(&bo);
1241 for (i -= 1 ; i >= 0 ; i--)
1242 _camera_release_imported_bo(&buffer_bo[i]);
1244 /* send return buffer */
1245 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1251 /* call preview callback */
1252 g_mutex_lock(&cb_info->preview_cb_mutex);
1254 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
1255 _camera_preview_frame_create(stream, num_buffer_key, buffer_bo_handle, &data_bo_handle, &frame);
1257 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
1258 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
1261 g_mutex_unlock(&cb_info->preview_cb_mutex);
1263 if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
1264 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1265 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
1267 if (ret == CAMERA_ERROR_NONE) {
1268 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt_evas);
1269 if (ret != CAMERA_ERROR_NONE) {
1270 LOGE("create pkt for evas failed");
1271 _camera_media_packet_data_release(mp_data, cb_info);
1275 #else /* TIZEN_FEATURE_EVAS_RENDERER */
1276 LOGW("evas renderer is not supported");
1277 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1280 /* call media packet callback */
1281 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
1282 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
1284 if (ret == CAMERA_ERROR_NONE) {
1285 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt);
1287 if (ret == CAMERA_ERROR_NONE) {
1288 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
1289 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
1291 _camera_media_packet_data_release(mp_data, cb_info);
1297 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1298 /* call evas renderer */
1300 g_mutex_lock(&cb_info->evas_mutex);
1301 if (cb_info->run_evas_render) {
1302 mm_evas_renderer_write(pkt_evas, cb_info->evas_info);
1304 LOGW("evas renderer is stopped, skip this buffer...");
1305 media_packet_destroy(pkt_evas);
1308 g_mutex_unlock(&cb_info->evas_mutex);
1310 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1312 /* send message for preview callback return */
1313 if (!CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS))
1314 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info, NULL, 0);
1316 if (mp_data == NULL) {
1317 /* release imported bo */
1318 for (i = 0 ; i < num_buffer_key ; i++)
1319 _camera_release_imported_bo(&buffer_bo[i]);
1321 /* unmap and unref tbm bo */
1322 _camera_release_imported_bo(&data_bo);
1323 _camera_release_imported_bo(&bo);
1326 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1328 /*LOGD("return buffer Done");*/
1333 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1337 muse_camera_msg_get(percent, recv_msg);
1339 LOGD("HDR progress - %d \%", percent);
1341 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1344 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1350 muse_camera_msg_get(policy, recv_msg);
1351 muse_camera_msg_get(previous, recv_msg);
1352 muse_camera_msg_get(current, recv_msg);
1354 LOGW("INTERRUPTED - policy %d, state previous %d, current %d",
1355 policy, previous, current);
1357 if (policy == CAMERA_POLICY_SOUND)
1358 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND is deprecated and will be removed from next release.");
1359 else if (policy == CAMERA_POLICY_SOUND_BY_CALL)
1360 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_CALL is deprecated and will be removed from next release.");
1361 else if (policy == CAMERA_POLICY_SOUND_BY_ALARM)
1362 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_ALARM is deprecated and will be removed from next release.");
1364 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1365 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1368 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1373 muse_camera_msg_get(policy, recv_msg);
1374 muse_camera_msg_get(state, recv_msg);
1376 LOGW("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1378 if (policy == CAMERA_POLICY_SOUND)
1379 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND is deprecated and will be removed from next release.");
1380 else if (policy == CAMERA_POLICY_SOUND_BY_CALL)
1381 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_CALL is deprecated and will be removed from next release.");
1382 else if (policy == CAMERA_POLICY_SOUND_BY_ALARM)
1383 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_ALARM is deprecated and will be removed from next release.");
1385 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1386 (camera_state_e)state, cb_info->user_data[event]);
1389 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1392 camera_detected_face_s *faces = NULL;
1394 muse_camera_msg_get(count, recv_msg);
1395 muse_camera_msg_get(tbm_key, recv_msg);
1398 LOGD("FACE_DETECTION - count %d, tbm_key %d", count, tbm_key);
1402 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
1404 faces = bo_handle.ptr;
1408 ((camera_face_detected_cb)cb_info->user_cb[event])(faces, count, cb_info->user_data[event]);
1411 _camera_release_imported_bo(&bo);
1415 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1416 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1417 /*LOGD("return buffer done");*/
1420 LOGE("invalid message - count %d, key %d", count, tbm_key);
1424 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1427 int current_state = 0;
1429 muse_camera_msg_get(error, recv_msg);
1430 muse_camera_msg_get(current_state, recv_msg);
1432 LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
1434 if (error == CAMERA_ERROR_SOUND_POLICY)
1435 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
1436 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_CALL)
1437 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
1438 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_ALARM)
1439 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
1441 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1442 (camera_state_e)current_state, cb_info->user_data[event]);
1446 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1448 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1449 muse_camera_msg_get(param1, recv_msg);
1450 muse_camera_msg_get(param2, recv_msg);
1452 /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/
1454 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1455 cb_info->user_cb[event] = NULL;
1456 cb_info->user_data[event] = NULL;
1457 LOGW("stop foreach callback for event %d", event);
1460 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1462 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1464 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1466 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1468 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1470 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1472 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1474 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1476 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1478 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1480 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1482 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1484 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1487 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1489 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1490 muse_camera_msg_get(param1, recv_msg);
1492 /*LOGD("event %d SUPPORTED %d ", event, param1);*/
1494 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1495 cb_info->user_cb[event] = NULL;
1496 cb_info->user_data[event] = NULL;
1497 LOGW("stop foreach callback for event %d", event);
1501 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1503 camera_image_data_s *rImage = NULL;
1504 camera_image_data_s *rPostview = NULL;
1505 camera_image_data_s *rThumbnail = NULL;
1506 unsigned char *buf_pos = NULL;
1507 int tbm_key_main = 0;
1508 int tbm_key_post = 0;
1509 int tbm_key_thumb = 0;
1510 tbm_bo bo_main = NULL;
1511 tbm_bo bo_post = NULL;
1512 tbm_bo bo_thumb = NULL;
1513 tbm_bo_handle bo_main_handle = {NULL, };
1514 tbm_bo_handle bo_post_handle = {NULL, };
1515 tbm_bo_handle bo_thumb_handle = {NULL, };
1517 muse_camera_msg_get(tbm_key_main, recv_msg);
1518 muse_camera_msg_get(tbm_key_post, recv_msg);
1519 muse_camera_msg_get(tbm_key_thumb, recv_msg);
1522 LOGD("camera capture callback came in. tbm_key_main %d, tbm_key_post %d, tbm_key_thumb %d",
1523 tbm_key_main, tbm_key_post, tbm_key_thumb);
1526 if (tbm_key_main <= 0) {
1527 LOGE("invalid key %d", tbm_key_main);
1531 /* import tbm bo and get virtual address */
1532 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_main, &bo_main, &bo_main_handle))
1535 buf_pos = (unsigned char *)bo_main_handle.ptr;
1536 rImage = (camera_image_data_s *)buf_pos;
1537 rImage->data = buf_pos + sizeof(camera_image_data_s);
1538 if (rImage->exif && rImage->exif_size > 0) {
1539 rImage->exif = rImage->data + rImage->size;
1541 rImage->exif = NULL;
1542 rImage->exif_size = 0;
1545 LOGD("image info %dx%d, size %d, EXIF info %p, size %d",
1546 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
1548 if (tbm_key_post > 0) {
1549 /* import tbm bo and get virtual address */
1550 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_post, &bo_post, &bo_post_handle))
1553 buf_pos = (unsigned char *)bo_post_handle.ptr;
1554 rPostview = (camera_image_data_s *)buf_pos;
1555 LOGD("rPostview->size : %d", rPostview->size);
1556 rPostview->data = buf_pos + sizeof(camera_image_data_s);
1559 if (tbm_key_thumb > 0) {
1560 /* import tbm bo and get virtual address */
1561 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_thumb, &bo_thumb, &bo_thumb_handle))
1564 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
1566 rThumbnail = (camera_image_data_s *)buf_pos;
1567 LOGD("rThumbnail->size : %d", rThumbnail->size);
1568 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
1571 ((camera_capturing_cb)cb_info->user_cb[event])(rImage, rPostview, rThumbnail, cb_info->user_data[event]);
1573 /* unmap and unref tbm bo */
1574 _camera_release_imported_bo(&bo_main);
1577 tbm_key = tbm_key_main;
1579 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1581 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1583 if (tbm_key_post > 0) {
1584 /* unmap and unref tbm bo */
1585 _camera_release_imported_bo(&bo_post);
1588 param.value.value_INT = tbm_key_post;
1589 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1592 if (tbm_key_thumb > 0) {
1593 /* unmap and unref tbm bo */
1594 _camera_release_imported_bo(&bo_thumb);
1597 param.value.value_INT = tbm_key_thumb;
1598 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1601 LOGD("return buffer done");
1605 LOGW("unhandled event %d", event);
1612 static bool _camera_idle_event_callback(void *data)
1614 camera_cb_info_s *cb_info = NULL;
1615 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1617 if (cam_idle_event == NULL) {
1618 LOGE("cam_idle_event is NULL");
1623 g_mutex_lock(&cam_idle_event->event_mutex);
1625 cb_info = cam_idle_event->cb_info;
1626 if (cb_info == NULL) {
1627 LOGW("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1628 goto IDLE_EVENT_CALLBACK_DONE;
1631 /* remove event from list */
1632 g_mutex_lock(&cb_info->idle_event_mutex);
1634 if (cb_info->idle_event_list)
1635 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1637 /*LOGD("remove camera idle event %p, %p", cam_idle_event, cb_info->idle_event_list);*/
1638 g_mutex_unlock(&cb_info->idle_event_mutex);
1641 _camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
1643 /* send signal for waiting thread */
1644 g_cond_signal(&cb_info->idle_event_cond);
1646 IDLE_EVENT_CALLBACK_DONE:
1647 /* unlock and release event */
1648 g_mutex_unlock(&cam_idle_event->event_mutex);
1649 g_mutex_clear(&cam_idle_event->event_mutex);
1651 g_free(cam_idle_event);
1652 cam_idle_event = NULL;
1657 static void *_camera_msg_handler_func(gpointer data)
1661 camera_message_s *cam_msg = NULL;
1662 camera_idle_event_s *cam_idle_event = NULL;
1663 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1664 camera_cb_info_s *cb_info = NULL;
1666 if (!handler_info || !handler_info->cb_info) {
1667 LOGE("NULL handler %p", handler_info);
1671 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1672 type = handler_info->type;
1674 LOGD("t:%d start", type);
1676 g_mutex_lock(&handler_info->mutex);
1678 while (g_atomic_int_get(&handler_info->running)) {
1679 if (g_queue_is_empty(handler_info->queue)) {
1680 /*LOGD("t:%d signal wait...", type);*/
1681 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1682 /*LOGD("t:%d signal received", type);*/
1684 if (g_atomic_int_get(&handler_info->running) == 0) {
1685 LOGD("t:%d stop event thread", type);
1690 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1692 g_mutex_unlock(&handler_info->mutex);
1694 if (cam_msg == NULL) {
1695 LOGE("t:%d NULL message", type);
1696 g_mutex_lock(&handler_info->mutex);
1702 if (api < MUSE_CAMERA_API_MAX) {
1705 g_mutex_lock(&cb_info->api_mutex[api]);
1707 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1708 if (cb_info->api_waiting[api] > 0) {
1709 cb_info->api_ret[api] = ret;
1710 cb_info->api_activating[api] = 1;
1712 /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
1714 g_cond_signal(&cb_info->api_cond[api]);
1716 LOGW("no waiting for this api [%d]", api);
1719 LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1722 g_mutex_unlock(&cb_info->api_mutex[api]);
1723 } else if (api == MUSE_CAMERA_CB_EVENT) {
1724 switch (cam_msg->event_class) {
1725 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1726 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event);
1728 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1729 cam_idle_event = g_new0(camera_idle_event_s, 1);
1730 if (cam_idle_event == NULL) {
1731 LOGE("t:%d cam_idle_event alloc failed", type);
1735 cam_idle_event->event = cam_msg->event;
1736 cam_idle_event->cb_info = cb_info;
1737 g_mutex_init(&cam_idle_event->event_mutex);
1738 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg) - 1);
1740 /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, cam_msg->event, cam_idle_event);*/
1742 g_mutex_lock(&cb_info->idle_event_mutex);
1743 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1744 g_mutex_unlock(&cb_info->idle_event_mutex);
1746 g_idle_add_full(G_PRIORITY_DEFAULT,
1747 (GSourceFunc)_camera_idle_event_callback,
1748 (gpointer)cam_idle_event,
1752 LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
1756 LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1762 g_mutex_lock(&handler_info->mutex);
1765 /* remove remained event */
1766 while (!g_queue_is_empty(handler_info->queue)) {
1767 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1769 LOGD("t:%d remove camera message %p", type, cam_msg);
1773 LOGW("t:%d NULL camera message", type);
1777 g_mutex_unlock(&handler_info->mutex);
1779 LOGD("t:%d return", type);
1785 static void _camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1787 camera_idle_event_s *cam_idle_event = NULL;
1789 gint64 end_time = 0;
1791 if (cb_info == NULL) {
1792 LOGE("cb_info is NULL");
1796 g_mutex_lock(&cb_info->idle_event_mutex);
1798 if (cb_info->idle_event_list == NULL) {
1799 LOGD("No remained idle event");
1800 g_mutex_unlock(&cb_info->idle_event_mutex);
1804 list = cb_info->idle_event_list;
1807 cam_idle_event = list->data;
1808 list = g_list_next(list);
1810 if (!cam_idle_event) {
1811 LOGW("Fail to remove idle event. The event is NULL");
1815 if (!g_mutex_trylock(&cam_idle_event->event_mutex)) {
1816 LOGW("lock failed, %p event is calling now", cam_idle_event);
1818 end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
1820 if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
1821 LOGW("signal received");
1828 LOGW("set NULL cb_info for event %p %d, it will be freed on idle callback",
1829 cam_idle_event, cam_idle_event->event);
1831 cam_idle_event->cb_info = NULL;
1833 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1835 g_mutex_unlock(&cam_idle_event->event_mutex);
1838 g_list_free(cb_info->idle_event_list);
1839 cb_info->idle_event_list = NULL;
1841 g_mutex_unlock(&cb_info->idle_event_mutex);
1847 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg)
1849 camera_message_s *cam_msg = NULL;
1851 if (!cb_info || !msg) {
1852 LOGE("NULL pointer %p %p", cb_info, msg);
1856 cam_msg = g_new0(camera_message_s, 1);
1858 LOGE("failed to alloc cam_msg for [%s]", msg);
1863 cam_msg->event = event;
1864 cam_msg->event_class = event_class;
1866 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1868 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1870 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1871 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1872 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1873 g_cond_signal(&cb_info->preview_cb_info.cond);
1874 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1875 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1876 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1877 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1878 g_cond_signal(&cb_info->capture_cb_info.cond);
1879 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1881 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1882 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1883 g_cond_signal(&cb_info->msg_handler_info.cond);
1884 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1893 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg)
1895 int ret = CAMERA_ERROR_NONE;
1899 int event_class = -1;
1903 if (!cb_info || !msg) {
1904 LOGE("invalid ptr %p %p", cb_info, msg);
1908 /*LOGD("msg [%s]", msg);*/
1910 if (!muse_camera_msg_get(api, msg)) {
1911 LOGE("failed to get camera api");
1915 if (api == MUSE_CAMERA_CB_EVENT) {
1916 if (!muse_camera_msg_get(event, msg) ||
1917 !muse_camera_msg_get(event_class, msg)) {
1918 LOGE("failed to get camera event or event_class [%s]", msg);
1922 if (!muse_camera_msg_get(api_class, msg)) {
1923 LOGE("failed to get camera api_class [%s]", msg);
1928 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1929 if (api >= MUSE_CAMERA_API_MAX) {
1930 LOGE("invalid api %d", api);
1934 if (!muse_camera_msg_get(ret, msg)) {
1935 LOGE("failed to get camera ret");
1939 g_mutex_lock(&cb_info->api_mutex[api]);
1942 case MUSE_CAMERA_API_CREATE:
1943 if (ret != CAMERA_ERROR_NONE) {
1944 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1945 LOGE("camera create error 0x%x. close client cb handler", ret);
1948 case MUSE_CAMERA_API_DESTROY:
1949 if (ret == CAMERA_ERROR_NONE) {
1950 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1951 LOGD("camera destroy done. close client cb handler");
1955 muse_camera_msg_get(get_type, msg);
1956 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1957 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1958 muse_camera_msg_get(get_index, msg);
1961 case MUSE_CAMERA_GET_TYPE_INT:
1962 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
1964 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1965 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
1966 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
1968 case MUSE_CAMERA_GET_TYPE_ARRAY:
1969 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
1970 muse_core_msg_deserialize("get_value",
1971 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
1972 LOGD("get display roi %d,%d,%dx%d",
1973 cb_info->get_display_roi_area[0],
1974 cb_info->get_display_roi_area[1],
1975 cb_info->get_display_roi_area[2],
1976 cb_info->get_display_roi_area[3]);
1978 muse_core_msg_deserialize("get_value",
1979 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
1980 LOGD("get geotag %lf, %lf, %lf",
1981 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
1984 case MUSE_CAMERA_GET_TYPE_STRING:
1985 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
1988 LOGW("unknown type %d", get_type);
1995 if (cb_info->api_waiting[api] > 0) {
1996 cb_info->api_ret[api] = ret;
1997 cb_info->api_activating[api] = 1;
1999 g_cond_signal(&cb_info->api_cond[api]);
2001 LOGW("no waiting for this api [%d]", api);
2004 g_mutex_unlock(&cb_info->api_mutex[api]);
2005 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
2006 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg);
2008 LOGW("unknown camera api %d, class %d", api, api_class);
2015 static void *_camera_msg_recv_func(gpointer data)
2017 int recv_length = 0;
2018 int single_length = 0;
2019 int remained_length = 0;
2020 char *recv_msg = NULL;
2021 char *single_msg = NULL;
2022 char *remained_msg = NULL;
2026 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
2029 LOGE("cb_info NULL");
2035 single_msg = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
2037 LOGE("single_msg malloc failed");
2041 recv_msg = cb_info->recv_msg;
2043 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
2044 recv_length = muse_core_msg_recv(cb_info->fd, recv_msg);
2045 if (recv_length <= 0) {
2046 cb_info->is_server_connected = FALSE;
2047 LOGE("receive msg failed - server disconnected");
2055 /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
2057 /* Need to split the combined entering msgs */
2058 for (cur_pos = 0 ; cur_pos < recv_length ; cur_pos++) {
2059 if (recv_msg[cur_pos] == '}') {
2060 single_length = cur_pos - prev_pos + 1;
2062 if (single_length < MUSE_CAMERA_MSG_MAX_LENGTH) {
2063 /* check remained msg */
2064 if (remained_length > 0) {
2066 strncpy(single_msg, remained_msg, remained_length);
2067 strncpy(single_msg + remained_length, recv_msg + prev_pos, single_length);
2068 single_msg[remained_length + single_length] = '\0';
2071 remained_msg = NULL;
2073 strncpy(single_msg, recv_msg + prev_pos, single_length);
2074 single_msg[single_length] = '\0';
2075 LOGE("lost msg [%s], skip...", single_msg);
2078 remained_length = 0;
2080 strncpy(single_msg, recv_msg + prev_pos, single_length);
2081 single_msg[single_length] = '\0';
2084 if (single_msg[0] == '{') {
2086 /*LOGD("splitted msg : [%s], Index : %d", single_msg, num_msg);*/
2087 /* process each message */
2088 __camera_process_msg(cb_info, single_msg);
2090 LOGE("invalid msg [%s]", single_msg);
2093 LOGE("too long message [len %d] skip...", single_length);
2096 prev_pos = cur_pos + 1;
2100 /* check incompleted message */
2101 if (recv_msg[recv_length - 1] != '}') {
2102 remained_length = recv_length - prev_pos;
2104 LOGW("incompleted message [len %d]", remained_length);
2106 remained_msg = (char *)malloc(remained_length + 1);
2108 strncpy(remained_msg, recv_msg + prev_pos, remained_length);
2109 remained_msg[remained_length] = '\0';
2111 LOGE("failed to alloc for remained msg");
2114 remained_length = 0;
2118 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
2120 if (!cb_info->is_server_connected) {
2121 /* send error msg for server disconnection */
2122 char *error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
2123 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
2124 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
2128 LOGE("error_msg failed");
2129 goto CB_HANDLER_EXIT;
2132 __camera_add_msg_to_queue(cb_info,
2133 MUSE_CAMERA_CB_EVENT,
2134 MUSE_CAMERA_EVENT_TYPE_ERROR,
2135 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
2138 muse_core_msg_free(error_msg);
2141 LOGE("add error msg for service disconnection done");
2152 remained_msg = NULL;
2159 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2160 int type, const char *thread_name, camera_cb_info_s *cb_info)
2162 if (!handler_info || !thread_name || !cb_info) {
2163 LOGE("t:%d NULL %p %p %p",
2164 type, handler_info, thread_name, cb_info);
2170 handler_info->type = type;
2171 handler_info->queue = g_queue_new();
2172 if (handler_info->queue == NULL) {
2173 LOGE("t:%d queue failed", type);
2177 g_mutex_init(&handler_info->mutex);
2178 g_cond_init(&handler_info->cond);
2180 handler_info->cb_info = (void *)cb_info;
2181 g_atomic_int_set(&handler_info->running, 1);
2183 handler_info->thread = g_thread_try_new(thread_name,
2184 _camera_msg_handler_func, (gpointer)handler_info, NULL);
2185 if (handler_info->thread == NULL) {
2186 LOGE("t:%d thread failed", type);
2188 g_mutex_clear(&handler_info->mutex);
2189 g_cond_clear(&handler_info->cond);
2190 g_queue_free(handler_info->queue);
2191 handler_info->queue = NULL;
2196 LOGD("t:%d done", type);
2202 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2206 if (!handler_info) {
2207 LOGE("NULL handler");
2211 if (!handler_info->thread) {
2212 LOGW("thread is not created");
2216 type = handler_info->type;
2218 LOGD("t:%d thread %p", type, handler_info->thread);
2220 g_mutex_lock(&handler_info->mutex);
2221 g_atomic_int_set(&handler_info->running, 0);
2222 g_cond_signal(&handler_info->cond);
2223 g_mutex_unlock(&handler_info->mutex);
2225 g_thread_join(handler_info->thread);
2226 handler_info->thread = NULL;
2228 g_mutex_clear(&handler_info->mutex);
2229 g_cond_clear(&handler_info->cond);
2230 g_queue_free(handler_info->queue);
2231 handler_info->queue = NULL;
2233 LOGD("t:%d done", type);
2239 static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
2241 camera_cb_info_s *cb_info = NULL;
2244 g_return_val_if_fail(sockfd > 0, NULL);
2246 cb_info = g_new0(camera_cb_info_s, 1);
2247 if (cb_info == NULL) {
2248 LOGE("cb_info failed");
2252 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2254 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2255 g_mutex_init(&cb_info->api_mutex[i]);
2256 g_cond_init(&cb_info->api_cond[i]);
2259 g_mutex_init(&cb_info->fd_lock);
2260 g_mutex_init(&cb_info->idle_event_mutex);
2261 g_cond_init(&cb_info->idle_event_cond);
2262 g_mutex_init(&cb_info->mp_data_mutex);
2263 g_mutex_init(&cb_info->preview_cb_mutex);
2264 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2265 g_mutex_init(&cb_info->evas_mutex);
2266 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2268 /* message handler thread */
2269 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2270 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2271 LOGE("msg_handler_info failed");
2275 /* message handler thread for preview callback */
2276 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2277 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2278 LOGE("preview_cb_info failed");
2282 /* message handler thread for capture callback */
2283 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2284 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2285 LOGE("capture_cb_info failed");
2289 cb_info->fd = sockfd;
2290 cb_info->preview_cb_flag = 0;
2291 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2292 cb_info->evas_info = NULL;
2293 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2295 /* message receive thread */
2296 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2297 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2298 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2299 if (cb_info->msg_recv_thread == NULL) {
2300 LOGE("message receive thread creation failed");
2304 cb_info->is_server_connected = TRUE;
2310 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2311 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2312 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2314 g_mutex_clear(&cb_info->fd_lock);
2315 g_mutex_clear(&cb_info->idle_event_mutex);
2316 g_cond_clear(&cb_info->idle_event_cond);
2317 g_mutex_clear(&cb_info->mp_data_mutex);
2318 g_mutex_clear(&cb_info->preview_cb_mutex);
2319 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2320 g_mutex_clear(&cb_info->evas_mutex);
2321 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2323 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2324 g_mutex_clear(&cb_info->api_mutex[i]);
2325 g_cond_clear(&cb_info->api_cond[i]);
2336 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2340 g_return_if_fail(cb_info != NULL);
2342 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2344 g_thread_join(cb_info->msg_recv_thread);
2345 cb_info->msg_recv_thread = NULL;
2347 LOGD("msg_recv thread removed");
2349 /* destroy msg handler threads */
2350 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2351 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2352 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2354 g_mutex_clear(&cb_info->fd_lock);
2355 g_mutex_clear(&cb_info->idle_event_mutex);
2356 g_cond_clear(&cb_info->idle_event_cond);
2357 g_mutex_clear(&cb_info->mp_data_mutex);
2358 g_mutex_clear(&cb_info->preview_cb_mutex);
2359 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2360 g_mutex_clear(&cb_info->evas_mutex);
2361 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2363 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2364 g_mutex_clear(&cb_info->api_mutex[i]);
2365 g_cond_clear(&cb_info->api_cond[i]);
2368 if (cb_info->fd > -1) {
2369 muse_client_close(cb_info->fd);
2373 if (cb_info->bufmgr) {
2374 tbm_bufmgr_deinit(cb_info->bufmgr);
2375 cb_info->bufmgr = NULL;
2377 if (cb_info->pkt_fmt) {
2378 media_format_unref(cb_info->pkt_fmt);
2379 cb_info->pkt_fmt = NULL;
2382 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2383 if (cb_info->evas_info)
2384 mm_evas_renderer_destroy(&cb_info->evas_info);
2385 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2387 cb_info->preview_cb_flag = 0;
2396 int _camera_start_evas_rendering(camera_h camera)
2398 int ret = CAMERA_ERROR_NONE;
2399 camera_cli_s *pc = (camera_cli_s *)camera;
2401 if (!pc || !pc->cb_info) {
2402 LOGE("NULL handle");
2403 return CAMERA_ERROR_INVALID_PARAMETER;
2408 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2409 LOGE("EVAS surface is not set");
2410 return CAMERA_ERROR_NONE;
2413 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2414 g_mutex_lock(&pc->cb_info->evas_mutex);
2416 /* set evas render flag as RUN */
2417 pc->cb_info->run_evas_render = true;
2418 ret = CAMERA_ERROR_NONE;
2420 g_mutex_unlock(&pc->cb_info->evas_mutex);
2421 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2422 LOGW("evas renderer is not supported");
2423 ret = CAMERA_ERROR_NOT_SUPPORTED;
2424 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2430 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2432 int ret = CAMERA_ERROR_NONE;
2433 camera_cli_s *pc = (camera_cli_s *)camera;
2435 if (!pc || !pc->cb_info) {
2436 LOGE("NULL handle");
2437 return CAMERA_ERROR_INVALID_PARAMETER;
2440 LOGD("stop - keep screen %d", keep_screen);
2442 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2443 LOGE("EVAS surface is not set");
2444 return CAMERA_ERROR_NONE;
2447 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2448 g_mutex_lock(&pc->cb_info->evas_mutex);
2450 /* set evas render flag as STOP and release buffers */
2451 pc->cb_info->run_evas_render = false;
2453 ret = mm_evas_renderer_retrieve_all_packets(pc->cb_info->evas_info, keep_screen);
2454 if (ret != MM_ERROR_NONE) {
2455 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2456 ret = CAMERA_ERROR_INVALID_OPERATION;
2459 g_mutex_unlock(&pc->cb_info->evas_mutex);
2460 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2461 LOGW("evas renderer is not supported");
2462 ret = CAMERA_ERROR_NOT_SUPPORTED;
2463 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2469 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2471 int ret = CAMERA_ERROR_NONE;
2474 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2476 /* create muse connection */
2477 if (!key || !value) {
2478 LOGE("NULL pointer");
2479 return CAMERA_ERROR_INVALID_PARAMETER;
2482 sock_fd = muse_client_new();
2484 LOGE("muse_client_new failed");
2485 return CAMERA_ERROR_INVALID_OPERATION;
2488 msg = muse_core_msg_new(api,
2489 MUSE_TYPE_INT, "module", MUSE_CAMERA,
2490 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2494 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2498 ret = muse_core_msg_send(sock_fd, msg);
2500 muse_core_msg_free(msg);
2504 LOGE("send msg failed");
2505 ret = CAMERA_ERROR_INVALID_OPERATION;
2509 ret = muse_core_msg_recv(sock_fd, recv_msg);
2511 LOGE("recv msg failed %d", errno);
2512 ret = CAMERA_ERROR_INVALID_OPERATION;
2516 if (!muse_camera_msg_get(ret, recv_msg)) {
2517 LOGE("failed to get return value from msg [%s]", recv_msg);
2518 ret = CAMERA_ERROR_INVALID_OPERATION;
2522 if (ret == CAMERA_ERROR_NONE)
2523 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2525 LOGD("api %d - value %d", api, *value);
2529 muse_client_close(sock_fd);
2537 int camera_create(camera_device_e device, camera_h *camera)
2540 char *send_msg = NULL;
2542 int ret = CAMERA_ERROR_NONE;
2544 camera_cli_s *pc = NULL;
2545 tbm_bufmgr bufmgr = NULL;
2547 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2548 muse_core_api_module_e muse_module = MUSE_CAMERA;
2549 int device_type = (int)device;
2552 LOGE("NULL pointer");
2553 return CAMERA_ERROR_INVALID_PARAMETER;
2556 sock_fd = muse_client_new();
2558 LOGE("muse_client_new failed - returned fd %d", sock_fd);
2559 ret = CAMERA_ERROR_INVALID_OPERATION;
2565 send_msg = muse_core_msg_new(api,
2566 MUSE_TYPE_INT, "module", muse_module,
2567 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2568 MUSE_TYPE_INT, "pid", pid,
2573 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2577 send_ret = muse_core_msg_send(sock_fd, send_msg);
2579 muse_core_msg_free(send_msg);
2583 LOGE("send msg failed %d", errno);
2584 ret = CAMERA_ERROR_INVALID_OPERATION;
2588 pc = g_new0(camera_cli_s, 1);
2590 LOGE("camera_cli_s alloc failed");
2591 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2595 bufmgr = tbm_bufmgr_init(-1);
2596 if (bufmgr == NULL) {
2597 LOGE("get tbm bufmgr failed");
2598 ret = CAMERA_ERROR_INVALID_OPERATION;
2602 pc->cb_info = _camera_client_callback_new(sock_fd);
2603 if (pc->cb_info == NULL) {
2604 LOGE("cb_info alloc failed");
2605 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2611 LOGD("cb info : %d", pc->cb_info->fd);
2613 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2615 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2617 if (ret == CAMERA_ERROR_NONE) {
2618 intptr_t handle = 0;
2619 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2621 LOGE("Receiving Handle Failed!!");
2622 ret = CAMERA_ERROR_INVALID_OPERATION;
2626 pc->remote_handle = handle;
2627 pc->cb_info->bufmgr = bufmgr;
2629 ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL);
2630 if (ret != CAMERA_ERROR_NONE) {
2631 LOGE("init display failed 0x%x", ret);
2635 LOGD("camera create 0x%x", pc->remote_handle);
2636 *camera = (camera_h)pc;
2645 tbm_bufmgr_deinit(bufmgr);
2650 muse_client_close(sock_fd);
2656 _camera_client_callback_destroy(pc->cb_info);
2663 LOGE("camera create error : 0x%x", ret);
2670 int camera_change_device(camera_h camera, camera_device_e device)
2673 int ret = CAMERA_ERROR_NONE;
2674 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2675 camera_cli_s *pc = (camera_cli_s *)camera;
2676 camera_msg_param param;
2678 if (!pc || !pc->cb_info) {
2679 LOGE("NULL handle");
2680 return CAMERA_ERROR_INVALID_PARAMETER;
2683 CAMERA_MSG_PARAM_SET(param, INT, device);
2685 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2687 if (ret == CAMERA_ERROR_NONE) {
2688 /* reset callback and user data */
2689 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2690 pc->cb_info->user_cb[i] = NULL;
2691 pc->cb_info->user_data[i] = NULL;
2693 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
2700 int camera_destroy(camera_h camera)
2702 int ret = CAMERA_ERROR_NONE;
2703 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2704 camera_cli_s *pc = (camera_cli_s *)camera;
2706 if (!pc || !pc->cb_info) {
2707 LOGE("NULL handle");
2708 return CAMERA_ERROR_INVALID_PARAMETER;
2713 if (pc->cb_info->is_server_connected)
2714 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2716 LOGW("server disconnected. release resource without send message.");
2718 if (ret == CAMERA_ERROR_NONE) {
2719 _camera_deactivate_idle_event_all(pc->cb_info);
2720 _camera_client_callback_destroy(pc->cb_info);
2730 int camera_start_preview(camera_h camera)
2732 int ret = CAMERA_ERROR_NONE;
2733 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2734 camera_cli_s *pc = (camera_cli_s *)camera;
2736 if (!pc || !pc->cb_info) {
2737 LOGE("NULL handle");
2738 return CAMERA_ERROR_INVALID_PARAMETER;
2743 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2744 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2745 ret = _camera_start_evas_rendering(camera);
2746 if (ret != CAMERA_ERROR_NONE) {
2747 LOGE("stop preview because of error");
2748 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, pc->cb_info, NULL, 0);
2752 LOGD("ret : 0x%x", ret);
2758 int camera_stop_preview(camera_h camera)
2760 int ret = CAMERA_ERROR_NONE;
2761 camera_cli_s *pc = (camera_cli_s *)camera;
2762 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2763 camera_state_e current_state = CAMERA_STATE_NONE;
2765 if (!pc || !pc->cb_info) {
2766 LOGE("NULL handle");
2767 return CAMERA_ERROR_INVALID_PARAMETER;
2773 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2774 ret = camera_get_state(camera, ¤t_state);
2775 if (ret != CAMERA_ERROR_NONE) {
2776 LOGE("failed to get current state 0x%x", ret);
2780 if (current_state == CAMERA_STATE_PREVIEW) {
2781 ret = _camera_stop_evas_rendering(camera, false);
2782 if (ret != CAMERA_ERROR_NONE)
2787 /* send stop preview message */
2788 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2790 if (ret != CAMERA_ERROR_NONE &&
2791 current_state == CAMERA_STATE_PREVIEW) {
2792 LOGW("restart evas rendering");
2793 _camera_start_evas_rendering(camera);
2796 LOGD("ret : 0x%x", ret);
2802 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2804 int ret = CAMERA_ERROR_NONE;
2805 camera_cli_s *pc = (camera_cli_s *)camera;
2806 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2808 if (!pc || !pc->cb_info) {
2809 LOGE("NULL handle");
2810 return CAMERA_ERROR_INVALID_PARAMETER;
2815 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2816 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2818 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2819 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2821 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2823 LOGD("ret : 0x%x", ret);
2829 bool camera_is_supported_continuous_capture(camera_h camera)
2831 int ret = CAMERA_ERROR_NONE;
2832 camera_cli_s *pc = (camera_cli_s *)camera;
2833 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2835 if (!pc || !pc->cb_info) {
2836 LOGE("NULL handle");
2837 return CAMERA_ERROR_INVALID_PARAMETER;
2842 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2845 LOGE("error is occurred 0x%x", ret);
2849 LOGD("ret : %d", ret);
2855 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)
2857 int ret = CAMERA_ERROR_NONE;
2858 camera_cli_s *pc = (camera_cli_s *)camera;
2859 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2860 camera_msg_param param;
2863 if (!pc || !pc->cb_info) {
2864 LOGE("NULL handle");
2865 return CAMERA_ERROR_INVALID_PARAMETER;
2870 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2871 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2873 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2874 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2876 value = (count << 16) | interval;
2877 CAMERA_MSG_PARAM_SET(param, INT, value);
2879 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2881 LOGD("ret : 0x%x", ret);
2887 int camera_stop_continuous_capture(camera_h camera)
2889 int ret = CAMERA_ERROR_NONE;
2890 camera_cli_s *pc = (camera_cli_s *)camera;
2891 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2893 if (!pc || !pc->cb_info) {
2894 LOGE("NULL handle");
2895 return CAMERA_ERROR_INVALID_PARAMETER;
2900 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2902 LOGD("ret : 0x%x", ret);
2908 bool camera_is_supported_face_detection(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_FACE_DETECTION;
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);
2934 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2936 int ret = CAMERA_ERROR_NONE;
2937 camera_cli_s *pc = (camera_cli_s *)camera;
2938 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2940 if (!pc || !pc->cb_info) {
2941 LOGE("NULL handle");
2942 return CAMERA_ERROR_INVALID_PARAMETER;
2947 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2950 LOGE("error is occurred 0x%x", ret);
2954 LOGD("ret : %d", ret);
2960 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2962 int ret = CAMERA_ERROR_NONE;
2963 camera_cli_s *pc = (camera_cli_s *)camera;
2964 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2966 if (!pc || !pc->cb_info) {
2967 LOGE("NULL handle");
2968 return CAMERA_ERROR_INVALID_PARAMETER;
2973 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2976 LOGE("error is occurred 0x%x", ret);
2980 LOGD("ret : %d", ret);
2985 int camera_get_device_count(camera_h camera, int *device_count)
2987 int ret = CAMERA_ERROR_NONE;
2988 camera_cli_s *pc = (camera_cli_s *)camera;
2989 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2991 if (!pc || !pc->cb_info) {
2992 LOGE("NULL handle");
2993 return CAMERA_ERROR_INVALID_PARAMETER;
2998 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3000 if (ret == CAMERA_ERROR_NONE)
3001 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
3003 LOGD("ret : 0x%x", ret);
3008 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
3010 int ret = CAMERA_ERROR_NONE;
3011 camera_cli_s *pc = (camera_cli_s *)camera;
3012 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
3014 if (!pc || !pc->cb_info) {
3015 LOGE("NULL handle");
3016 return CAMERA_ERROR_INVALID_PARAMETER;
3021 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
3022 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
3024 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3026 LOGD("ret : 0x%x", ret);
3031 int camera_stop_face_detection(camera_h camera)
3033 int ret = CAMERA_ERROR_NONE;
3034 camera_cli_s *pc = (camera_cli_s *)camera;
3035 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
3037 if (!pc || !pc->cb_info) {
3038 LOGE("NULL handle");
3039 return CAMERA_ERROR_INVALID_PARAMETER;
3044 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3046 LOGD("ret : 0x%x", ret);
3051 int camera_get_state(camera_h camera, camera_state_e *state)
3053 int ret = CAMERA_ERROR_NONE;
3054 camera_cli_s *pc = (camera_cli_s *)camera;
3055 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
3057 if (!pc || !pc->cb_info || !state) {
3058 LOGE("NULL pointer %p %p", pc, state);
3059 return CAMERA_ERROR_INVALID_PARAMETER;
3064 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3066 if (ret == CAMERA_ERROR_NONE)
3067 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
3069 LOGD("ret : 0x%x", ret);
3074 int camera_start_focusing(camera_h camera, bool continuous)
3076 int ret = CAMERA_ERROR_NONE;
3077 camera_cli_s *pc = (camera_cli_s *)camera;
3078 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
3079 camera_msg_param param;
3080 int is_continuous = (int)continuous;
3082 if (!pc || !pc->cb_info) {
3083 LOGE("NULL handle");
3084 return CAMERA_ERROR_INVALID_PARAMETER;
3089 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
3091 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3093 LOGD("ret : 0x%x", ret);
3098 int camera_cancel_focusing(camera_h camera)
3100 int ret = CAMERA_ERROR_NONE;
3101 camera_cli_s *pc = (camera_cli_s *)camera;
3102 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3104 if (!pc || !pc->cb_info) {
3105 LOGE("NULL handle");
3106 return CAMERA_ERROR_INVALID_PARAMETER;
3109 LOGD("Enter, remote_handle : %x", pc->remote_handle);
3111 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3113 LOGD("ret : 0x%x", ret);
3118 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3120 int ret = CAMERA_ERROR_NONE;
3121 void *set_display_handle = NULL;
3122 Evas_Object *obj = NULL;
3123 const char *object_type = NULL;
3124 camera_cli_s *pc = (camera_cli_s *)camera;
3125 camera_cb_info_s *cb_info = NULL;
3126 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3127 camera_state_e current_state = CAMERA_STATE_NONE;
3128 camera_msg_param param;
3132 if (!pc || !pc->cb_info) {
3133 LOGE("NULL handle");
3134 return CAMERA_ERROR_INVALID_PARAMETER;
3137 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
3138 LOGE("invalid type %d", type);
3139 return CAMERA_ERROR_INVALID_PARAMETER;
3142 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
3143 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
3144 return CAMERA_ERROR_INVALID_PARAMETER;
3147 cb_info = (camera_cb_info_s *)pc->cb_info;
3149 ret = camera_get_state(camera, ¤t_state);
3150 if (ret != CAMERA_ERROR_NONE) {
3151 LOGE("failed to get current state 0x%x", ret);
3155 if (current_state != CAMERA_STATE_CREATED) {
3156 LOGE("INVALID_STATE : current %d", current_state);
3157 return CAMERA_ERROR_INVALID_STATE;
3160 LOGD("Enter - display : %p", display);
3162 if (type == CAMERA_DISPLAY_TYPE_NONE) {
3163 set_display_handle = 0;
3164 LOGD("display type NONE");
3167 obj = (Evas_Object *)display;
3168 object_type = evas_object_type_get(obj);
3170 if (type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
3171 /* get wayland parent id */
3172 if (_camera_get_wl_info(obj, &pc->wl_info) != CAMERA_ERROR_NONE) {
3173 LOGE("failed to get wayland info");
3174 return CAMERA_ERROR_INVALID_OPERATION;
3177 set_display_handle = (void *)&pc->wl_info;
3178 LOGD("display type OVERLAY : handle %p", set_display_handle);
3179 } else if (type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
3180 /* evas object surface */
3181 set_display_handle = (void *)display;
3182 LOGD("display type EVAS : handle %p", set_display_handle);
3184 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3185 g_mutex_lock(&cb_info->evas_mutex);
3187 if (cb_info->evas_info) {
3188 LOGW("destroy existed evas renderer %p", cb_info->evas_info);
3189 ret = mm_evas_renderer_destroy(&cb_info->evas_info);
3190 if (ret != MM_ERROR_NONE) {
3191 LOGE("failed to destroy evas renderer %p", cb_info->evas_info);
3192 g_mutex_unlock(&cb_info->evas_mutex);
3193 return CAMERA_ERROR_INVALID_OPERATION;
3197 /* create evas renderer */
3198 ret = mm_evas_renderer_create(&cb_info->evas_info, (Evas_Object *)set_display_handle);
3199 if (ret == MM_ERROR_NONE) {
3200 camera_flip_e flip = CAMERA_FLIP_NONE;
3201 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3202 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3209 camera_get_display_flip(camera, &flip);
3210 camera_get_display_mode(camera, &mode);
3211 camera_get_display_rotation(camera, &rotation);
3212 camera_is_display_visible(camera, &visible);
3213 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3215 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
3216 flip, mode, rotation, visible, x, y, width, height);
3218 ret = mm_evas_renderer_set_flip(cb_info->evas_info, flip);
3219 ret |= mm_evas_renderer_set_geometry(cb_info->evas_info, mode);
3220 ret |= mm_evas_renderer_set_rotation(cb_info->evas_info, rotation);
3221 ret |= mm_evas_renderer_set_visible(cb_info->evas_info, visible);
3223 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
3224 ret |= mm_evas_renderer_set_roi_area(cb_info->evas_info, x, y, width, height);
3227 g_mutex_unlock(&cb_info->evas_mutex);
3229 if (ret != MM_ERROR_NONE) {
3230 LOGE("mm_evas_renderer error 0x%x", ret);
3231 return CAMERA_ERROR_INVALID_OPERATION;
3233 #else /* TIZEN_FEATURE_EVAS_RENDERER */
3234 LOGE("EVAS surface is not supported");
3235 return CAMERA_ERROR_NOT_SUPPORTED;
3236 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3238 LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type);
3239 return CAMERA_ERROR_INVALID_PARAMETER;
3242 LOGE("failed to get evas object type from %p", obj);
3243 return CAMERA_ERROR_INVALID_PARAMETER;
3247 pc->display_handle = (intptr_t)set_display_handle;
3249 if (type == CAMERA_DISPLAY_TYPE_OVERLAY) {
3252 length = sizeof(camera_wl_info_s) / sizeof(int) + \
3253 (sizeof(camera_wl_info_s) % sizeof(int) ? 1 : 0);
3255 msg = muse_core_msg_new(api,
3256 MUSE_TYPE_INT, "type", type,
3257 MUSE_TYPE_ARRAY, "wl_info", length, (int *)&pc->wl_info,
3260 LOGE("msg creation failed: api %d", api);
3261 return CAMERA_ERROR_OUT_OF_MEMORY;
3264 if (pc->cb_info->is_server_connected) {
3265 __camera_update_api_waiting(pc->cb_info, api, 1);
3267 g_mutex_lock(&pc->cb_info->fd_lock);
3268 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
3269 g_mutex_unlock(&pc->cb_info->fd_lock);
3273 LOGE("message send failed");
3274 ret = CAMERA_ERROR_INVALID_OPERATION;
3276 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
3279 __camera_update_api_waiting(pc->cb_info, api, -1);
3281 muse_core_msg_free(msg);
3283 LOGD("wayland parent id : %d, window %d,%d,%dx%d",
3284 pc->wl_info.parent_id, pc->wl_info.window_x, pc->wl_info.window_y,
3285 pc->wl_info.window_width, pc->wl_info.window_height);
3287 CAMERA_MSG_PARAM_SET(param, INT, type);
3289 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3292 if (ret != CAMERA_ERROR_NONE)
3293 LOGE("set display error 0x%x", ret);
3294 else if (type == CAMERA_DISPLAY_TYPE_EVAS)
3295 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3301 int camera_set_preview_resolution(camera_h camera, int width, int height)
3303 int ret = CAMERA_ERROR_NONE;
3304 camera_state_e current_state = CAMERA_STATE_NONE;
3305 camera_cli_s *pc = (camera_cli_s *)camera;
3306 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3307 camera_msg_param param;
3310 if (!pc || !pc->cb_info) {
3311 LOGE("NULL handle");
3312 return CAMERA_ERROR_INVALID_PARAMETER;
3315 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3316 ret = camera_get_state(camera, ¤t_state);
3317 if (ret != CAMERA_ERROR_NONE) {
3318 LOGE("failed to get current state 0x%x", ret);
3322 if (current_state == CAMERA_STATE_PREVIEW) {
3323 ret = _camera_stop_evas_rendering(camera, true);
3324 if (ret != CAMERA_ERROR_NONE)
3329 value = (width << 16) | height;
3330 CAMERA_MSG_PARAM_SET(param, INT, value);
3332 LOGD("%dx%d -> 0x%x", width, height, value);
3334 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3336 LOGD("ret : 0x%x", ret);
3338 if (current_state == CAMERA_STATE_PREVIEW) {
3339 LOGW("restart evas rendering");
3340 _camera_start_evas_rendering(camera);
3347 int camera_set_capture_resolution(camera_h camera, int width, int height)
3349 int ret = CAMERA_ERROR_NONE;
3350 camera_cli_s *pc = (camera_cli_s *)camera;
3351 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3352 camera_msg_param param;
3355 if (!pc || !pc->cb_info) {
3356 LOGE("NULL handle");
3357 return CAMERA_ERROR_INVALID_PARAMETER;
3362 value = (width << 16) | height;
3363 CAMERA_MSG_PARAM_SET(param, INT, value);
3365 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3367 LOGD("ret : 0x%x", ret);
3373 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3375 int ret = CAMERA_ERROR_NONE;
3376 int set_format = (int)format;
3377 camera_cli_s *pc = (camera_cli_s *)camera;
3378 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3379 camera_msg_param param;
3381 if (!pc || !pc->cb_info) {
3382 LOGE("NULL handle");
3383 return CAMERA_ERROR_INVALID_PARAMETER;
3386 LOGD("Enter - format %d", set_format);
3388 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3390 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3392 LOGD("ret : 0x%x", ret);
3398 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3400 int ret = CAMERA_ERROR_NONE;
3401 int set_format = (int)format;
3402 camera_msg_param param;
3403 camera_cli_s *pc = (camera_cli_s *)camera;
3404 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3406 if (!pc || !pc->cb_info) {
3407 LOGE("NULL handle");
3408 return CAMERA_ERROR_INVALID_PARAMETER;
3411 LOGD("Enter - capture_format %d", set_format);
3413 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3415 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3417 LOGD("ret : 0x%x", ret);
3423 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3425 int ret = CAMERA_ERROR_NONE;
3426 camera_cli_s *pc = (camera_cli_s *)camera;
3427 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3429 if (!pc || !pc->cb_info || !width || !height) {
3430 LOGE("NULL pointer %p %p %p", pc, width, height);
3431 return CAMERA_ERROR_INVALID_PARAMETER;
3436 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3438 if (ret == CAMERA_ERROR_NONE) {
3439 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3440 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3443 LOGD("ret : 0x%x", ret);
3449 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3451 int ret = CAMERA_ERROR_NONE;
3452 int set_rotation = (int)rotation;
3453 camera_cli_s *pc = (camera_cli_s *)camera;
3454 camera_msg_param param;
3456 if (!pc || !pc->cb_info) {
3457 LOGE("NULL handle");
3458 return CAMERA_ERROR_INVALID_PARAMETER;
3461 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3462 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3463 g_mutex_lock(&pc->cb_info->evas_mutex);
3465 ret = mm_evas_renderer_set_rotation(pc->cb_info->evas_info, rotation);
3467 g_mutex_unlock(&pc->cb_info->evas_mutex);
3469 if (ret != MM_ERROR_NONE) {
3470 LOGE("failed to set rotation for evas surface 0x%x", ret);
3471 return CAMERA_ERROR_INVALID_OPERATION;
3474 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3476 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3478 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3484 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3486 int ret = CAMERA_ERROR_NONE;
3487 camera_cli_s *pc = (camera_cli_s *)camera;
3489 if (!pc || !pc->cb_info || !rotation) {
3490 LOGE("NULL pointer %p %p", pc, rotation);
3491 return CAMERA_ERROR_INVALID_PARAMETER;
3494 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3496 if (ret == CAMERA_ERROR_NONE)
3497 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3503 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3505 int ret = CAMERA_ERROR_NONE;
3506 int set_flip = (int)flip;
3507 camera_cli_s *pc = (camera_cli_s *)camera;
3508 camera_msg_param param;
3510 if (!pc || !pc->cb_info) {
3511 LOGE("NULL handle");
3512 return CAMERA_ERROR_INVALID_PARAMETER;
3515 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3516 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3517 g_mutex_lock(&pc->cb_info->evas_mutex);
3519 ret = mm_evas_renderer_set_flip(pc->cb_info->evas_info, flip);
3521 g_mutex_unlock(&pc->cb_info->evas_mutex);
3523 if (ret != MM_ERROR_NONE) {
3524 LOGE("failed to set flip for evas surface 0x%x", ret);
3525 return CAMERA_ERROR_INVALID_OPERATION;
3528 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3530 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3532 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3538 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3540 int ret = CAMERA_ERROR_NONE;
3541 camera_cli_s *pc = (camera_cli_s *)camera;
3543 if (!pc || !pc->cb_info || !flip) {
3544 LOGE("NULL pointer %p %p", pc, flip);
3545 return CAMERA_ERROR_INVALID_PARAMETER;
3548 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3550 if (ret == CAMERA_ERROR_NONE)
3551 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3557 int camera_set_display_visible(camera_h camera, bool visible)
3559 int ret = CAMERA_ERROR_NONE;
3560 int set_visible = (int)visible;
3561 camera_cli_s *pc = (camera_cli_s *)camera;
3562 camera_msg_param param;
3564 if (!pc || !pc->cb_info) {
3565 LOGE("NULL handle");
3566 return CAMERA_ERROR_INVALID_PARAMETER;
3569 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3570 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3571 g_mutex_lock(&pc->cb_info->evas_mutex);
3573 ret = mm_evas_renderer_set_visible(pc->cb_info->evas_info, visible);
3575 g_mutex_unlock(&pc->cb_info->evas_mutex);
3577 if (ret != MM_ERROR_NONE) {
3578 LOGE("failed to set visible for evas surface 0x%x", ret);
3579 return CAMERA_ERROR_INVALID_OPERATION;
3582 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3584 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3586 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3592 int camera_is_display_visible(camera_h camera, bool *visible)
3594 int ret = CAMERA_ERROR_NONE;
3595 camera_cli_s *pc = (camera_cli_s *)camera;
3597 if (!pc || !pc->cb_info || !visible) {
3598 LOGE("NULL pointer %p %p", pc, visible);
3599 return CAMERA_ERROR_INVALID_PARAMETER;
3602 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3604 if (ret == CAMERA_ERROR_NONE)
3605 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3611 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3613 int ret = CAMERA_ERROR_NONE;
3614 int set_mode = (int)mode;
3615 camera_cli_s *pc = (camera_cli_s *)camera;
3616 camera_msg_param param;
3618 if (!pc || !pc->cb_info) {
3619 LOGE("NULL handle");
3620 return CAMERA_ERROR_INVALID_PARAMETER;
3623 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3624 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3625 g_mutex_lock(&pc->cb_info->evas_mutex);
3627 ret = mm_evas_renderer_set_geometry(pc->cb_info->evas_info, mode);
3629 g_mutex_unlock(&pc->cb_info->evas_mutex);
3631 if (ret != MM_ERROR_NONE) {
3632 LOGE("failed to set geometry for evas surface 0x%x", ret);
3633 return CAMERA_ERROR_INVALID_OPERATION;
3636 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3638 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3640 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3646 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3648 int ret = CAMERA_ERROR_NONE;
3649 camera_cli_s *pc = (camera_cli_s *)camera;
3651 if (!pc || !pc->cb_info || !mode) {
3652 LOGE("NULL pointer %p %p", pc, mode);
3653 return CAMERA_ERROR_INVALID_PARAMETER;
3656 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3658 if (ret == CAMERA_ERROR_NONE)
3659 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3665 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3667 int ret = CAMERA_ERROR_NONE;
3668 int set_hint = (int)hint;
3669 camera_cli_s *pc = (camera_cli_s *)camera;
3670 camera_msg_param param;
3672 if (!pc || !pc->cb_info) {
3673 LOGE("NULL handle");
3674 return CAMERA_ERROR_INVALID_PARAMETER;
3677 LOGD("Enter - hint %d", set_hint);
3679 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3681 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3687 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3689 int ret = CAMERA_ERROR_NONE;
3690 camera_cli_s *pc = (camera_cli_s *)camera;
3691 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3693 if (!pc || !pc->cb_info || !hint) {
3694 LOGE("NULL pointer %p %p", pc, hint);
3695 return CAMERA_ERROR_INVALID_PARAMETER;
3698 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3700 if (ret == CAMERA_ERROR_NONE) {
3701 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3702 LOGD("display reuse hint %d", *hint);
3709 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3711 int ret = CAMERA_ERROR_NONE;
3712 camera_cli_s *pc = (camera_cli_s *)camera;
3713 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3715 if (!pc || !pc->cb_info || !width || !height) {
3716 LOGE("NULL pointer %p %p %p", pc, width, height);
3717 return CAMERA_ERROR_INVALID_PARAMETER;
3722 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3724 if (ret == CAMERA_ERROR_NONE) {
3725 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3726 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3729 LOGD("ret : 0x%x", ret);
3735 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3737 int ret = CAMERA_ERROR_NONE;
3738 camera_cli_s *pc = (camera_cli_s *)camera;
3739 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3741 if (!pc || !pc->cb_info || !format) {
3742 LOGE("NULL pointer %p %p", pc, format);
3743 return CAMERA_ERROR_INVALID_PARAMETER;
3748 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3750 if (ret == CAMERA_ERROR_NONE)
3751 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3753 LOGD("ret : 0x%x", ret);
3759 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3761 int ret = CAMERA_ERROR_NONE;
3762 camera_cli_s *pc = (camera_cli_s *)camera;
3763 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3765 if (!pc || !pc->cb_info || !format) {
3766 LOGE("NULL pointer %p %p", pc, format);
3767 return CAMERA_ERROR_INVALID_PARAMETER;
3772 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3774 if (ret == CAMERA_ERROR_NONE)
3775 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3777 LOGD("ret : 0x%x", ret);
3783 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3785 int ret = CAMERA_ERROR_NONE;
3786 camera_cli_s *pc = (camera_cli_s *)camera;
3787 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3789 if (!pc || !pc->cb_info || !facing_direction) {
3790 LOGE("NULL pointer %p %p", pc, facing_direction);
3791 return CAMERA_ERROR_INVALID_PARAMETER;
3796 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3798 if (ret == CAMERA_ERROR_NONE)
3799 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3801 LOGD("ret : 0x%x", ret);
3807 int camera_set_preview_cb(camera_h camera, camera_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_PREVIEW_CB;
3813 if (!pc || !pc->cb_info || !callback) {
3814 LOGE("NULL pointer %p %p", pc, callback);
3815 return CAMERA_ERROR_INVALID_PARAMETER;
3820 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3822 if (ret == CAMERA_ERROR_NONE) {
3823 g_mutex_lock(&pc->cb_info->preview_cb_mutex);
3825 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3826 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3828 g_mutex_unlock(&pc->cb_info->preview_cb_mutex);
3830 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3833 LOGD("ret : 0x%x", ret);
3839 int camera_unset_preview_cb(camera_h camera)
3841 int ret = CAMERA_ERROR_NONE;
3842 camera_cli_s *pc = (camera_cli_s *)camera;
3843 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3845 if (!pc || !pc->cb_info) {
3846 LOGE("NULL handle");
3847 return CAMERA_ERROR_INVALID_PARAMETER;
3852 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3854 if (ret == CAMERA_ERROR_NONE) {
3855 g_mutex_lock(&pc->cb_info->preview_cb_mutex);
3857 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3858 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3860 g_mutex_unlock(&pc->cb_info->preview_cb_mutex);
3862 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3865 LOGD("ret : 0x%x", ret);
3871 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3873 int ret = CAMERA_ERROR_NONE;
3874 camera_cli_s *pc = (camera_cli_s *)camera;
3875 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3877 if (!pc || !pc->cb_info) {
3878 LOGE("NULL handle");
3879 return CAMERA_ERROR_INVALID_PARAMETER;
3882 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3883 LOGE("NOT SUPPORTED");
3884 return CAMERA_ERROR_NOT_SUPPORTED;
3887 if (callback == NULL) {
3888 LOGE("NULL callback");
3889 return CAMERA_ERROR_INVALID_PARAMETER;
3894 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3896 if (ret == CAMERA_ERROR_NONE) {
3897 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3898 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3901 LOGD("ret : 0x%x", ret);
3907 int camera_unset_media_packet_preview_cb(camera_h camera)
3909 int ret = CAMERA_ERROR_NONE;
3910 camera_cli_s *pc = (camera_cli_s *)camera;
3911 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3913 if (!pc || !pc->cb_info) {
3914 LOGE("NULL handle");
3915 return CAMERA_ERROR_INVALID_PARAMETER;
3920 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3922 if (ret == CAMERA_ERROR_NONE) {
3923 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3924 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3927 LOGD("ret : 0x%x", ret);
3933 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3935 int ret = CAMERA_ERROR_NONE;
3936 camera_cli_s *pc = (camera_cli_s *)camera;
3937 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3939 if (!pc || !pc->cb_info || !callback) {
3940 LOGE("NULL pointer %p %p", pc, callback);
3941 return CAMERA_ERROR_INVALID_PARAMETER;
3946 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3948 if (ret == CAMERA_ERROR_NONE) {
3949 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3950 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3953 LOGD("ret : 0x%x", ret);
3959 int camera_unset_state_changed_cb(camera_h camera)
3961 int ret = CAMERA_ERROR_NONE;
3962 camera_cli_s *pc = (camera_cli_s *)camera;
3963 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3965 if (!pc || !pc->cb_info) {
3966 LOGE("NULL handle");
3967 return CAMERA_ERROR_INVALID_PARAMETER;
3972 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3974 if (ret == CAMERA_ERROR_NONE) {
3975 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3976 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3979 LOGD("ret : 0x%x", ret);
3985 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3987 int ret = CAMERA_ERROR_NONE;
3988 camera_cli_s *pc = (camera_cli_s *)camera;
3989 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3991 if (!pc || !pc->cb_info || !callback) {
3992 LOGE("NULL pointer %p %p", pc, callback);
3993 return CAMERA_ERROR_INVALID_PARAMETER;
3998 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4000 if (ret == CAMERA_ERROR_NONE) {
4001 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
4002 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
4005 LOGD("ret : 0x%x", ret);
4011 int camera_unset_interrupted_cb(camera_h camera)
4013 int ret = CAMERA_ERROR_NONE;
4014 camera_cli_s *pc = (camera_cli_s *)camera;
4015 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
4017 if (!pc || !pc->cb_info) {
4018 LOGE("NULL handle");
4019 return CAMERA_ERROR_INVALID_PARAMETER;
4024 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4026 if (ret == CAMERA_ERROR_NONE) {
4027 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
4028 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
4031 LOGD("ret : 0x%x", ret);
4037 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
4039 int ret = CAMERA_ERROR_NONE;
4040 camera_cli_s *pc = (camera_cli_s *)camera;
4041 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
4043 if (!pc || !pc->cb_info || !callback) {
4044 LOGE("NULL pointer %p %p", pc, callback);
4045 return CAMERA_ERROR_INVALID_PARAMETER;
4050 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4052 if (ret == CAMERA_ERROR_NONE) {
4053 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
4054 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
4057 LOGD("ret : 0x%x", ret);
4063 int camera_unset_interrupt_started_cb(camera_h camera)
4065 int ret = CAMERA_ERROR_NONE;
4066 camera_cli_s *pc = (camera_cli_s *)camera;
4067 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
4069 if (!pc || !pc->cb_info) {
4070 LOGE("NULL handle");
4071 return CAMERA_ERROR_INVALID_PARAMETER;
4076 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4078 if (ret == CAMERA_ERROR_NONE) {
4079 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4080 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
4083 LOGD("ret : 0x%x", ret);
4089 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
4091 int ret = CAMERA_ERROR_NONE;
4092 camera_cli_s *pc = (camera_cli_s *)camera;
4093 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
4095 if (!pc || !pc->cb_info || !callback) {
4096 LOGE("NULL pointer %p %p", pc, callback);
4097 return CAMERA_ERROR_INVALID_PARAMETER;
4102 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4104 if (ret == CAMERA_ERROR_NONE) {
4105 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
4106 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
4109 LOGD("ret : 0x%x", ret);
4115 int camera_unset_focus_changed_cb(camera_h camera)
4117 int ret = CAMERA_ERROR_NONE;
4118 camera_cli_s *pc = (camera_cli_s *)camera;
4119 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
4121 if (!pc || !pc->cb_info) {
4122 LOGE("NULL handle");
4123 return CAMERA_ERROR_INVALID_PARAMETER;
4128 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4130 if (ret == CAMERA_ERROR_NONE) {
4131 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4132 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
4135 LOGD("ret : 0x%x", ret);
4141 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
4143 int ret = CAMERA_ERROR_NONE;
4144 camera_cli_s *pc = (camera_cli_s *)camera;
4145 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
4147 if (!pc || !pc->cb_info || !callback) {
4148 LOGE("NULL pointer %p %p", pc, callback);
4149 return CAMERA_ERROR_INVALID_PARAMETER;
4154 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4156 if (ret == CAMERA_ERROR_NONE) {
4157 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4158 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4161 LOGD("ret : 0x%x", ret);
4167 int camera_unset_error_cb(camera_h camera)
4169 int ret = CAMERA_ERROR_NONE;
4170 camera_cli_s *pc = (camera_cli_s *)camera;
4171 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4173 if (!pc || !pc->cb_info) {
4174 LOGE("NULL handle");
4175 return CAMERA_ERROR_INVALID_PARAMETER;
4180 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4182 if (ret == CAMERA_ERROR_NONE) {
4183 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4184 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4187 LOGD("ret : 0x%x", ret);
4193 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4195 int ret = CAMERA_ERROR_NONE;
4196 camera_cli_s *pc = (camera_cli_s *)camera;
4197 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4199 if (!pc || !pc->cb_info || !foreach_cb) {
4200 LOGE("NULL pointer %p %p", pc, foreach_cb);
4201 return CAMERA_ERROR_INVALID_PARAMETER;
4206 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4207 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4209 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4211 LOGD("ret : 0x%x", ret);
4217 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4219 int ret = CAMERA_ERROR_NONE;
4220 camera_cli_s *pc = (camera_cli_s *)camera;
4221 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4223 if (!pc || !pc->cb_info || !foreach_cb) {
4224 LOGE("NULL pointer %p %p", pc, foreach_cb);
4225 return CAMERA_ERROR_INVALID_PARAMETER;
4230 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4231 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4233 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4235 LOGD("ret : 0x%x", ret);
4241 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4243 int ret = CAMERA_ERROR_NONE;
4244 camera_cli_s *pc = (camera_cli_s *)camera;
4245 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4247 if (!pc || !pc->cb_info || !foreach_cb) {
4248 LOGE("NULL pointer %p %p", pc, foreach_cb);
4249 return CAMERA_ERROR_INVALID_PARAMETER;
4254 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4255 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4257 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4259 LOGD("ret : 0x%x", ret);
4265 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4267 int ret = CAMERA_ERROR_NONE;
4268 camera_cli_s *pc = (camera_cli_s *)camera;
4269 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4271 if (!pc || !pc->cb_info || !foreach_cb) {
4272 LOGE("NULL pointer %p %p", pc, foreach_cb);
4273 return CAMERA_ERROR_INVALID_PARAMETER;
4278 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4279 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4281 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4283 LOGD("ret : 0x%x", ret);
4289 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4291 int ret = CAMERA_ERROR_NONE;
4292 camera_cli_s *pc = (camera_cli_s *)camera;
4293 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4295 if (!pc || !pc->cb_info || !width || !height) {
4296 LOGE("NULL pointer %p %p %p", pc, width, height);
4297 return CAMERA_ERROR_INVALID_PARAMETER;
4301 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4303 if (ret == CAMERA_ERROR_NONE) {
4304 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4305 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4308 LOGD("ret : 0x%x", ret);
4314 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4316 int ret = CAMERA_ERROR_NONE;
4317 camera_cli_s *pc = (camera_cli_s *)camera;
4318 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4320 if (!pc || !pc->cb_info || !angle) {
4321 LOGE("NULL pointer %p %p", pc, angle);
4322 return CAMERA_ERROR_INVALID_PARAMETER;
4327 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4329 if (ret == CAMERA_ERROR_NONE)
4330 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4332 LOGD("ret : 0x%x", ret);
4338 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4340 int ret = CAMERA_ERROR_NONE;
4341 camera_cli_s *pc = (camera_cli_s *)camera;
4342 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4343 camera_msg_param param;
4344 int set_mode = (int)mode;
4346 if (!pc || !pc->cb_info) {
4347 LOGE("NULL handle");
4348 return CAMERA_ERROR_INVALID_PARAMETER;
4353 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4355 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4357 LOGD("ret : 0x%x", ret);
4363 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4365 int ret = CAMERA_ERROR_NONE;
4366 camera_cli_s *pc = (camera_cli_s *)camera;
4367 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4369 if (!pc || !pc->cb_info || !mode) {
4370 LOGE("NULL pointer %p %p", pc, mode);
4371 return CAMERA_ERROR_INVALID_PARAMETER;
4376 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4378 if (ret == CAMERA_ERROR_NONE)
4379 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4381 LOGD("ret : 0x%x", ret);
4387 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4389 int ret = CAMERA_ERROR_NONE;
4390 camera_cli_s *pc = (camera_cli_s *)camera;
4391 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4393 if (!pc || !pc->cb_info || !foreach_cb) {
4394 LOGE("NULL pointer %p %p", pc, foreach_cb);
4395 return CAMERA_ERROR_INVALID_PARAMETER;
4400 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4401 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4403 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4405 LOGD("Finish, return :%x", ret);
4411 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4413 int ret = CAMERA_ERROR_NONE;
4414 camera_cli_s *pc = (camera_cli_s *)camera;
4415 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4416 camera_msg_param param;
4417 int set_fps = (int)fps;
4419 if (!pc || !pc->cb_info) {
4420 LOGE("NULL handle");
4421 return CAMERA_ERROR_INVALID_PARAMETER;
4426 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4428 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4430 LOGD("ret : 0x%x", ret);
4436 int camera_attr_set_image_quality(camera_h camera, int quality)
4438 int ret = CAMERA_ERROR_NONE;
4439 camera_cli_s *pc = (camera_cli_s *)camera;
4440 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4441 camera_msg_param param;
4443 if (!pc || !pc->cb_info) {
4444 LOGE("NULL handle");
4445 return CAMERA_ERROR_INVALID_PARAMETER;
4450 CAMERA_MSG_PARAM_SET(param, INT, quality);
4452 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4454 LOGD("ret : 0x%x", ret);
4460 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4462 int ret = CAMERA_ERROR_NONE;
4463 camera_cli_s *pc = (camera_cli_s *)camera;
4464 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4466 if (!pc || !pc->cb_info || !fps) {
4467 LOGE("NULL pointer %p %p", pc, fps);
4468 return CAMERA_ERROR_INVALID_PARAMETER;
4473 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4475 if (ret == CAMERA_ERROR_NONE)
4476 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4478 LOGD("ret : 0x%x", ret);
4484 int camera_attr_get_image_quality(camera_h camera, int *quality)
4486 int ret = CAMERA_ERROR_NONE;
4487 camera_cli_s *pc = (camera_cli_s *)camera;
4488 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4490 if (!pc || !pc->cb_info || !quality) {
4491 LOGE("NULL pointer %p %p", pc, quality);
4492 return CAMERA_ERROR_INVALID_PARAMETER;
4497 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4499 if (ret == CAMERA_ERROR_NONE)
4500 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4502 LOGD("ret : 0x%x", ret);
4508 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4510 int ret = CAMERA_ERROR_NONE;
4511 camera_cli_s *pc = (camera_cli_s *)camera;
4512 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4514 if (!pc || !pc->cb_info || !bitrate) {
4515 LOGE("NULL pointer %p %p", pc, bitrate);
4516 return CAMERA_ERROR_INVALID_PARAMETER;
4521 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4523 if (ret == CAMERA_ERROR_NONE)
4524 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4526 LOGD("ret : 0x%x", ret);
4532 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4534 int ret = CAMERA_ERROR_NONE;
4535 camera_cli_s *pc = (camera_cli_s *)camera;
4536 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4537 camera_msg_param param;
4538 int set_bitrate = bitrate;
4540 if (!pc || !pc->cb_info) {
4541 LOGE("NULL handle");
4542 return CAMERA_ERROR_INVALID_PARAMETER;
4547 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4549 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4551 LOGD("ret : 0x%x", ret);
4557 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4559 int ret = CAMERA_ERROR_NONE;
4560 camera_cli_s *pc = (camera_cli_s *)camera;
4561 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4563 if (!pc || !pc->cb_info || !interval) {
4564 LOGE("NULL pointer %p %p", pc, interval);
4565 return CAMERA_ERROR_INVALID_PARAMETER;
4570 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4572 if (ret == CAMERA_ERROR_NONE)
4573 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4575 LOGD("ret : 0x%x", ret);
4581 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4583 int ret = CAMERA_ERROR_NONE;
4584 camera_cli_s *pc = (camera_cli_s *)camera;
4585 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4586 camera_msg_param param;
4587 int set_gop_interval = interval;
4589 if (!pc || !pc->cb_info) {
4590 LOGE("NULL handle");
4591 return CAMERA_ERROR_INVALID_PARAMETER;
4596 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4598 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4600 LOGD("ret : 0x%x", ret);
4606 int camera_attr_set_zoom(camera_h camera, int zoom)
4608 int ret = CAMERA_ERROR_NONE;
4609 camera_cli_s *pc = (camera_cli_s *)camera;
4610 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4611 camera_msg_param param;
4613 if (!pc || !pc->cb_info) {
4614 LOGE("NULL handle");
4615 return CAMERA_ERROR_INVALID_PARAMETER;
4618 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4620 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4622 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4624 LOGD("ret : 0x%x", ret);
4630 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4632 int ret = CAMERA_ERROR_NONE;
4633 camera_cli_s *pc = (camera_cli_s *)camera;
4634 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4635 camera_msg_param param;
4636 int set_mode = (int)mode;
4638 if (!pc || !pc->cb_info) {
4639 LOGE("NULL handle");
4640 return CAMERA_ERROR_INVALID_PARAMETER;
4643 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4645 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4647 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4653 int camera_attr_set_af_area(camera_h camera, int x, int y)
4655 int ret = CAMERA_ERROR_NONE;
4656 camera_cli_s *pc = (camera_cli_s *)camera;
4657 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4658 camera_msg_param param;
4661 if (!pc || !pc->cb_info) {
4662 LOGE("NULL handle");
4663 return CAMERA_ERROR_INVALID_PARAMETER;
4666 LOGD("Enter - %d,%d", x, y);
4668 value = (x << 16) | y;
4669 CAMERA_MSG_PARAM_SET(param, INT, value);
4671 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4673 LOGD("ret : 0x%x", ret);
4679 int camera_attr_clear_af_area(camera_h camera)
4681 int ret = CAMERA_ERROR_NONE;
4682 camera_cli_s *pc = (camera_cli_s *)camera;
4683 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4685 if (!pc || !pc->cb_info) {
4686 LOGE("NULL handle");
4687 return CAMERA_ERROR_INVALID_PARAMETER;
4692 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4694 LOGD("ret : 0x%x", ret);
4700 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4702 int ret = CAMERA_ERROR_NONE;
4703 camera_cli_s *pc = (camera_cli_s *)camera;
4704 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4705 camera_msg_param param;
4706 int set_mode = (int)mode;
4708 if (!pc || !pc->cb_info) {
4709 LOGE("NULL handle");
4710 return CAMERA_ERROR_INVALID_PARAMETER;
4715 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4717 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4719 LOGD("ret : 0x%x", ret);
4725 int camera_attr_set_exposure(camera_h camera, int value)
4727 int ret = CAMERA_ERROR_NONE;
4728 camera_cli_s *pc = (camera_cli_s *)camera;
4729 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4730 camera_msg_param param;
4732 if (!pc || !pc->cb_info) {
4733 LOGE("NULL handle");
4734 return CAMERA_ERROR_INVALID_PARAMETER;
4739 CAMERA_MSG_PARAM_SET(param, INT, value);
4741 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4743 LOGD("ret : 0x%x", ret);
4749 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4751 int ret = CAMERA_ERROR_NONE;
4752 camera_cli_s *pc = (camera_cli_s *)camera;
4753 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4754 camera_msg_param param;
4755 int set_iso = (int)iso;
4757 if (!pc || !pc->cb_info) {
4758 LOGE("NULL handle");
4759 return CAMERA_ERROR_INVALID_PARAMETER;
4764 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4766 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4768 LOGD("ret : 0x%x", ret);
4774 int camera_attr_set_brightness(camera_h camera, int level)
4776 int ret = CAMERA_ERROR_NONE;
4777 camera_cli_s *pc = (camera_cli_s *)camera;
4778 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4779 camera_msg_param param;
4781 if (!pc || !pc->cb_info) {
4782 LOGE("NULL handle");
4783 return CAMERA_ERROR_INVALID_PARAMETER;
4788 CAMERA_MSG_PARAM_SET(param, INT, level);
4790 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4792 LOGD("ret : 0x%x", ret);
4798 int camera_attr_set_contrast(camera_h camera, int level)
4800 int ret = CAMERA_ERROR_NONE;
4801 camera_cli_s *pc = (camera_cli_s *)camera;
4802 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4803 camera_msg_param param;
4805 if (!pc || !pc->cb_info) {
4806 LOGE("NULL handle");
4807 return CAMERA_ERROR_INVALID_PARAMETER;
4812 CAMERA_MSG_PARAM_SET(param, INT, level);
4814 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4816 LOGD("ret : 0x%x", ret);
4822 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4824 int ret = CAMERA_ERROR_NONE;
4825 camera_cli_s *pc = (camera_cli_s *)camera;
4826 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4827 camera_msg_param param;
4828 int set_whitebalance = (int)wb;
4830 if (!pc || !pc->cb_info) {
4831 LOGE("NULL handle");
4832 return CAMERA_ERROR_INVALID_PARAMETER;
4837 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4839 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4841 LOGD("ret : 0x%x", ret);
4847 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4849 int ret = CAMERA_ERROR_NONE;
4850 camera_cli_s *pc = (camera_cli_s *)camera;
4851 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4852 camera_msg_param param;
4853 int set_effect = (int)effect;
4855 if (!pc || !pc->cb_info) {
4856 LOGE("NULL handle");
4857 return CAMERA_ERROR_INVALID_PARAMETER;
4862 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4864 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4866 LOGD("ret : 0x%x", ret);
4872 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4874 int ret = CAMERA_ERROR_NONE;
4875 camera_cli_s *pc = (camera_cli_s *)camera;
4876 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4877 camera_msg_param param;
4878 int set_mode = (int)mode;
4880 if (!pc || !pc->cb_info) {
4881 LOGE("NULL handle");
4882 return CAMERA_ERROR_INVALID_PARAMETER;
4887 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4889 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4891 LOGD("ret : 0x%x", ret);
4897 int camera_attr_enable_tag(camera_h camera, bool enable)
4899 int ret = CAMERA_ERROR_NONE;
4900 camera_cli_s *pc = (camera_cli_s *)camera;
4901 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4902 camera_msg_param param;
4903 int set_enable = (int)enable;
4905 if (!pc || !pc->cb_info) {
4906 LOGE("NULL handle");
4907 return CAMERA_ERROR_INVALID_PARAMETER;
4912 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4914 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4916 LOGD("ret : 0x%x", ret);
4922 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
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_SET_TAG_IMAGE_DESCRIPTION;
4927 camera_msg_param param;
4929 if (!pc || !pc->cb_info || !description) {
4930 LOGE("NULL pointer %p %p", pc, description);
4931 return CAMERA_ERROR_INVALID_PARAMETER;
4936 CAMERA_MSG_PARAM_SET(param, STRING, description);
4938 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4940 LOGD("ret : 0x%x", ret);
4946 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4948 int ret = CAMERA_ERROR_NONE;
4949 camera_cli_s *pc = (camera_cli_s *)camera;
4950 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4951 camera_msg_param param;
4952 int set_orientation = (int)orientation;
4954 if (!pc || !pc->cb_info) {
4955 LOGE("NULL handle");
4956 return CAMERA_ERROR_INVALID_PARAMETER;
4961 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4963 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4965 LOGD("ret : 0x%x", ret);
4971 int camera_attr_set_tag_software(camera_h camera, const char *software)
4973 int ret = CAMERA_ERROR_NONE;
4974 camera_cli_s *pc = (camera_cli_s *)camera;
4975 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4976 camera_msg_param param;
4978 if (!pc || !pc->cb_info || !software) {
4979 LOGE("NULL pointer %p %p", pc, software);
4980 return CAMERA_ERROR_INVALID_PARAMETER;
4983 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4985 CAMERA_MSG_PARAM_SET(param, STRING, software);
4987 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4989 LOGD("ret : 0x%x", ret);
4995 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4997 int ret = CAMERA_ERROR_NONE;
4998 camera_cli_s *pc = (camera_cli_s *)camera;
4999 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
5000 double set_geotag[3] = {latitude, longitude, altitude};
5005 if (!pc || !pc->cb_info) {
5006 LOGE("NULL handle");
5007 return CAMERA_ERROR_INVALID_PARAMETER;
5012 length = sizeof(set_geotag) / sizeof(int) + \
5013 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
5015 msg = muse_core_msg_new(api,
5016 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
5019 LOGE("msg creation failed: api %d", api);
5020 return CAMERA_ERROR_OUT_OF_MEMORY;
5023 if (pc->cb_info->is_server_connected) {
5024 __camera_update_api_waiting(pc->cb_info, api, 1);
5026 g_mutex_lock(&pc->cb_info->fd_lock);
5027 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
5028 g_mutex_unlock(&pc->cb_info->fd_lock);
5032 LOGE("message send failed");
5033 ret = CAMERA_ERROR_INVALID_OPERATION;
5035 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
5038 __camera_update_api_waiting(pc->cb_info, api, -1);
5040 muse_core_msg_free(msg);
5042 LOGD("ret : 0x%x", ret);
5048 int camera_attr_remove_geotag(camera_h camera)
5050 int ret = CAMERA_ERROR_NONE;
5051 camera_cli_s *pc = (camera_cli_s *)camera;
5052 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
5054 if (!pc || !pc->cb_info) {
5055 LOGE("NULL handle");
5056 return CAMERA_ERROR_INVALID_PARAMETER;
5061 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5063 LOGD("ret : 0x%x", ret);
5069 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
5071 int ret = CAMERA_ERROR_NONE;
5072 camera_cli_s *pc = (camera_cli_s *)camera;
5073 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
5074 camera_msg_param param;
5075 int set_mode = (int)mode;
5077 if (!pc || !pc->cb_info) {
5078 LOGE("NULL handle");
5079 return CAMERA_ERROR_INVALID_PARAMETER;
5084 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5086 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5088 LOGD("ret : 0x%x", ret);
5094 int camera_attr_get_zoom(camera_h camera, int *zoom)
5096 int ret = CAMERA_ERROR_NONE;
5097 camera_cli_s *pc = (camera_cli_s *)camera;
5098 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
5100 if (!pc || !pc->cb_info || !zoom) {
5101 LOGE("NULL pointer %p %p", pc, zoom);
5102 return CAMERA_ERROR_INVALID_PARAMETER;
5107 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5109 if (ret == CAMERA_ERROR_NONE)
5110 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
5112 LOGD("ret : 0x%x", ret);
5118 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
5120 int ret = CAMERA_ERROR_NONE;
5121 camera_cli_s *pc = (camera_cli_s *)camera;
5122 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
5124 if (!pc || !pc->cb_info || !min || !max) {
5125 LOGE("NULL pointer %p %p %p", pc, min, max);
5126 return CAMERA_ERROR_INVALID_PARAMETER;
5131 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5133 if (ret == CAMERA_ERROR_NONE) {
5134 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
5135 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
5138 LOGD("ret : 0x%x", ret);
5144 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
5146 int ret = CAMERA_ERROR_NONE;
5147 camera_cli_s *pc = (camera_cli_s *)camera;
5148 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
5150 if (!pc || !pc->cb_info || !mode) {
5151 LOGE("NULL pointer %p %p", pc, mode);
5152 return CAMERA_ERROR_INVALID_PARAMETER;
5157 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5159 if (ret == CAMERA_ERROR_NONE)
5160 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5162 LOGD("ret : 0x%x", ret);
5168 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5170 int ret = CAMERA_ERROR_NONE;
5171 camera_cli_s *pc = (camera_cli_s *)camera;
5172 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5174 if (!pc || !pc->cb_info || !mode) {
5175 LOGE("NULL pointer %p %p", pc, mode);
5176 return CAMERA_ERROR_INVALID_PARAMETER;
5181 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5183 if (ret == CAMERA_ERROR_NONE)
5184 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5186 LOGD("ret : 0x%x", ret);
5192 int camera_attr_get_exposure(camera_h camera, int *value)
5194 int ret = CAMERA_ERROR_NONE;
5195 camera_cli_s *pc = (camera_cli_s *)camera;
5196 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5198 if (!pc || !pc->cb_info || !value) {
5199 LOGE("NULL pointer %p %p", pc, value);
5200 return CAMERA_ERROR_INVALID_PARAMETER;
5205 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5207 if (ret == CAMERA_ERROR_NONE)
5208 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5210 LOGD("ret : 0x%x", ret);
5216 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5218 int ret = CAMERA_ERROR_NONE;
5219 camera_cli_s *pc = (camera_cli_s *)camera;
5220 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5222 if (!pc || !pc->cb_info || !min || !max) {
5223 LOGE("NULL pointer %p %p %p", pc, min, max);
5224 return CAMERA_ERROR_INVALID_PARAMETER;
5229 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5231 if (ret == CAMERA_ERROR_NONE) {
5232 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5233 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5236 LOGD("ret : 0x%x", ret);
5242 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5244 int ret = CAMERA_ERROR_NONE;
5245 camera_cli_s *pc = (camera_cli_s *)camera;
5246 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5248 if (!pc || !pc->cb_info || !iso) {
5249 LOGE("NULL pointer %p %p", pc, iso);
5250 return CAMERA_ERROR_INVALID_PARAMETER;
5255 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5257 if (ret == CAMERA_ERROR_NONE)
5258 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5260 LOGD("ret : 0x%x", ret);
5266 int camera_attr_get_brightness(camera_h camera, int *level)
5268 int ret = CAMERA_ERROR_NONE;
5269 camera_cli_s *pc = (camera_cli_s *)camera;
5270 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5272 if (!pc || !pc->cb_info || !level) {
5273 LOGE("NULL pointer %p %p", pc, level);
5274 return CAMERA_ERROR_INVALID_PARAMETER;
5279 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5281 if (ret == CAMERA_ERROR_NONE)
5282 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5284 LOGD("ret : 0x%x", ret);
5290 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5292 int ret = CAMERA_ERROR_NONE;
5293 camera_cli_s *pc = (camera_cli_s *)camera;
5294 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5296 if (!pc || !pc->cb_info || !min || !max) {
5297 LOGE("NULL pointer %p %p %p", pc, min, max);
5298 return CAMERA_ERROR_INVALID_PARAMETER;
5303 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5305 if (ret == CAMERA_ERROR_NONE) {
5306 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5307 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5310 LOGD("ret : 0x%x", ret);
5316 int camera_attr_get_contrast(camera_h camera, int *level)
5318 int ret = CAMERA_ERROR_NONE;
5319 camera_cli_s *pc = (camera_cli_s *)camera;
5320 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5322 if (!pc || !pc->cb_info || !level) {
5323 LOGE("NULL pointer %p %p", pc, level);
5324 return CAMERA_ERROR_INVALID_PARAMETER;
5329 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5331 if (ret == CAMERA_ERROR_NONE)
5332 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5334 LOGD("ret : 0x%x", ret);
5340 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5342 int ret = CAMERA_ERROR_NONE;
5343 camera_cli_s *pc = (camera_cli_s *)camera;
5344 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5346 if (!pc || !pc->cb_info || !min || !max) {
5347 LOGE("NULL pointer %p %p %p", pc, min, max);
5348 return CAMERA_ERROR_INVALID_PARAMETER;
5353 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5355 if (ret == CAMERA_ERROR_NONE) {
5356 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5357 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5358 LOGD("min %d, max %d", *min, *max);
5361 LOGD("ret : 0x%x", ret);
5367 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5369 int ret = CAMERA_ERROR_NONE;
5370 camera_cli_s *pc = (camera_cli_s *)camera;
5371 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5373 if (!pc || !pc->cb_info || !wb) {
5374 LOGE("NULL pointer %p %p", pc, wb);
5375 return CAMERA_ERROR_INVALID_PARAMETER;
5380 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5382 if (ret == CAMERA_ERROR_NONE)
5383 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5385 LOGD("ret : 0x%x", ret);
5391 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5393 int ret = CAMERA_ERROR_NONE;
5394 camera_cli_s *pc = (camera_cli_s *)camera;
5395 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5397 if (!pc || !pc->cb_info || !effect) {
5398 LOGE("NULL pointer %p %p", pc, effect);
5399 return CAMERA_ERROR_INVALID_PARAMETER;
5404 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5406 if (ret == CAMERA_ERROR_NONE)
5407 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5409 LOGD("ret : 0x%x", ret);
5415 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5417 int ret = CAMERA_ERROR_NONE;
5418 camera_cli_s *pc = (camera_cli_s *)camera;
5419 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5421 if (!pc || !pc->cb_info || !mode) {
5422 LOGE("NULL pointer %p %p", pc, mode);
5423 return CAMERA_ERROR_INVALID_PARAMETER;
5428 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5430 if (ret == CAMERA_ERROR_NONE)
5431 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5433 LOGD("ret : 0x%x", ret);
5439 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5441 int ret = CAMERA_ERROR_NONE;
5442 camera_cli_s *pc = (camera_cli_s *)camera;
5443 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5445 if (!pc || !pc->cb_info || !enable) {
5446 LOGE("NULL pointer %p %p", pc, enable);
5447 return CAMERA_ERROR_INVALID_PARAMETER;
5452 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5454 if (ret == CAMERA_ERROR_NONE)
5455 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5457 LOGD("ret : 0x%x", ret);
5463 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5465 int ret = CAMERA_ERROR_NONE;
5466 camera_cli_s *pc = (camera_cli_s *)camera;
5467 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5469 if (!pc || !pc->cb_info || !description) {
5470 LOGE("NULL pointer %p %p", pc, description);
5471 return CAMERA_ERROR_INVALID_PARAMETER;
5476 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5478 if (ret == CAMERA_ERROR_NONE)
5479 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5481 LOGD("ret : 0x%x", ret);
5487 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5489 int ret = CAMERA_ERROR_NONE;
5490 camera_cli_s *pc = (camera_cli_s *)camera;
5491 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5493 if (!pc || !pc->cb_info || !orientation) {
5494 LOGE("NULL pointer %p %p", pc, orientation);
5495 return CAMERA_ERROR_INVALID_PARAMETER;
5500 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5502 if (ret == CAMERA_ERROR_NONE)
5503 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5505 LOGD("ret : 0x%x", ret);
5511 int camera_attr_get_tag_software(camera_h camera, char **software)
5513 int ret = CAMERA_ERROR_NONE;
5514 camera_cli_s *pc = (camera_cli_s *)camera;
5515 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5517 if (!pc || !pc->cb_info || !software) {
5518 LOGE("NULL pointer %p %p", pc, software);
5519 return CAMERA_ERROR_INVALID_PARAMETER;
5524 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5526 if (ret == CAMERA_ERROR_NONE)
5527 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5529 LOGD("ret : 0x%x", ret);
5535 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5537 int ret = CAMERA_ERROR_NONE;
5538 camera_cli_s *pc = (camera_cli_s *)camera;
5539 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5541 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5542 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5543 return CAMERA_ERROR_INVALID_PARAMETER;
5548 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5550 if (ret == CAMERA_ERROR_NONE) {
5551 *latitude = pc->cb_info->get_geotag[0];
5552 *longitude = pc->cb_info->get_geotag[1];
5553 *altitude = pc->cb_info->get_geotag[2];
5556 LOGD("ret : 0x%x", ret);
5562 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5564 int ret = CAMERA_ERROR_NONE;
5565 camera_cli_s *pc = (camera_cli_s *)camera;
5566 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5568 if (!pc || !pc->cb_info || !mode) {
5569 LOGE("NULL pointer %p %p", pc, mode);
5570 return CAMERA_ERROR_INVALID_PARAMETER;
5575 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5577 if (ret == CAMERA_ERROR_NONE)
5578 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5580 LOGD("ret : 0x%x", ret);
5586 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5588 int ret = CAMERA_ERROR_NONE;
5589 int get_flash_state = 0;
5592 LOGE("NULL pointer");
5593 return CAMERA_ERROR_INVALID_PARAMETER;
5596 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5597 (int)device, "get_flash_state", &get_flash_state);
5599 if (ret == CAMERA_ERROR_NONE) {
5600 *state = (camera_flash_state_e)get_flash_state;
5601 LOGD("flash state %d", *state);
5603 LOGE("failed 0x%x", ret);
5610 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5612 int ret = CAMERA_ERROR_NONE;
5613 camera_cli_s *pc = (camera_cli_s *)camera;
5614 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5616 if (!pc || !pc->cb_info || !foreach_cb) {
5617 LOGE("NULL pointer %p %p", pc, foreach_cb);
5618 return CAMERA_ERROR_INVALID_PARAMETER;
5623 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5624 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5626 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5628 LOGD("ret : 0x%x", ret);
5634 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5636 int ret = CAMERA_ERROR_NONE;
5637 camera_cli_s *pc = (camera_cli_s *)camera;
5638 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5640 if (!pc || !pc->cb_info || !foreach_cb) {
5641 LOGE("NULL pointer %p %p", pc, foreach_cb);
5642 return CAMERA_ERROR_INVALID_PARAMETER;
5647 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5648 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5650 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5652 LOGD("ret : 0x%x", ret);
5658 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5660 int ret = CAMERA_ERROR_NONE;
5661 camera_cli_s *pc = (camera_cli_s *)camera;
5662 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5664 if (!pc || !pc->cb_info || !foreach_cb) {
5665 LOGE("NULL pointer %p %p", pc, foreach_cb);
5666 return CAMERA_ERROR_INVALID_PARAMETER;
5671 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5672 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5674 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5676 LOGD("ret : 0x%x", ret);
5682 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5684 int ret = CAMERA_ERROR_NONE;
5685 camera_cli_s *pc = (camera_cli_s *)camera;
5686 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5688 if (!pc || !pc->cb_info || !foreach_cb) {
5689 LOGE("NULL pointer %p %p", pc, foreach_cb);
5690 return CAMERA_ERROR_INVALID_PARAMETER;
5695 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5696 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5698 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5700 LOGD("ret : 0x%x", ret);
5706 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5708 int ret = CAMERA_ERROR_NONE;
5709 camera_cli_s *pc = (camera_cli_s *)camera;
5710 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5712 if (!pc || !pc->cb_info || !foreach_cb) {
5713 LOGE("NULL pointer %p %p", pc, foreach_cb);
5714 return CAMERA_ERROR_INVALID_PARAMETER;
5719 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5720 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5722 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5724 LOGD("ret : 0x%x", ret);
5730 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5732 int ret = CAMERA_ERROR_NONE;
5733 camera_cli_s *pc = (camera_cli_s *)camera;
5734 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5736 if (!pc || !pc->cb_info || !foreach_cb) {
5737 LOGE("NULL pointer %p %p", pc, foreach_cb);
5738 return CAMERA_ERROR_INVALID_PARAMETER;
5743 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5744 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5746 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5748 LOGD("ret : 0x%x", ret);
5754 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5756 int ret = CAMERA_ERROR_NONE;
5757 camera_cli_s *pc = (camera_cli_s *)camera;
5758 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5760 if (!pc || !pc->cb_info || !foreach_cb) {
5761 LOGE("NULL pointer %p %p", pc, foreach_cb);
5762 return CAMERA_ERROR_INVALID_PARAMETER;
5767 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5768 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5770 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5772 LOGD("ret : 0x%x", ret);
5778 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
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_FOREACH_SUPPORTED_FPS;
5784 if (!pc || !pc->cb_info || !foreach_cb) {
5785 LOGE("NULL pointer %p %p", pc, foreach_cb);
5786 return CAMERA_ERROR_INVALID_PARAMETER;
5791 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5792 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5794 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5796 LOGD("Enter, handle :%x", pc->remote_handle);
5802 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)
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_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5807 camera_msg_param param;
5810 if (!pc || !pc->cb_info || !foreach_cb) {
5811 LOGE("NULL pointer %p %p", pc, foreach_cb);
5812 return CAMERA_ERROR_INVALID_PARAMETER;
5817 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5818 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5820 value = (width << 16) | height;
5821 CAMERA_MSG_PARAM_SET(param, INT, value);
5823 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5825 LOGD("ret : 0x%x", ret);
5831 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5833 int ret = CAMERA_ERROR_NONE;
5834 camera_cli_s *pc = (camera_cli_s *)camera;
5835 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5837 if (!pc || !pc->cb_info || !foreach_cb) {
5838 LOGE("NULL pointer %p %p", pc, foreach_cb);
5839 return CAMERA_ERROR_INVALID_PARAMETER;
5844 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5845 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5847 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5849 LOGD("ret : 0x%x", ret);
5855 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5857 int ret = CAMERA_ERROR_NONE;
5858 camera_cli_s *pc = (camera_cli_s *)camera;
5859 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5861 if (!pc || !pc->cb_info || !foreach_cb) {
5862 LOGE("NULL pointer %p %p", pc, foreach_cb);
5863 return CAMERA_ERROR_INVALID_PARAMETER;
5868 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5869 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5871 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5873 LOGD("ret : 0x%x", ret);
5879 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5881 int ret = CAMERA_ERROR_NONE;
5882 camera_cli_s *pc = (camera_cli_s *)camera;
5883 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5884 camera_msg_param param;
5885 int set_rotation = (int)rotation;
5887 if (!pc || !pc->cb_info) {
5888 LOGE("NULL handle");
5889 return CAMERA_ERROR_INVALID_PARAMETER;
5894 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5896 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5898 LOGD("ret : 0x%x", ret);
5904 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5906 int ret = CAMERA_ERROR_NONE;
5907 camera_cli_s *pc = (camera_cli_s *)camera;
5908 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5910 if (!pc || !pc->cb_info || !rotation) {
5911 LOGE("NULL pointer %p %p", pc, rotation);
5912 return CAMERA_ERROR_INVALID_PARAMETER;
5917 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5919 if (ret == CAMERA_ERROR_NONE)
5920 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5922 LOGD("ret : 0x%x", ret);
5928 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5930 int ret = CAMERA_ERROR_NONE;
5931 camera_cli_s *pc = (camera_cli_s *)camera;
5932 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5933 camera_msg_param param;
5934 int set_flip = (int)flip;
5936 if (!pc || !pc->cb_info) {
5937 LOGE("NULL handle");
5938 return CAMERA_ERROR_INVALID_PARAMETER;
5943 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5945 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5947 LOGD("ret : 0x%x", ret);
5953 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5955 int ret = CAMERA_ERROR_NONE;
5956 camera_cli_s *pc = (camera_cli_s *)camera;
5957 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5959 if (!pc || !pc->cb_info || !flip) {
5960 LOGE("NULL pointer %p %p", pc, flip);
5961 return CAMERA_ERROR_INVALID_PARAMETER;
5966 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5968 if (ret == CAMERA_ERROR_NONE)
5969 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5971 LOGD("ret : 0x%x", ret);
5976 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5978 int ret = CAMERA_ERROR_NONE;
5979 camera_cli_s *pc = (camera_cli_s *)camera;
5980 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5981 camera_msg_param param;
5982 int set_mode = (int)mode;
5984 if (!pc || !pc->cb_info) {
5985 LOGE("NULL handle");
5986 return CAMERA_ERROR_INVALID_PARAMETER;
5991 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5993 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5995 LOGD("ret : 0x%x", ret);
6001 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
6003 int ret = CAMERA_ERROR_NONE;
6004 camera_cli_s *pc = (camera_cli_s *)camera;
6005 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
6007 if (!pc || !pc->cb_info || !mode) {
6008 LOGE("NULL pointer %p %p", pc, mode);
6009 return CAMERA_ERROR_INVALID_PARAMETER;
6014 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6016 if (ret == CAMERA_ERROR_NONE)
6017 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
6019 LOGD("ret : 0x%x", ret);
6025 bool camera_attr_is_supported_hdr_capture(camera_h camera)
6027 int ret = CAMERA_ERROR_NONE;
6028 camera_cli_s *pc = (camera_cli_s *)camera;
6029 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
6031 if (!pc || !pc->cb_info) {
6032 LOGE("NULL handle");
6033 return CAMERA_ERROR_INVALID_PARAMETER;
6038 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6041 LOGE("error is occurred 0x%x", ret);
6045 LOGD("ret : %d", ret);
6051 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
6053 int ret = CAMERA_ERROR_NONE;
6054 camera_cli_s *pc = (camera_cli_s *)camera;
6055 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
6057 if (!pc || !pc->cb_info) {
6058 LOGE("NULL handle");
6059 return CAMERA_ERROR_INVALID_PARAMETER;
6064 if (!camera_attr_is_supported_hdr_capture(camera)) {
6065 LOGE("HDR not supported");
6066 return CAMERA_ERROR_NOT_SUPPORTED;
6070 LOGE("NULL callback");
6071 return CAMERA_ERROR_INVALID_PARAMETER;
6074 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6076 if (ret == CAMERA_ERROR_NONE) {
6077 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
6078 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
6081 LOGD("ret : 0x%x", ret);
6087 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
6089 int ret = CAMERA_ERROR_NONE;
6090 camera_cli_s *pc = (camera_cli_s *)camera;
6091 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
6093 if (!pc || !pc->cb_info) {
6094 LOGE("NULL handle");
6095 return CAMERA_ERROR_INVALID_PARAMETER;
6100 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6102 if (ret == CAMERA_ERROR_NONE) {
6103 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6104 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6107 LOGD("ret : 0x%x", ret);
6113 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6115 int ret = CAMERA_ERROR_NONE;
6116 camera_cli_s *pc = (camera_cli_s *)camera;
6117 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
6118 camera_msg_param param;
6119 int set_enable = (int)enable;
6121 if (!pc || !pc->cb_info) {
6122 LOGE("NULL handle");
6123 return CAMERA_ERROR_INVALID_PARAMETER;
6128 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6130 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6132 LOGD("ret : 0x%x", ret);
6138 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6140 int ret = CAMERA_ERROR_NONE;
6141 camera_cli_s *pc = (camera_cli_s *)camera;
6142 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6144 if (!pc || !pc->cb_info || !enabled) {
6145 LOGE("NULL pointer %p %p", pc, enabled);
6146 return CAMERA_ERROR_INVALID_PARAMETER;
6151 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6153 if (ret == CAMERA_ERROR_NONE)
6154 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6156 LOGD("ret : 0x%x", ret);
6162 bool camera_attr_is_supported_anti_shake(camera_h camera)
6164 int ret = CAMERA_ERROR_NONE;
6165 camera_cli_s *pc = (camera_cli_s *)camera;
6166 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6168 if (!pc || !pc->cb_info) {
6169 LOGE("NULL handle");
6170 return CAMERA_ERROR_INVALID_PARAMETER;
6175 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6178 LOGE("error is occurred 0x%x", ret);
6182 LOGD("ret : %d", ret);
6188 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6190 int ret = CAMERA_ERROR_NONE;
6191 camera_cli_s *pc = (camera_cli_s *)camera;
6192 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6193 camera_msg_param param;
6194 int set_enable = (int)enable;
6196 if (!pc || !pc->cb_info) {
6197 LOGE("NULL handle");
6198 return CAMERA_ERROR_INVALID_PARAMETER;
6203 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6205 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6207 LOGD("ret : 0x%x", ret);
6213 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6215 int ret = CAMERA_ERROR_NONE;
6216 camera_cli_s *pc = (camera_cli_s *)camera;
6217 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6219 if (!pc || !pc->cb_info || !enabled) {
6220 LOGE("NULL pointer %p %p", pc, enabled);
6221 return CAMERA_ERROR_INVALID_PARAMETER;
6226 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6228 if (ret == CAMERA_ERROR_NONE)
6229 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6231 LOGD("ret : 0x%x", ret);
6237 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6239 int ret = CAMERA_ERROR_NONE;
6240 camera_cli_s *pc = (camera_cli_s *)camera;
6241 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6243 if (!pc || !pc->cb_info) {
6244 LOGE("NULL handle");
6245 return CAMERA_ERROR_INVALID_PARAMETER;
6250 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6253 LOGE("error is occurred 0x%x", ret);
6257 LOGD("ret : %d", ret);
6263 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6265 int ret = CAMERA_ERROR_NONE;
6266 camera_cli_s *pc = (camera_cli_s *)camera;
6267 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6268 camera_msg_param param;
6269 int set_enable = (int)enable;
6271 if (!pc || !pc->cb_info) {
6272 LOGE("NULL handle");
6273 return CAMERA_ERROR_INVALID_PARAMETER;
6278 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6280 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6282 LOGD("ret : 0x%x", ret);
6288 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6290 int ret = CAMERA_ERROR_NONE;
6291 camera_cli_s *pc = (camera_cli_s *)camera;
6292 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6294 if (!pc || !pc->cb_info || !enabled) {
6295 LOGE("NULL pointer %p %p", pc, enabled);
6296 return CAMERA_ERROR_INVALID_PARAMETER;
6301 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6303 if (ret == CAMERA_ERROR_NONE)
6304 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6306 LOGD("ret : 0x%x", ret);
6312 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6314 int ret = CAMERA_ERROR_NONE;
6315 camera_cli_s *pc = (camera_cli_s *)camera;
6316 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6318 if (!pc || !pc->cb_info) {
6319 LOGE("NULL handle");
6320 return CAMERA_ERROR_INVALID_PARAMETER;
6325 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6328 LOGE("error is occurred 0x%x", ret);
6332 LOGD("ret : %d", ret);
6338 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6340 int ret = CAMERA_ERROR_NONE;
6341 camera_cli_s *pc = (camera_cli_s *)camera;
6342 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6343 camera_msg_param param;
6344 int set_disable = (int)disable;
6346 if (!pc || !pc->cb_info) {
6347 LOGE("NULL handle");
6348 return CAMERA_ERROR_INVALID_PARAMETER;
6353 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6355 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6357 LOGD("ret : 0x%x", ret);
6363 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6365 int ret = CAMERA_ERROR_NONE;
6366 camera_cli_s *pc = (camera_cli_s *)camera;
6367 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6368 camera_msg_param param;
6369 int set_move_type = (int)move_type;
6372 if (!pc || !pc->cb_info) {
6373 LOGE("NULL handle");
6374 return CAMERA_ERROR_INVALID_PARAMETER;
6379 value = (set_move_type << 16) | pan_step;
6380 CAMERA_MSG_PARAM_SET(param, INT, value);
6382 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6384 LOGD("ret : 0x%x", ret);
6390 int camera_attr_get_pan(camera_h camera, int *pan_step)
6392 int ret = CAMERA_ERROR_NONE;
6393 camera_cli_s *pc = (camera_cli_s *)camera;
6394 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6396 if (!pc || !pc->cb_info || !pan_step) {
6397 LOGE("NULL pointer %p %p", pc, pan_step);
6398 return CAMERA_ERROR_INVALID_PARAMETER;
6403 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6405 if (ret == CAMERA_ERROR_NONE)
6406 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6408 LOGD("ret : 0x%x", ret);
6414 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6416 int ret = CAMERA_ERROR_NONE;
6417 camera_cli_s *pc = (camera_cli_s *)camera;
6418 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6420 if (!pc || !pc->cb_info || !min || !max) {
6421 LOGE("NULL pointer %p %p", pc, min, max);
6422 return CAMERA_ERROR_INVALID_PARAMETER;
6427 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6429 if (ret == CAMERA_ERROR_NONE) {
6430 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6431 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6434 LOGD("ret : 0x%x", ret);
6440 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6442 int ret = CAMERA_ERROR_NONE;
6443 camera_cli_s *pc = (camera_cli_s *)camera;
6444 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6445 camera_msg_param param;
6446 int set_move_type = (int)move_type;
6449 if (!pc || !pc->cb_info) {
6450 LOGE("NULL handle");
6451 return CAMERA_ERROR_INVALID_PARAMETER;
6456 value = (set_move_type << 16) | tilt_step;
6457 CAMERA_MSG_PARAM_SET(param, INT, value);
6459 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6461 LOGD("ret : 0x%x", ret);
6467 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6469 int ret = CAMERA_ERROR_NONE;
6470 camera_cli_s *pc = (camera_cli_s *)camera;
6471 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6473 if (!pc || !pc->cb_info || !tilt_step) {
6474 LOGE("NULL pointer %p %p", pc, tilt_step);
6475 return CAMERA_ERROR_INVALID_PARAMETER;
6480 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6482 if (ret == CAMERA_ERROR_NONE)
6483 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6485 LOGD("ret : 0x%x", ret);
6491 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6493 int ret = CAMERA_ERROR_NONE;
6494 camera_cli_s *pc = (camera_cli_s *)camera;
6495 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6497 if (!pc || !pc->cb_info || !min || !max) {
6498 LOGE("NULL pointer %p %p %p", pc, min, max);
6499 return CAMERA_ERROR_INVALID_PARAMETER;
6504 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6506 if (ret == CAMERA_ERROR_NONE) {
6507 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6508 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6511 LOGD("ret : 0x%x", ret);
6517 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6519 int ret = CAMERA_ERROR_NONE;
6520 camera_cli_s *pc = (camera_cli_s *)camera;
6521 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6522 camera_msg_param param;
6523 int set_ptz_type = (int)ptz_type;
6525 if (!pc || !pc->cb_info) {
6526 LOGE("NULL handle");
6527 return CAMERA_ERROR_INVALID_PARAMETER;
6532 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6534 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6536 LOGD("ret : 0x%x", ret);
6542 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6544 int ret = CAMERA_ERROR_NONE;
6545 camera_cli_s *pc = (camera_cli_s *)camera;
6546 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6548 if (!pc || !pc->cb_info || !foreach_cb) {
6549 LOGE("NULL pointer %p %p", pc, foreach_cb);
6550 return CAMERA_ERROR_INVALID_PARAMETER;
6555 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6556 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6558 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6560 LOGD("ret : 0x%x", ret);
6566 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6568 int ret = CAMERA_ERROR_NONE;
6569 camera_cli_s *pc = (camera_cli_s *)camera;
6570 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6571 int set_display_roi_area[4] = {x, y, width, height};
6576 if (!pc || !pc->cb_info) {
6577 LOGE("NULL handle");
6578 return CAMERA_ERROR_INVALID_PARAMETER;
6583 #ifdef TIZEN_FEATURE_EVAS_RENDERER
6584 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6585 g_mutex_lock(&pc->cb_info->evas_mutex);
6587 ret = mm_evas_renderer_set_roi_area(pc->cb_info->evas_info, x, y, width, height);
6589 g_mutex_unlock(&pc->cb_info->evas_mutex);
6591 if (ret != MM_ERROR_NONE) {
6592 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6593 return CAMERA_ERROR_INVALID_OPERATION;
6596 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
6598 length = sizeof(set_display_roi_area) / sizeof(int) + \
6599 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6601 msg = muse_core_msg_new(api,
6602 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6605 LOGE("msg creation failed: api %d", api);
6606 return CAMERA_ERROR_OUT_OF_MEMORY;
6609 if (pc->cb_info->is_server_connected) {
6610 __camera_update_api_waiting(pc->cb_info, api, 1);
6612 g_mutex_lock(&pc->cb_info->fd_lock);
6613 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
6614 g_mutex_unlock(&pc->cb_info->fd_lock);
6618 LOGE("message send failed");
6619 ret = CAMERA_ERROR_INVALID_OPERATION;
6621 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6624 __camera_update_api_waiting(pc->cb_info, api, -1);
6626 muse_core_msg_free(msg);
6628 LOGD("ret : 0x%x", ret);
6634 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6636 camera_cli_s *pc = (camera_cli_s *)camera;
6637 int ret = CAMERA_ERROR_NONE;
6638 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6640 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6641 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6642 return CAMERA_ERROR_INVALID_PARAMETER;
6647 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6649 if (ret == CAMERA_ERROR_NONE) {
6650 *x = pc->cb_info->get_display_roi_area[0];
6651 *y = pc->cb_info->get_display_roi_area[1];
6652 *width = pc->cb_info->get_display_roi_area[2];
6653 *height = pc->cb_info->get_display_roi_area[3];
6656 LOGD("ret : 0x%x", ret);
6662 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6664 int ret = CAMERA_ERROR_NONE;
6665 int get_device_state = 0;
6668 LOGE("NULL pointer");
6669 return CAMERA_ERROR_INVALID_PARAMETER;
6672 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6673 (int)device, "get_device_state", &get_device_state);
6675 if (ret == CAMERA_ERROR_NONE) {
6676 *state = (camera_device_state_e)get_device_state;
6677 LOGD("device state %d", *state);
6679 LOGE("failed 0x%x", ret);
6686 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6688 int ret = CAMERA_ERROR_NONE;
6689 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6690 camera_cb_info *info = NULL;
6692 if (!callback || !cb_id) {
6693 LOGE("invalid pointer %p %p", callback, cb_id);
6694 return CAMERA_ERROR_INVALID_PARAMETER;
6697 /* check camera support */
6698 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6699 if (ret != CAMERA_ERROR_NONE) {
6700 LOGE("get device state failed");
6704 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6706 info = g_new0(camera_cb_info, 1);
6708 LOGE("info failed");
6709 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6713 info->id = ++g_cam_dev_state_changed_cb_id;
6714 info->callback = (void *)callback;
6715 info->user_data = user_data;
6719 /* subscribe dbus signal for camera state change */
6720 if (!g_cam_dev_state_changed_cb_conn) {
6721 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6722 if (!g_cam_dev_state_changed_cb_conn) {
6723 LOGE("failed to get gdbus connection");
6724 ret = CAMERA_ERROR_INVALID_OPERATION;
6728 LOGD("subscribe signal %s - %s - %s",
6729 MM_CAMCORDER_DBUS_OBJECT,
6730 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6731 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6733 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6734 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6735 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6736 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6737 LOGE("failed to get gdbus connection");
6738 ret = CAMERA_ERROR_INVALID_OPERATION;
6742 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6745 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6747 LOGD("callback id %d", info->id);
6750 if (ret != CAMERA_ERROR_NONE) {
6756 if (g_cam_dev_state_changed_cb_conn) {
6757 g_object_unref(g_cam_dev_state_changed_cb_conn);
6758 g_cam_dev_state_changed_cb_conn = NULL;
6762 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6768 int camera_remove_device_state_changed_cb(int cb_id)
6770 int ret = CAMERA_ERROR_NONE;
6771 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6772 GList *tmp_list = NULL;
6773 camera_cb_info *info = NULL;
6775 /* check camera support */
6776 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6777 if (ret != CAMERA_ERROR_NONE) {
6778 LOGE("get device state failed");
6782 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6784 if (!g_cam_dev_state_changed_cb_list) {
6785 LOGE("there is no callback info");
6786 ret = CAMERA_ERROR_INVALID_OPERATION;
6790 tmp_list = g_cam_dev_state_changed_cb_list;
6793 info = tmp_list->data;
6794 tmp_list = tmp_list->next;
6801 if (info->id == cb_id) {
6802 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6807 if (!g_cam_dev_state_changed_cb_list) {
6808 /* no remained callback */
6809 if (g_cam_dev_state_changed_cb_conn) {
6810 /* unsubscribe signal */
6811 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6812 g_cam_dev_state_changed_cb_subscribe_id = 0;
6814 /* unref connection */
6815 g_object_unref(g_cam_dev_state_changed_cb_conn);
6816 g_cam_dev_state_changed_cb_conn = NULL;
6820 LOGD("id %d callback removed", cb_id);
6821 ret = CAMERA_ERROR_NONE;
6827 LOGE("id %d callback not found", cb_id);
6828 ret = CAMERA_ERROR_INVALID_PARAMETER;
6831 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);