2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
24 #include <muse_camera.h>
25 #include <muse_camera_msg.h>
26 #include <muse_core_ipc.h>
27 #include <muse_core_module.h>
28 #include <camera_private.h>
29 #include <muse_core.h>
31 #include <Elementary.h>
32 #include <tbm_surface_internal.h>
34 #include <Ecore_Wayland.h>
35 #include <wayland-client.h>
36 #include <tizen-extension-client-protocol.h>
37 #ifdef TIZEN_FEATURE_EVAS_RENDERER
38 #include <mm_evas_renderer.h>
39 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
44 #define LOG_TAG "TIZEN_N_CAMERA"
47 static void __global(void *data, struct wl_registry *registry,
48 uint32_t name, const char *interface, uint32_t version)
50 struct tizen_surface **tz_surface = NULL;
57 tz_surface = (struct tizen_surface **)data;
60 LOGW("NULL interface");
64 /*LOGI("interface %s", interface);*/
66 if (strcmp(interface, "tizen_surface") == 0) {
67 LOGD("binding tizen surface for wayland");
69 *tz_surface = wl_registry_bind(registry, name, &tizen_surface_interface, version);
70 if (*tz_surface == NULL)
71 LOGE("failed to bind");
79 static void __global_remove(void *data, struct wl_registry *wl_registry, uint32_t name)
85 static const struct wl_registry_listener _camera_wl_registry_listener = {
90 void __parent_id_getter(void *data, struct tizen_resource *tizen_resource, uint32_t id)
97 *((unsigned int *)data) = id;
99 LOGD("[CLIENT] got parent_id [%u] from server", id);
104 static const struct tizen_resource_listener _camera_tz_resource_listener = {
108 int _camera_get_wl_info(Evas_Object *obj, camera_wl_info_s *wl_info)
110 int ret = CAMERA_ERROR_NONE;
111 Ecore_Wl_Window *window = NULL;
112 struct wl_display *display = NULL;
113 struct wl_surface *surface = NULL;
114 struct wl_registry *registry = NULL;
115 struct tizen_surface *tz_surface = NULL;
116 struct tizen_resource *tz_resource = NULL;
118 if (!obj || !wl_info) {
119 LOGE("NULL parameter %p %p", obj, wl_info);
120 return CAMERA_ERROR_INVALID_OPERATION;
123 window = elm_win_wl_window_get(obj);
125 LOGE("failed to get wayland window");
126 ret = CAMERA_ERROR_INVALID_OPERATION;
130 surface = (struct wl_surface *)ecore_wl_window_surface_get(window);
132 LOGE("failed to get wayland surface");
133 ret = CAMERA_ERROR_INVALID_OPERATION;
137 display = (struct wl_display *)ecore_wl_display_get();
139 LOGE("failed to get wayland display");
140 ret = CAMERA_ERROR_INVALID_OPERATION;
144 registry = wl_display_get_registry(display);
146 LOGE("failed to get wayland registry");
147 ret = CAMERA_ERROR_INVALID_OPERATION;
151 wl_registry_add_listener(registry, &_camera_wl_registry_listener, &tz_surface);
153 wl_display_dispatch(display);
154 wl_display_roundtrip(display);
157 LOGE("failed to get tizen surface");
158 ret = CAMERA_ERROR_INVALID_OPERATION;
162 /* Get parent_id which is unique in a entire systemw. */
163 tz_resource = tizen_surface_get_tizen_resource(tz_surface, surface);
165 LOGE("failed to get tizen resurce");
166 ret = CAMERA_ERROR_INVALID_OPERATION;
170 wl_info->parent_id = 0;
172 tizen_resource_add_listener(tz_resource, &_camera_tz_resource_listener, &wl_info->parent_id);
174 wl_display_roundtrip(display);
176 if (wl_info->parent_id > 0) {
178 Ecore_Evas *ecore_evas = NULL;
179 ret = CAMERA_ERROR_NONE;
181 wl_info->evas_obj = obj;
183 evas_object_geometry_get(obj, &wl_info->window_x, &wl_info->window_y,
184 &wl_info->window_width, &wl_info->window_height);
186 ecore_evas = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
188 rotation = ecore_evas_rotation_get(ecore_evas);
189 if (rotation == 90 || rotation == 270) {
190 int temp = wl_info->window_width;
192 LOGD("swap width and height %d, %d", wl_info->window_width, wl_info->window_height);
194 wl_info->window_width = wl_info->window_height;
195 wl_info->window_height = temp;
198 LOGW("failed to get ecore_evas.. skip rotation check");
201 LOGD("evas object : %p, rotation : %d, parent id : %u, window : %d,%d,%dx%d",
202 wl_info->evas_obj, rotation, wl_info->parent_id,
203 wl_info->window_x, wl_info->window_y,
204 wl_info->window_width, wl_info->window_height);
206 ret = CAMERA_ERROR_INVALID_OPERATION;
207 LOGE("failed to get parent id");
212 tizen_surface_destroy(tz_surface);
217 tizen_resource_destroy(tz_resource);
222 wl_registry_destroy(registry);
230 static int _camera_import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle)
232 tbm_bo tmp_bo = NULL;
233 tbm_bo_handle tmp_bo_handle = {NULL, };
235 if (!bufmgr || !bo || !bo_handle || !tbm_key) {
236 LOGE("invalid parameter - %p %p %p, key %d",
237 bufmgr, bo, bo_handle, tbm_key);
241 tmp_bo = tbm_bo_import(bufmgr, tbm_key);
242 if (tmp_bo == NULL) {
243 LOGE("import failed - key %d", tbm_key);
247 tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
248 if (tmp_bo_handle.ptr == NULL) {
249 LOGE("map failed %p", tmp_bo);
250 tbm_bo_unref(tmp_bo);
255 tbm_bo_unmap(tmp_bo);
257 /* set bo and bo_handle */
259 *bo_handle = tmp_bo_handle;
264 static void _camera_release_imported_bo(tbm_bo *bo)
277 static int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
279 int ret = CAMERA_ERROR_NONE;
282 /*LOGD("Enter api : %d", api);*/
284 g_mutex_lock(&(cb_info->api_mutex[api]));
286 if (cb_info->api_activating[api] == 0) {
287 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
288 if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
289 ret = cb_info->api_ret[api];
290 cb_info->api_activating[api] = 0;
292 /*LOGD("return value : 0x%x", ret);*/
294 ret = CAMERA_ERROR_INVALID_OPERATION;
295 LOGE("api %d was TIMED OUT!", api);
298 ret = cb_info->api_ret[api];
299 cb_info->api_activating[api] = 0;
301 /*LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);*/
304 g_mutex_unlock(&(cb_info->api_mutex[api]));
306 if (ret != CAMERA_ERROR_NONE) {
307 LOGE("api %d : error 0x%x", api, ret);
309 if (ret == CAMERA_ERROR_SOUND_POLICY)
310 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
311 else if (ret == CAMERA_ERROR_SOUND_POLICY_BY_CALL)
312 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
313 else if (ret == CAMERA_ERROR_SOUND_POLICY_BY_ALARM)
314 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
321 static void _camera_msg_send(int api, camera_cb_info_s *cb_info,
322 int *ret, int timeout)
327 LOGE("NULL info - api %d", api);
330 *ret = CAMERA_ERROR_INVALID_PARAMETER;
335 msg = muse_core_msg_json_factory_new(api, NULL);
337 LOGE("msg failed: api %d", api);
340 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
345 /*LOGD("send msg %s", msg);*/
347 if (muse_core_ipc_send_msg(cb_info->fd, msg) < 0) {
348 LOGE("msg send failed");
350 *ret = CAMERA_ERROR_INVALID_OPERATION;
353 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
356 muse_core_msg_json_factory_free(msg);
362 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
363 int *ret, camera_msg_param *param, int timeout)
367 if (!cb_info || !param) {
368 LOGE("invalid pointer : api %d - %p %p", api, cb_info, param);
371 *ret = CAMERA_ERROR_INVALID_PARAMETER;
376 /*LOGD("type %d, name %s", param->type, param->name);*/
378 switch (param->type) {
380 msg = muse_core_msg_json_factory_new(api,
381 param->type, param->name, param->value.value_INT,
384 case MUSE_TYPE_STRING:
385 msg = muse_core_msg_json_factory_new(api,
386 param->type, param->name, param->value.value_STRING,
390 LOGE("unknown type %d", param->type);
395 LOGE("msg failed: api %d", api);
398 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
403 /*LOGD("send msg %s", msg);*/
405 if (muse_core_ipc_send_msg(cb_info->fd, msg) < 0) {
406 LOGE("msg send failed");
409 *ret = CAMERA_ERROR_INVALID_OPERATION;
412 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
415 muse_core_msg_json_factory_free(msg);
421 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
423 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
424 in_format >= MM_PIXEL_FORMAT_NUM ||
425 out_format == NULL) {
426 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
427 return CAMERA_ERROR_INVALID_PARAMETER;
431 case MM_PIXEL_FORMAT_NV12:
432 case MM_PIXEL_FORMAT_NV12T:
433 *out_format = TBM_FORMAT_NV12;
435 case MM_PIXEL_FORMAT_NV16:
436 *out_format = TBM_FORMAT_NV16;
438 case MM_PIXEL_FORMAT_NV21:
439 *out_format = TBM_FORMAT_NV21;
441 case MM_PIXEL_FORMAT_YUYV:
442 *out_format = TBM_FORMAT_YUYV;
444 case MM_PIXEL_FORMAT_UYVY:
445 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
446 *out_format = TBM_FORMAT_UYVY;
448 case MM_PIXEL_FORMAT_422P:
449 *out_format = TBM_FORMAT_YUV422;
451 case MM_PIXEL_FORMAT_I420:
452 *out_format = TBM_FORMAT_YUV420;
454 case MM_PIXEL_FORMAT_YV12:
455 *out_format = TBM_FORMAT_YVU420;
457 case MM_PIXEL_FORMAT_RGB565:
458 *out_format = TBM_FORMAT_RGB565;
460 case MM_PIXEL_FORMAT_RGB888:
461 *out_format = TBM_FORMAT_RGB888;
463 case MM_PIXEL_FORMAT_RGBA:
464 *out_format = TBM_FORMAT_RGBA8888;
466 case MM_PIXEL_FORMAT_ARGB:
467 *out_format = TBM_FORMAT_ARGB8888;
470 LOGE("invalid in_format %d", in_format);
471 return CAMERA_ERROR_INVALID_PARAMETER;
474 return CAMERA_ERROR_NONE;
478 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
480 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
481 in_format >= MM_PIXEL_FORMAT_NUM ||
483 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
484 return CAMERA_ERROR_INVALID_PARAMETER;
488 case MM_PIXEL_FORMAT_NV12:
489 case MM_PIXEL_FORMAT_NV12T:
490 *mimetype = MEDIA_FORMAT_NV12;
492 case MM_PIXEL_FORMAT_NV16:
493 *mimetype = MEDIA_FORMAT_NV16;
495 case MM_PIXEL_FORMAT_NV21:
496 *mimetype = MEDIA_FORMAT_NV21;
498 case MM_PIXEL_FORMAT_YUYV:
499 *mimetype = MEDIA_FORMAT_YUYV;
501 case MM_PIXEL_FORMAT_UYVY:
502 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
503 *mimetype = MEDIA_FORMAT_UYVY;
505 case MM_PIXEL_FORMAT_422P:
506 *mimetype = MEDIA_FORMAT_422P;
508 case MM_PIXEL_FORMAT_I420:
509 *mimetype = MEDIA_FORMAT_I420;
511 case MM_PIXEL_FORMAT_YV12:
512 *mimetype = MEDIA_FORMAT_YV12;
514 case MM_PIXEL_FORMAT_RGB565:
515 *mimetype = MEDIA_FORMAT_RGB565;
517 case MM_PIXEL_FORMAT_RGB888:
518 *mimetype = MEDIA_FORMAT_RGB888;
520 case MM_PIXEL_FORMAT_RGBA:
521 *mimetype = MEDIA_FORMAT_RGBA;
523 case MM_PIXEL_FORMAT_ARGB:
524 *mimetype = MEDIA_FORMAT_ARGB;
527 LOGE("invalid in_format %d", in_format);
528 return CAMERA_ERROR_INVALID_PARAMETER;
531 return CAMERA_ERROR_NONE;
534 void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_key,
535 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame)
538 unsigned char *buf_pos = NULL;
540 if (stream == NULL || buffer_bo_handle == NULL || frame == NULL) {
541 LOGE("invalid parameter - stream:%p, buffer_bo_handle:%p", stream, buffer_bo_handle);
546 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
547 frame->format = MM_PIXEL_FORMAT_UYVY;
549 frame->format = stream->format;
551 frame->width = stream->width;
552 frame->height = stream->height;
553 frame->timestamp = stream->timestamp;
554 frame->num_of_planes = stream->num_planes;
556 if (num_buffer_key == 0) {
558 if (!data_bo_handle || !data_bo_handle->ptr) {
559 LOGE("NULL pointer");
563 buf_pos = data_bo_handle->ptr;
565 if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) {
566 frame->data.encoded_plane.data = buf_pos;
567 frame->data.encoded_plane.size = stream->data.encoded.length_data;
568 total_size = stream->data.encoded.length_data;
570 switch (stream->num_planes) {
572 frame->data.single_plane.yuv = buf_pos;
573 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
574 total_size = stream->data.yuv420.length_yuv;
577 frame->data.double_plane.y = buf_pos;
578 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
579 buf_pos += stream->data.yuv420sp.length_y;
580 frame->data.double_plane.uv = buf_pos;
581 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
582 total_size = stream->data.yuv420sp.length_y + \
583 stream->data.yuv420sp.length_uv;
586 frame->data.triple_plane.y = buf_pos;
587 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
588 buf_pos += stream->data.yuv420p.length_y;
589 frame->data.triple_plane.u = buf_pos;
590 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
591 buf_pos += stream->data.yuv420p.length_u;
592 frame->data.triple_plane.v = buf_pos;
593 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
594 total_size = stream->data.yuv420p.length_y + \
595 stream->data.yuv420p.length_u + \
596 stream->data.yuv420p.length_v;
604 switch (stream->num_planes) {
606 frame->data.single_plane.yuv = buffer_bo_handle[0].ptr;
607 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
608 total_size = stream->data.yuv420.length_yuv;
611 frame->data.double_plane.y = buffer_bo_handle[0].ptr;
612 if (stream->num_planes == (unsigned int)num_buffer_key)
613 frame->data.double_plane.uv = buffer_bo_handle[1].ptr;
615 frame->data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
616 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
617 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
618 total_size = stream->data.yuv420sp.length_y + \
619 stream->data.yuv420sp.length_uv;
622 frame->data.triple_plane.y = buffer_bo_handle[0].ptr;
623 if (stream->num_planes == (unsigned int)num_buffer_key) {
624 frame->data.triple_plane.u = buffer_bo_handle[1].ptr;
625 frame->data.triple_plane.v = buffer_bo_handle[2].ptr;
627 frame->data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y;
628 frame->data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u;
630 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
631 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
632 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
633 total_size = stream->data.yuv420p.length_y + \
634 stream->data.yuv420p.length_u + \
635 stream->data.yuv420p.length_v;
643 LOGD("format %d, %dx%d, size %d plane num %d",
644 frame.format, frame.width, frame.height, total_size, frame.num_of_planes);
650 int _camera_media_packet_data_create(int tbm_key, int num_buffer_key, tbm_bo bo,
651 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
654 int ret = CAMERA_ERROR_NONE;
655 camera_media_packet_data *tmp_mp_data = NULL;
657 if (*mp_data == NULL) {
658 tmp_mp_data = g_new0(camera_media_packet_data, 1);
660 tmp_mp_data->tbm_key = tbm_key;
661 tmp_mp_data->num_buffer_key = num_buffer_key;
662 tmp_mp_data->bo = bo;
663 tmp_mp_data->data_bo = data_bo;
664 tmp_mp_data->ref_cnt++;
666 for (i = 0 ; i < num_buffer_key ; i++)
667 tmp_mp_data->buffer_bo[i] = buffer_bo[i];
669 *mp_data = tmp_mp_data;
670 /*LOGD("mp_data %p", tmp_mp_data);*/
672 ret = CAMERA_ERROR_OUT_OF_MEMORY;
673 LOGE("failed to alloc media packet data");
676 ((camera_media_packet_data *)*mp_data)->ref_cnt++;
682 void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
686 camera_msg_param param;
688 if (!mp_data || !cb_info) {
689 LOGE("NULL pointer %p %p", mp_data, cb_info);
693 if (mp_data->ref_cnt > 1) {
695 LOGD("ref count %d", mp_data->ref_cnt);
697 /* release imported bo */
698 for (i = 0 ; i < mp_data->num_buffer_key ; i++) {
699 tbm_bo_unref(mp_data->buffer_bo[i]);
700 mp_data->buffer_bo[i] = NULL;
704 _camera_release_imported_bo(&mp_data->bo);
705 _camera_release_imported_bo(&mp_data->data_bo);
708 tbm_key = mp_data->tbm_key;
710 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
712 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
721 int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
722 camera_media_packet_data *mp_data, media_packet_h *packet)
724 media_packet_h pkt = NULL;
725 bool make_pkt_fmt = false;
726 tbm_surface_h tsurf = NULL;
727 tbm_surface_info_s tsurf_info;
728 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
729 uint32_t bo_format = 0;
732 int num_buffer_key = 0;
733 tbm_bo *buffer_bo = NULL;
735 if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) {
736 LOGE("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p",
737 cb_info, stream, mp_data, packet);
738 return CAMERA_ERROR_INVALID_PARAMETER;
741 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
742 buffer_bo = mp_data->buffer_bo;
743 num_buffer_key = mp_data->num_buffer_key;
745 /* create tbm surface */
746 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
747 tsurf_info.planes[i].stride = stream->stride[i];
749 /* get tbm surface format */
750 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
751 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
753 if (ret == CAMERA_ERROR_NONE) {
754 tsurf_info.width = stream->width;
755 tsurf_info.height = stream->height;
756 tsurf_info.format = bo_format;
757 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
758 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
760 if (num_buffer_key > 0) {
762 case TBM_FORMAT_NV12:
763 case TBM_FORMAT_NV21:
764 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
765 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
766 tsurf_info.planes[0].offset = 0;
767 if (num_buffer_key == 1)
768 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
769 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
771 case TBM_FORMAT_YUV420:
772 case TBM_FORMAT_YVU420:
773 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
774 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
775 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
776 tsurf_info.planes[0].offset = 0;
777 if (num_buffer_key == 1) {
778 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
779 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
781 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
783 case TBM_FORMAT_UYVY:
784 case TBM_FORMAT_YUYV:
785 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
786 tsurf_info.planes[0].offset = 0;
787 tsurf_info.size = tsurf_info.planes[0].size;
793 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_key);
794 } else if (mp_data->data_bo) {
796 case TBM_FORMAT_NV12:
797 case TBM_FORMAT_NV21:
798 tsurf_info.planes[0].size = stream->width * stream->height;
799 tsurf_info.planes[1].size = (tsurf_info.planes[0].size) >> 1;
800 tsurf_info.planes[0].offset = 0;
801 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
802 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
804 case TBM_FORMAT_YUV420:
805 case TBM_FORMAT_YVU420:
806 tsurf_info.planes[0].size = stream->width * stream->height;
807 tsurf_info.planes[1].size = (stream->width >> 1) * (stream->height >> 1);
808 tsurf_info.planes[2].size = tsurf_info.planes[1].size;
809 tsurf_info.planes[0].offset = 0;
810 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
811 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
812 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
814 case TBM_FORMAT_UYVY:
815 case TBM_FORMAT_YUYV:
816 tsurf_info.planes[0].size = (stream->width * stream->height) << 1;
817 tsurf_info.planes[0].offset = 0;
818 tsurf_info.size = tsurf_info.planes[0].size;
824 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1);
826 /*LOGD("tbm surface %p", tsurf);*/
830 /* check media packet format */
831 if (cb_info->pkt_fmt) {
832 int pkt_fmt_width = 0;
833 int pkt_fmt_height = 0;
834 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
836 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
837 if (pkt_fmt_mimetype != mimetype ||
838 pkt_fmt_width != stream->width ||
839 pkt_fmt_height != stream->height) {
840 LOGW("change fmt: current 0x%x, %dx%d",
841 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
842 media_format_unref(cb_info->pkt_fmt);
843 cb_info->pkt_fmt = NULL;
850 /* create packet format */
852 LOGW("make new pkt_fmt - 0x%x, %dx%d", mimetype, stream->width, stream->height);
853 ret = media_format_create(&cb_info->pkt_fmt);
854 if (ret == MEDIA_FORMAT_ERROR_NONE) {
855 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
856 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
857 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
858 LOGW("media_format_set : 0x%x", ret);
860 LOGW("media_format_create failed 0x%x", ret);
864 /* create media packet */
865 ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt,
866 tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
867 (void *)cb_info, &pkt);
868 if (ret != MEDIA_PACKET_ERROR_NONE) {
869 LOGE("media_packet_create failed 0x%x", ret);
870 tbm_surface_destroy(tsurf);
874 LOGE("tbm surface failed. %dx%d, format %d, num_buffer_key %d, data_bo %p",
875 stream->width, stream->height, stream->format, num_buffer_key, mp_data->data_bo);
879 /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
880 /* set media packet data */
881 ret = media_packet_set_extra(pkt, (void *)mp_data);
882 if (ret != MEDIA_PACKET_ERROR_NONE) {
883 LOGE("media_packet_set_extra failed");
885 _camera_media_packet_data_release(mp_data, cb_info);
888 media_packet_destroy(pkt);
891 /* set timestamp : msec -> nsec */
892 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
893 LOGW("media_packet_set_pts failed");
902 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
905 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
906 camera_media_packet_data *mp_data = NULL;
907 tbm_surface_h tsurf = NULL;
909 if (!pkt || !cb_info) {
910 LOGE("NULL pointer %p %p", pkt, cb_info);
911 return MEDIA_PACKET_FINALIZE;
914 ret = media_packet_get_extra(pkt, (void **)&mp_data);
915 if (ret != MEDIA_PACKET_ERROR_NONE) {
916 LOGE("media_packet_get_extra failed 0x%x", ret);
917 return MEDIA_PACKET_FINALIZE;
920 /*LOGD("mp_data %p", mp_data);*/
922 g_mutex_lock(&cb_info->mp_data_mutex);
924 _camera_media_packet_data_release(mp_data, cb_info);
927 g_mutex_unlock(&cb_info->mp_data_mutex);
929 ret = media_packet_get_tbm_surface(pkt, &tsurf);
930 if (ret != MEDIA_PACKET_ERROR_NONE)
931 LOGE("get tbm_surface failed 0x%x", ret);
934 tbm_surface_destroy(tsurf);
938 return MEDIA_PACKET_FINALIZE;
941 static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event)
947 tbm_bo_handle bo_handle = {NULL, };
948 camera_msg_param param;
950 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
951 LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event);
955 /*LOGD("get camera msg %s, event %d", recv_msg, event);*/
957 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
958 if (!(CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) &&
959 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] == NULL &&
960 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] == NULL) {
961 LOGW("all preview callback from user are NULL");
964 } else if (cb_info->user_cb[event] == NULL) {
965 LOGW("user callback for event %d is not set", event);
970 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
976 muse_camera_msg_get(previous, recv_msg);
977 muse_camera_msg_get(current, recv_msg);
978 muse_camera_msg_get(by_policy, recv_msg);
980 LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
981 previous, current, by_policy);
983 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
984 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
987 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
991 muse_camera_msg_get(state, recv_msg);
993 LOGD("FOCUS state - %d", state);
995 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
998 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
999 LOGD("CAPTURE_COMPLETED");
1000 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1002 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1003 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1007 int num_buffer_key = 0;
1008 int buffer_key[BUFFER_MAX_PLANE_NUM] = {0, };
1010 unsigned char *buf_pos = NULL;
1012 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
1013 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
1014 tbm_bo data_bo = NULL;
1015 tbm_bo_handle data_bo_handle = {.ptr = NULL};
1017 camera_preview_data_s frame;
1018 camera_stream_data_s *stream = NULL;
1019 camera_media_packet_data *mp_data = NULL;
1020 media_packet_h pkt = NULL;
1022 muse_camera_msg_get(tbm_key, recv_msg);
1023 muse_camera_msg_get(num_buffer_key, recv_msg);
1024 muse_camera_msg_get_array(buffer_key, recv_msg);
1025 muse_camera_msg_get(data_key, recv_msg);
1027 memset(&frame, 0x0, sizeof(camera_preview_data_s));
1030 LOGE("invalid key %d", tbm_key);
1034 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1037 /* import tbm data_bo and get virtual address */
1038 if (!_camera_import_tbm_key(cb_info->bufmgr, data_key, &data_bo, &data_bo_handle)) {
1039 LOGE("failed to import data key %d", data_key);
1040 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1045 /* import tbm bo and get virtual address */
1046 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
1047 LOGE("failed to import key %d", tbm_key);
1048 _camera_release_imported_bo(&data_bo);
1049 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1053 buf_pos = (unsigned char *)bo_handle.ptr;
1055 /* get stream info */
1056 stream = (camera_stream_data_s *)buf_pos;
1058 for (i = 0 ; i < num_buffer_key ; i++) {
1059 /* import buffer bo and get virtual address */
1060 if (!_camera_import_tbm_key(cb_info->bufmgr, buffer_key[i], &buffer_bo[i], &buffer_bo_handle[i])) {
1061 LOGE("failed to import buffer key %d", buffer_key[i]);
1063 /* release imported bo */
1064 _camera_release_imported_bo(&data_bo);
1065 _camera_release_imported_bo(&bo);
1067 for (i -= 1 ; i >= 0 ; i--)
1068 _camera_release_imported_bo(&buffer_bo[i]);
1070 /* send return buffer */
1071 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1077 /* call preview callback */
1078 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
1079 _camera_preview_frame_create(stream, num_buffer_key, buffer_bo_handle, &data_bo_handle, &frame);
1081 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
1082 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
1085 /* call media packet callback */
1086 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
1087 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
1089 if (ret == CAMERA_ERROR_NONE) {
1090 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt);
1092 if (ret == CAMERA_ERROR_NONE) {
1093 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
1094 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
1096 _camera_media_packet_data_release(mp_data, cb_info);
1102 /* call evas renderer */
1103 if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
1104 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1105 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
1107 if (ret == CAMERA_ERROR_NONE) {
1108 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt);
1110 if (ret == CAMERA_ERROR_NONE) {
1111 g_mutex_lock(&cb_info->evas_mutex);
1113 if (cb_info->run_evas_render) {
1114 mm_evas_renderer_write(pkt, cb_info->evas_info);
1116 LOGW("evas renderer is stopped, skip this buffer...");
1117 media_packet_destroy(pkt);
1122 g_mutex_unlock(&cb_info->evas_mutex);
1124 _camera_media_packet_data_release(mp_data, cb_info);
1128 #else /* TIZEN_FEATURE_EVAS_RENDERER */
1129 LOGW("evas renderer is not supported");
1130 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1133 /* send message for preview callback return */
1134 if (!CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS))
1135 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info, NULL, 0);
1137 if (mp_data == NULL) {
1138 /* release imported bo */
1139 for (i = 0 ; i < num_buffer_key ; i++)
1140 _camera_release_imported_bo(&buffer_bo[i]);
1142 /* unmap and unref tbm bo */
1143 _camera_release_imported_bo(&data_bo);
1144 _camera_release_imported_bo(&bo);
1147 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1149 /*LOGD("return buffer Done");*/
1153 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1157 muse_camera_msg_get(percent, recv_msg);
1159 LOGD("HDR progress - %d \%", percent);
1161 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1164 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1170 muse_camera_msg_get(policy, recv_msg);
1171 muse_camera_msg_get(previous, recv_msg);
1172 muse_camera_msg_get(current, recv_msg);
1174 LOGW("INTERRUPTED - policy %d, state previous %d, current %d",
1175 policy, previous, current);
1177 if (policy == CAMERA_POLICY_SOUND)
1178 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND is deprecated and will be removed from next release.");
1179 else if (policy == CAMERA_POLICY_SOUND_BY_CALL)
1180 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_CALL is deprecated and will be removed from next release.");
1181 else if (policy == CAMERA_POLICY_SOUND_BY_ALARM)
1182 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_ALARM is deprecated and will be removed from next release.");
1184 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1185 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1188 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1191 camera_detected_face_s *faces = NULL;
1193 muse_camera_msg_get(count, recv_msg);
1194 muse_camera_msg_get(tbm_key, recv_msg);
1196 if (count > 0 && tbm_key > 0) {
1197 LOGD("FACE_DETECTION - count %d, tbm_key %d", count, tbm_key);
1199 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle))
1203 faces = bo_handle.ptr;
1205 ((camera_face_detected_cb)cb_info->user_cb[event])(faces, count, cb_info->user_data[event]);
1211 for (i = 0 ; i < count ; i++) {
1212 LOGD("id[%2d] - score %d, position (%d,%d,%dx%d)",
1213 i, faces[i].score, faces[i].x, faces[i].y, faces[i].width, faces[i].height);
1219 _camera_release_imported_bo(&bo);
1222 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1223 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1225 /*LOGD("return buffer done");*/
1227 LOGE("invalid message - count %d, key %d", count, tbm_key);
1231 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1234 int current_state = 0;
1236 muse_camera_msg_get(error, recv_msg);
1237 muse_camera_msg_get(current_state, recv_msg);
1239 LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
1241 if (error == CAMERA_ERROR_SOUND_POLICY)
1242 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
1243 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_CALL)
1244 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
1245 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_ALARM)
1246 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
1248 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1249 (camera_state_e)current_state, cb_info->user_data[event]);
1252 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1254 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1255 muse_camera_msg_get(param1, recv_msg);
1256 muse_camera_msg_get(param2, recv_msg);
1258 /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/
1260 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1261 cb_info->user_cb[event] = NULL;
1262 cb_info->user_data[event] = NULL;
1263 LOGW("stop foreach callback for event %d", event);
1266 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1268 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1270 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1272 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1274 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1276 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1278 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1280 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1282 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1284 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1286 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1288 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1290 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1292 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1294 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1295 muse_camera_msg_get(param1, recv_msg);
1297 /*LOGD("event %d SUPPORTED %d ", event, param1);*/
1299 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1300 cb_info->user_cb[event] = NULL;
1301 cb_info->user_data[event] = NULL;
1302 LOGW("stop foreach callback for event %d", event);
1305 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1307 camera_image_data_s *rImage = NULL;
1308 camera_image_data_s *rPostview = NULL;
1309 camera_image_data_s *rThumbnail = NULL;
1310 unsigned char *buf_pos = NULL;
1311 int tbm_key_main = 0;
1312 int tbm_key_post = 0;
1313 int tbm_key_thumb = 0;
1314 tbm_bo bo_main = NULL;
1315 tbm_bo bo_post = NULL;
1316 tbm_bo bo_thumb = NULL;
1317 tbm_bo_handle bo_main_handle = {NULL, };
1318 tbm_bo_handle bo_post_handle = {NULL, };
1319 tbm_bo_handle bo_thumb_handle = {NULL, };
1321 muse_camera_msg_get(tbm_key_main, recv_msg);
1322 muse_camera_msg_get(tbm_key_post, recv_msg);
1323 muse_camera_msg_get(tbm_key_thumb, recv_msg);
1326 LOGD("camera capture callback came in. tbm_key_main %d, tbm_key_post %d, tbm_key_thumb %d",
1327 tbm_key_main, tbm_key_post, tbm_key_thumb);
1330 if (tbm_key_main <= 0) {
1331 LOGE("invalid key %d", tbm_key_main);
1335 /* import tbm bo and get virtual address */
1336 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_main, &bo_main, &bo_main_handle))
1339 buf_pos = (unsigned char *)bo_main_handle.ptr;
1340 rImage = (camera_image_data_s *)buf_pos;
1341 rImage->data = buf_pos + sizeof(camera_image_data_s);
1343 LOGD("image info %dx%d, size : %d", rImage->width, rImage->height, rImage->size);
1345 if (tbm_key_post > 0) {
1346 /* import tbm bo and get virtual address */
1347 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_post, &bo_post, &bo_post_handle))
1350 buf_pos = (unsigned char *)bo_post_handle.ptr;
1351 rPostview = (camera_image_data_s *)buf_pos;
1352 LOGD("rPostview->size : %d", rPostview->size);
1353 rPostview->data = buf_pos + sizeof(camera_image_data_s);
1356 if (tbm_key_thumb > 0) {
1357 /* import tbm bo and get virtual address */
1358 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_thumb, &bo_thumb, &bo_thumb_handle))
1361 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
1363 rThumbnail = (camera_image_data_s *)buf_pos;
1364 LOGD("rThumbnail->size : %d", rThumbnail->size);
1365 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
1368 ((camera_capturing_cb)cb_info->user_cb[event])(rImage, rPostview, rThumbnail, cb_info->user_data[event]);
1370 /* unmap and unref tbm bo */
1371 _camera_release_imported_bo(&bo_main);
1374 tbm_key = tbm_key_main;
1376 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1378 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1380 if (tbm_key_post > 0) {
1381 /* unmap and unref tbm bo */
1382 _camera_release_imported_bo(&bo_post);
1385 param.value.value_INT = tbm_key_post;
1386 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1389 if (tbm_key_thumb > 0) {
1390 /* unmap and unref tbm bo */
1391 _camera_release_imported_bo(&bo_thumb);
1394 param.value.value_INT = tbm_key_thumb;
1395 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1398 LOGD("return buffer done");
1401 case MUSE_CAMERA_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR:
1404 LOGW("Unknown event : %d", event);
1411 static bool _camera_idle_event_callback(void *data)
1413 camera_cb_info_s *cb_info = NULL;
1414 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1416 if (cam_idle_event == NULL) {
1417 LOGE("cam_idle_event is NULL");
1422 g_mutex_lock(&cam_idle_event->event_mutex);
1424 cb_info = cam_idle_event->cb_info;
1425 if (cb_info == NULL) {
1426 LOGW("camera cb_info is NULL. event %d", cam_idle_event->event);
1427 goto IDLE_EVENT_CALLBACK_DONE;
1430 /* remove event from list */
1431 g_mutex_lock(&cb_info->idle_event_mutex);
1433 if (cb_info->idle_event_list)
1434 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1436 /*LOGD("remove camera idle event %p, %p", cam_idle_event, cb_info->idle_event_list);*/
1437 g_mutex_unlock(&cb_info->idle_event_mutex);
1440 _camera_client_user_callback(cam_idle_event->cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
1442 /* send signal for waiting thread */
1443 g_cond_signal(&cb_info->idle_event_cond);
1445 IDLE_EVENT_CALLBACK_DONE:
1446 /* unlock and release event */
1447 g_mutex_unlock(&cam_idle_event->event_mutex);
1448 g_mutex_clear(&cam_idle_event->event_mutex);
1450 g_free(cam_idle_event);
1451 cam_idle_event = NULL;
1456 static void *_camera_msg_handler_func(gpointer data)
1460 camera_message_s *cam_msg = NULL;
1461 camera_idle_event_s *cam_idle_event = NULL;
1462 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1463 camera_cb_info_s *cb_info = NULL;
1465 if (!handler_info || !handler_info->cb_info) {
1466 LOGE("t:%d NULL handler %p", type, handler_info);
1470 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1471 type = handler_info->type;
1473 LOGD("t:%d start", type);
1475 g_mutex_lock(&handler_info->mutex);
1477 while (g_atomic_int_get(&handler_info->running)) {
1478 if (g_queue_is_empty(handler_info->queue)) {
1479 /*LOGD("t:%d signal wait...", type);*/
1480 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1481 /*LOGD("t:%d signal received", type);*/
1483 if (g_atomic_int_get(&handler_info->running) == 0) {
1484 LOGD("t:%d stop event thread", type);
1489 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1491 g_mutex_unlock(&handler_info->mutex);
1493 if (cam_msg == NULL) {
1494 LOGE("t:%d NULL message", type);
1495 g_mutex_lock(&handler_info->mutex);
1501 if (api < MUSE_CAMERA_API_MAX) {
1504 g_mutex_lock(&cb_info->api_mutex[api]);
1506 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1507 cb_info->api_ret[api] = ret;
1508 cb_info->api_activating[api] = 1;
1510 /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
1512 g_cond_signal(&cb_info->api_cond[api]);
1514 LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1517 g_mutex_unlock(&cb_info->api_mutex[api]);
1518 } else if (api == MUSE_CAMERA_CB_EVENT) {
1519 switch (cam_msg->event_class) {
1520 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1521 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event);
1523 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1524 cam_idle_event = g_new0(camera_idle_event_s, 1);
1525 if (cam_idle_event == NULL) {
1526 LOGE("t:%d cam_idle_event alloc failed", type);
1530 cam_idle_event->event = cam_msg->event;
1531 cam_idle_event->cb_info = cb_info;
1532 g_mutex_init(&cam_idle_event->event_mutex);
1533 memcpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg));
1535 /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, event, cam_idle_event);*/
1537 g_mutex_lock(&cb_info->idle_event_mutex);
1538 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1539 g_mutex_unlock(&cb_info->idle_event_mutex);
1541 g_idle_add_full(G_PRIORITY_DEFAULT,
1542 (GSourceFunc)_camera_idle_event_callback,
1543 (gpointer)cam_idle_event,
1547 LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
1551 LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1557 g_mutex_lock(&handler_info->mutex);
1560 /* remove remained event */
1561 while (!g_queue_is_empty(handler_info->queue)) {
1562 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1564 LOGD("t:%d remove camera message %p", type, cam_msg);
1568 LOGW("t:%d NULL camera message", type);
1572 g_mutex_unlock(&handler_info->mutex);
1574 LOGD("t:%d return", type);
1580 static void _camera_remove_idle_event_all(camera_cb_info_s *cb_info)
1582 camera_idle_event_s *cam_idle_event = NULL;
1583 gboolean ret = TRUE;
1585 gint64 end_time = 0;
1587 if (cb_info == NULL) {
1588 LOGE("cb_info is NULL");
1592 g_mutex_lock(&cb_info->idle_event_mutex);
1594 if (cb_info->idle_event_list == NULL) {
1595 LOGD("No remained idle event");
1596 g_mutex_unlock(&cb_info->idle_event_mutex);
1600 list = cb_info->idle_event_list;
1603 cam_idle_event = list->data;
1604 list = g_list_next(list);
1606 if (!cam_idle_event) {
1607 LOGW("Fail to remove idle event. The event is NULL");
1611 if (g_mutex_trylock(&cam_idle_event->event_mutex)) {
1612 ret = g_idle_remove_by_data(cam_idle_event);
1614 LOGD("remove idle event [%p], ret[%d]", cam_idle_event, ret);
1617 cam_idle_event->cb_info = NULL;
1618 LOGW("idle event %p will be called later", cam_idle_event);
1621 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1623 g_mutex_unlock(&cam_idle_event->event_mutex);
1626 g_mutex_clear(&cam_idle_event->event_mutex);
1628 g_free(cam_idle_event);
1629 cam_idle_event = NULL;
1631 LOGD("remove idle event done");
1637 LOGW("event lock failed. it's being called...");
1639 end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
1641 if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
1642 LOGW("signal received");
1647 g_list_free(cb_info->idle_event_list);
1648 cb_info->idle_event_list = NULL;
1650 g_mutex_unlock(&cb_info->idle_event_mutex);
1656 static void *_camera_msg_recv_func(gpointer data)
1663 int event_class = 0;
1667 char *recv_msg = NULL;
1668 char **parse_str = NULL;
1669 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
1672 LOGE("cb_info NULL");
1678 parse_str = (char **)malloc(sizeof(char *) * CAMERA_PARSE_STRING_SIZE);
1679 if (parse_str == NULL) {
1680 LOGE("parse_str malloc failed");
1684 for (i = 0 ; i < CAMERA_PARSE_STRING_SIZE ; i++) {
1685 parse_str[i] = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
1686 if (parse_str[i] == NULL) {
1687 LOGE("parse_str[%d] malloc failed", i);
1688 goto CB_HANDLER_EXIT;
1692 recv_msg = cb_info->recv_msg;
1694 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
1695 ret = muse_core_ipc_recv_msg(cb_info->fd, recv_msg);
1699 recv_msg[ret] = '\0';
1705 /*LOGD("recvMSg : %s, length : %d", recv_msg, ret);*/
1707 /* Need to split the combined entering msgs.
1708 This module supports up to 200 combined msgs. */
1709 for (str_pos = 0; str_pos < ret; str_pos++) {
1710 if (recv_msg[str_pos] == '}') {
1711 strncpy(parse_str[num_token], recv_msg + prev_pos, str_pos - prev_pos + 1);
1712 /*LOGD("splitted msg : [%s], Index : %d", parse_str[num_token], num_token);*/
1713 prev_pos = str_pos + 1;
1718 /*LOGD("num_token : %d", num_token);*/
1720 /* Re-construct to the useful single msg. */
1721 for (i = 0; i < num_token; i++) {
1722 if (i >= CAMERA_PARSE_STRING_SIZE) {
1723 LOGE("invalid token index %d", i);
1732 if (!muse_camera_msg_get(api, parse_str[i])) {
1733 LOGE("failed to get camera api");
1737 if (api == MUSE_CAMERA_CB_EVENT) {
1738 if (!muse_camera_msg_get(event, parse_str[i]) ||
1739 !muse_camera_msg_get(event_class, parse_str[i])) {
1740 LOGE("failed to get camera event or event_class [%s]", parse_str[i]);
1744 if (!muse_camera_msg_get(api_class, parse_str[i])) {
1745 LOGE("failed to get camera api_class [%s]", parse_str[i]);
1750 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1751 if (api >= MUSE_CAMERA_API_MAX) {
1752 LOGE("invalid api %d", api);
1756 g_mutex_lock(&cb_info->api_mutex[api]);
1758 if (!muse_camera_msg_get(ret, parse_str[i])) {
1759 LOGE("failed to get camera ret");
1760 g_mutex_unlock(&cb_info->api_mutex[api]);
1764 cb_info->api_ret[api] = ret;
1765 cb_info->api_activating[api] = 1;
1767 if (api == MUSE_CAMERA_API_CREATE) {
1768 if (ret != CAMERA_ERROR_NONE) {
1769 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1770 LOGE("camera create error 0x%x. close client cb handler", ret);
1772 } else if (api == MUSE_CAMERA_API_DESTROY) {
1773 if (ret == CAMERA_ERROR_NONE) {
1774 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1775 LOGD("camera destroy done. close client cb handler");
1777 } else if (api == MUSE_CAMERA_API_GET_FLASH_STATE) {
1778 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1779 LOGD("get flash state done. close client cb handler");
1782 g_cond_signal(&cb_info->api_cond[api]);
1783 g_mutex_unlock(&cb_info->api_mutex[api]);
1784 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
1785 camera_message_s *cam_msg = g_new0(camera_message_s, 1);
1786 if (cam_msg == NULL) {
1787 LOGE("failed to alloc cam_msg");
1792 cam_msg->event = event;
1793 cam_msg->event_class = event_class;
1795 memcpy(cam_msg->recv_msg, parse_str[i], sizeof(cam_msg->recv_msg));
1797 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1799 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1800 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1801 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1802 g_cond_signal(&cb_info->preview_cb_info.cond);
1803 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1804 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1805 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1806 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1807 g_cond_signal(&cb_info->capture_cb_info.cond);
1808 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1810 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1811 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1812 g_cond_signal(&cb_info->msg_handler_info.cond);
1813 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1816 LOGW("unknown camera api %d, class %d", api, api_class);
1822 LOGD("client cb exit");
1826 for (i = 0 ; i < CAMERA_PARSE_STRING_SIZE ; i++) {
1829 parse_str[i] = NULL;
1841 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
1842 int type, const char *thread_name, camera_cb_info_s *cb_info)
1844 if (!handler_info || !thread_name || !cb_info) {
1845 LOGE("t:%d NULL %p %p %p",
1846 type, handler_info, thread_name, cb_info);
1852 handler_info->type = type;
1853 handler_info->queue = g_queue_new();
1854 if (handler_info->queue == NULL) {
1855 LOGE("t:%d queue failed", type);
1859 g_mutex_init(&handler_info->mutex);
1860 g_cond_init(&handler_info->cond);
1862 handler_info->cb_info = (void *)cb_info;
1863 g_atomic_int_set(&handler_info->running, 1);
1865 handler_info->thread = g_thread_try_new(thread_name,
1866 _camera_msg_handler_func, (gpointer)handler_info, NULL);
1867 if (handler_info->thread == NULL) {
1868 LOGE("t:%d thread failed", type);
1870 g_mutex_clear(&handler_info->mutex);
1871 g_cond_clear(&handler_info->cond);
1872 g_queue_free(handler_info->queue);
1873 handler_info->queue = NULL;
1878 LOGD("t:%d done", type);
1884 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
1888 if (!handler_info) {
1889 LOGE("NULL handler");
1893 if (!handler_info->thread) {
1894 LOGW("thread is not created");
1898 type = handler_info->type;
1900 LOGD("t:%d thread %p", type, handler_info->thread);
1902 g_mutex_lock(&handler_info->mutex);
1903 g_atomic_int_set(&handler_info->running, 0);
1904 g_cond_signal(&handler_info->cond);
1905 g_mutex_unlock(&handler_info->mutex);
1907 g_thread_join(handler_info->thread);
1908 g_thread_unref(handler_info->thread);
1909 handler_info->thread = NULL;
1911 g_mutex_clear(&handler_info->mutex);
1912 g_cond_clear(&handler_info->cond);
1913 g_queue_free(handler_info->queue);
1914 handler_info->queue = NULL;
1916 LOGD("t:%d done", type);
1922 static camera_cb_info_s *_camera_client_callback_new(gint sockfd, bool need_msg_handler_thread)
1924 camera_cb_info_s *cb_info = NULL;
1927 g_return_val_if_fail(sockfd > 0, NULL);
1929 cb_info = g_new0(camera_cb_info_s, 1);
1930 if (cb_info == NULL) {
1931 LOGE("cb_info failed");
1935 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
1936 g_mutex_init(&cb_info->api_mutex[i]);
1937 g_cond_init(&cb_info->api_cond[i]);
1940 g_mutex_init(&cb_info->idle_event_mutex);
1941 g_cond_init(&cb_info->idle_event_cond);
1942 g_mutex_init(&cb_info->mp_data_mutex);
1943 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1944 g_mutex_init(&cb_info->evas_mutex);
1945 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1947 if (need_msg_handler_thread) {
1948 /* message handler thread */
1949 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
1950 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
1951 LOGE("msg_handler_info failed");
1955 /* message handler thread for preview callback */
1956 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
1957 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
1958 LOGE("preview_cb_info failed");
1962 /* message handler thread for capture callback */
1963 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
1964 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
1965 LOGE("capture_cb_info failed");
1970 cb_info->fd = sockfd;
1971 cb_info->preview_cb_flag = 0;
1972 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1973 cb_info->evas_info = NULL;
1974 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1976 /* message receive thread */
1977 g_atomic_int_set(&cb_info->msg_recv_running, 1);
1978 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
1979 _camera_msg_recv_func, (gpointer)cb_info, NULL);
1980 if (cb_info->msg_recv_thread == NULL) {
1981 LOGE("message receive thread creation failed");
1989 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
1990 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
1991 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
1993 g_mutex_clear(&cb_info->idle_event_mutex);
1994 g_cond_clear(&cb_info->idle_event_cond);
1995 g_mutex_clear(&cb_info->mp_data_mutex);
1996 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1997 g_mutex_clear(&cb_info->evas_mutex);
1998 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2000 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2001 g_mutex_clear(&cb_info->api_mutex[i]);
2002 g_cond_clear(&cb_info->api_cond[i]);
2012 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2016 g_return_if_fail(cb_info != NULL);
2018 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2020 g_thread_join(cb_info->msg_recv_thread);
2021 g_thread_unref(cb_info->msg_recv_thread);
2022 cb_info->msg_recv_thread = NULL;
2024 LOGD("msg_recv thread removed");
2026 /* destroy msg handler threads */
2027 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2028 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2029 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2031 g_mutex_clear(&cb_info->idle_event_mutex);
2032 g_cond_clear(&cb_info->idle_event_cond);
2033 g_mutex_clear(&cb_info->mp_data_mutex);
2034 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2035 g_mutex_clear(&cb_info->evas_mutex);
2036 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2038 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2039 g_mutex_clear(&cb_info->api_mutex[i]);
2040 g_cond_clear(&cb_info->api_cond[i]);
2043 if (cb_info->fd > -1) {
2044 muse_core_connection_close(cb_info->fd);
2048 if (cb_info->bufmgr) {
2049 tbm_bufmgr_deinit(cb_info->bufmgr);
2050 cb_info->bufmgr = NULL;
2052 if (cb_info->pkt_fmt) {
2053 media_format_unref(cb_info->pkt_fmt);
2054 cb_info->pkt_fmt = NULL;
2057 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2058 if (cb_info->evas_info)
2059 mm_evas_renderer_destroy(&cb_info->evas_info);
2060 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2062 cb_info->preview_cb_flag = 0;
2071 int _camera_start_evas_rendering(camera_h camera)
2073 int ret = CAMERA_ERROR_NONE;
2074 camera_cli_s *pc = (camera_cli_s *)camera;
2076 if (!pc || !pc->cb_info) {
2077 LOGE("NULL handle");
2078 return CAMERA_ERROR_INVALID_PARAMETER;
2083 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2084 LOGE("EVAS surface is not set");
2085 return CAMERA_ERROR_NONE;
2088 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2089 g_mutex_lock(&pc->cb_info->evas_mutex);
2091 /* set evas render flag as RUN */
2092 pc->cb_info->run_evas_render = true;
2093 ret = CAMERA_ERROR_NONE;
2095 g_mutex_unlock(&pc->cb_info->evas_mutex);
2096 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2097 LOGW("evas renderer is not supported");
2098 ret = CAMERA_ERROR_NOT_SUPPORTED;
2099 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2105 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2107 int ret = CAMERA_ERROR_NONE;
2108 camera_cli_s *pc = (camera_cli_s *)camera;
2110 if (!pc || !pc->cb_info) {
2111 LOGE("NULL handle");
2112 return CAMERA_ERROR_INVALID_PARAMETER;
2115 LOGD("stop - keep screen %d", keep_screen);
2117 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2118 LOGE("EVAS surface is not set");
2119 return CAMERA_ERROR_NONE;
2122 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2123 g_mutex_lock(&pc->cb_info->evas_mutex);
2125 /* set evas render flag as STOP and release buffers */
2126 pc->cb_info->run_evas_render = false;
2128 ret = mm_evas_renderer_retrieve_all_packets(pc->cb_info->evas_info, keep_screen);
2129 if (ret != MM_ERROR_NONE) {
2130 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2131 ret = CAMERA_ERROR_INVALID_OPERATION;
2134 g_mutex_unlock(&pc->cb_info->evas_mutex);
2135 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2136 LOGW("evas renderer is not supported");
2137 ret = CAMERA_ERROR_NOT_SUPPORTED;
2138 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2144 int camera_create(camera_device_e device, camera_h *camera)
2147 char *send_msg = NULL;
2149 int ret = CAMERA_ERROR_NONE;
2151 camera_cli_s *pc = NULL;
2152 tbm_bufmgr bufmgr = NULL;
2154 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2155 muse_core_api_module_e muse_module = MUSE_CAMERA;
2156 int device_type = (int)device;
2159 LOGE("NULL pointer");
2160 return CAMERA_ERROR_INVALID_PARAMETER;
2163 sock_fd = muse_core_client_new();
2165 LOGE("muse_core_client_new failed - returned fd %d", sock_fd);
2166 ret = CAMERA_ERROR_INVALID_OPERATION;
2172 send_msg = muse_core_msg_json_factory_new(api,
2173 MUSE_TYPE_INT, "module", muse_module,
2174 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2175 MUSE_TYPE_INT, "pid", pid,
2180 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2184 send_ret = muse_core_ipc_send_msg(sock_fd, send_msg);
2186 muse_core_msg_json_factory_free(send_msg);
2190 LOGE("send msg failed %d", errno);
2191 ret = CAMERA_ERROR_INVALID_OPERATION;
2195 pc = g_new0(camera_cli_s, 1);
2197 LOGE("camera_cli_s alloc failed");
2198 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2202 bufmgr = tbm_bufmgr_init(-1);
2203 if (bufmgr == NULL) {
2204 LOGE("get tbm bufmgr failed");
2205 ret = CAMERA_ERROR_INVALID_OPERATION;
2209 pc->cb_info = _camera_client_callback_new(sock_fd, true);
2210 if (pc->cb_info == NULL) {
2211 LOGE("cb_info alloc failed");
2212 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2218 LOGD("cb info : %d", pc->cb_info->fd);
2220 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2221 if (ret == CAMERA_ERROR_NONE) {
2222 intptr_t handle = 0;
2223 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2225 LOGE("Receiving Handle Failed!!");
2226 ret = CAMERA_ERROR_INVALID_OPERATION;
2230 pc->remote_handle = handle;
2231 pc->cb_info->bufmgr = bufmgr;
2233 ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL);
2234 if (ret != CAMERA_ERROR_NONE) {
2235 LOGE("init display failed 0x%x", ret);
2239 LOGD("camera create 0x%x", pc->remote_handle);
2240 *camera = (camera_h)pc;
2249 tbm_bufmgr_deinit(bufmgr);
2254 muse_core_connection_close(sock_fd);
2260 _camera_client_callback_destroy(pc->cb_info);
2267 LOGE("camera create error : 0x%x", ret);
2273 int camera_change_device(camera_h camera, camera_device_e device)
2275 int ret = CAMERA_ERROR_NONE;
2276 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2277 camera_cli_s *pc = (camera_cli_s *)camera;
2278 camera_msg_param param;
2280 if (!pc || !pc->cb_info) {
2281 LOGE("NULL handle");
2282 return CAMERA_ERROR_INVALID_PARAMETER;
2285 CAMERA_MSG_PARAM_SET(param, INT, device);
2287 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2293 int camera_destroy(camera_h camera)
2295 int ret = CAMERA_ERROR_NONE;
2296 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2297 camera_cli_s *pc = (camera_cli_s *)camera;
2299 if (!pc || !pc->cb_info) {
2300 LOGE("NULL handle");
2301 return CAMERA_ERROR_INVALID_PARAMETER;
2306 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2307 if (ret == CAMERA_ERROR_NONE) {
2308 _camera_remove_idle_event_all(pc->cb_info);
2309 _camera_client_callback_destroy(pc->cb_info);
2319 int camera_start_preview(camera_h camera)
2321 int ret = CAMERA_ERROR_NONE;
2322 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2323 camera_cli_s *pc = (camera_cli_s *)camera;
2325 if (!pc || !pc->cb_info) {
2326 LOGE("NULL handle");
2327 return CAMERA_ERROR_INVALID_PARAMETER;
2332 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT_LONG);
2333 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2334 ret = _camera_start_evas_rendering(camera);
2335 if (ret != CAMERA_ERROR_NONE) {
2336 LOGE("stop preview because of error");
2337 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, pc->cb_info, NULL, 0);
2341 LOGD("ret : 0x%x", ret);
2347 int camera_stop_preview(camera_h camera)
2349 int ret = CAMERA_ERROR_NONE;
2350 camera_cli_s *pc = (camera_cli_s *)camera;
2351 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2352 camera_state_e current_state = CAMERA_STATE_NONE;
2354 if (!pc || !pc->cb_info) {
2355 LOGE("NULL handle");
2356 return CAMERA_ERROR_INVALID_PARAMETER;
2361 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2362 ret = camera_get_state(camera, ¤t_state);
2363 if (ret != CAMERA_ERROR_NONE) {
2364 LOGE("failed to get current state 0x%x", ret);
2368 if (current_state == CAMERA_STATE_PREVIEW) {
2369 ret = _camera_stop_evas_rendering(camera, false);
2370 if (ret != CAMERA_ERROR_NONE)
2375 /* send stop preview message */
2376 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2378 if (ret != CAMERA_ERROR_NONE &&
2379 current_state == CAMERA_STATE_PREVIEW) {
2380 LOGW("restart evas rendering");
2381 _camera_start_evas_rendering(camera);
2384 LOGD("ret : 0x%x", ret);
2390 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2392 int ret = CAMERA_ERROR_NONE;
2393 camera_cli_s *pc = (camera_cli_s *)camera;
2394 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2396 if (!pc || !pc->cb_info) {
2397 LOGE("NULL handle");
2398 return CAMERA_ERROR_INVALID_PARAMETER;
2403 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2404 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2406 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2407 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2409 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2411 LOGD("ret : 0x%x", ret);
2417 bool camera_is_supported_continuous_capture(camera_h camera)
2419 int ret = CAMERA_ERROR_NONE;
2420 camera_cli_s *pc = (camera_cli_s *)camera;
2421 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2423 if (!pc || !pc->cb_info) {
2424 LOGE("NULL handle");
2425 return CAMERA_ERROR_INVALID_PARAMETER;
2430 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2432 LOGD("ret : 0x%x", ret);
2438 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)
2440 int ret = CAMERA_ERROR_NONE;
2441 camera_cli_s *pc = (camera_cli_s *)camera;
2442 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2443 camera_msg_param param;
2446 if (!pc || !pc->cb_info) {
2447 LOGE("NULL handle");
2448 return CAMERA_ERROR_INVALID_PARAMETER;
2453 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2454 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2455 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2457 value = (count << 16) | interval;
2458 CAMERA_MSG_PARAM_SET(param, INT, value);
2460 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2462 LOGD("ret : 0x%x", ret);
2468 int camera_stop_continuous_capture(camera_h camera)
2470 int ret = CAMERA_ERROR_NONE;
2471 camera_cli_s *pc = (camera_cli_s *)camera;
2472 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2474 if (!pc || !pc->cb_info) {
2475 LOGE("NULL handle");
2476 return CAMERA_ERROR_INVALID_PARAMETER;
2481 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2483 LOGD("ret : 0x%x", ret);
2489 bool camera_is_supported_face_detection(camera_h camera)
2491 int ret = CAMERA_ERROR_NONE;
2492 camera_cli_s *pc = (camera_cli_s *)camera;
2493 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2495 if (!pc || !pc->cb_info) {
2496 LOGE("NULL handle");
2497 return CAMERA_ERROR_INVALID_PARAMETER;
2502 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2504 LOGD("ret : 0x%x", ret);
2510 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2512 int ret = CAMERA_ERROR_NONE;
2513 camera_cli_s *pc = (camera_cli_s *)camera;
2514 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2516 if (!pc || !pc->cb_info) {
2517 LOGE("NULL handle");
2518 return CAMERA_ERROR_INVALID_PARAMETER;
2523 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2525 LOGD("ret : 0x%x", ret);
2531 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2533 int ret = CAMERA_ERROR_NONE;
2534 camera_cli_s *pc = (camera_cli_s *)camera;
2535 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2537 if (!pc || !pc->cb_info) {
2538 LOGE("NULL handle");
2539 return CAMERA_ERROR_INVALID_PARAMETER;
2544 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2546 LOGD("ret : 0x%x", ret);
2551 int camera_get_device_count(camera_h camera, int *device_count)
2553 int ret = CAMERA_ERROR_NONE;
2554 camera_cli_s *pc = (camera_cli_s *)camera;
2555 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2556 int get_device_count = 0;
2558 if (!pc || !pc->cb_info) {
2559 LOGE("NULL handle");
2560 return CAMERA_ERROR_INVALID_PARAMETER;
2565 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2567 if (ret == CAMERA_ERROR_NONE) {
2568 muse_camera_msg_get(get_device_count, pc->cb_info->recv_msg);
2569 *device_count = get_device_count;
2572 LOGD("ret : 0x%x", ret);
2577 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2579 int ret = CAMERA_ERROR_NONE;
2580 camera_cli_s *pc = (camera_cli_s *)camera;
2581 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2583 if (!pc || !pc->cb_info) {
2584 LOGE("NULL handle");
2585 return CAMERA_ERROR_INVALID_PARAMETER;
2590 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2591 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2593 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2595 LOGD("ret : 0x%x", ret);
2600 int camera_stop_face_detection(camera_h camera)
2602 int ret = CAMERA_ERROR_NONE;
2603 camera_cli_s *pc = (camera_cli_s *)camera;
2604 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
2606 if (!pc || !pc->cb_info) {
2607 LOGE("NULL handle");
2608 return CAMERA_ERROR_INVALID_PARAMETER;
2613 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2615 LOGD("ret : 0x%x", ret);
2620 int camera_get_state(camera_h camera, camera_state_e *state)
2622 int ret = CAMERA_ERROR_NONE;
2623 camera_cli_s *pc = (camera_cli_s *)camera;
2624 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
2625 int get_state = CAMERA_STATE_NONE;
2627 if (!pc || !pc->cb_info || !state) {
2628 LOGE("NULL pointer %p %p", pc, state);
2629 return CAMERA_ERROR_INVALID_PARAMETER;
2634 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2636 if (ret == CAMERA_ERROR_NONE) {
2637 muse_camera_msg_get(get_state, pc->cb_info->recv_msg);
2638 *state = (camera_state_e)get_state;
2641 LOGD("ret : 0x%x", ret);
2646 int camera_start_focusing(camera_h camera, bool continuous)
2648 int ret = CAMERA_ERROR_NONE;
2649 camera_cli_s *pc = (camera_cli_s *)camera;
2650 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
2651 camera_msg_param param;
2652 int is_continuous = (int)continuous;
2654 if (!pc || !pc->cb_info) {
2655 LOGE("NULL handle");
2656 return CAMERA_ERROR_INVALID_PARAMETER;
2661 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
2663 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2665 LOGD("ret : 0x%x", ret);
2670 int camera_cancel_focusing(camera_h camera)
2672 int ret = CAMERA_ERROR_NONE;
2673 camera_cli_s *pc = (camera_cli_s *)camera;
2674 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
2676 if (!pc || !pc->cb_info) {
2677 LOGE("NULL handle");
2678 return CAMERA_ERROR_INVALID_PARAMETER;
2681 LOGD("Enter, remote_handle : %x", pc->remote_handle);
2683 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2685 LOGD("ret : 0x%x", ret);
2690 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
2692 int ret = CAMERA_ERROR_NONE;
2693 void *set_display_handle = NULL;
2694 Evas_Object *obj = NULL;
2695 const char *object_type = NULL;
2696 camera_cli_s *pc = (camera_cli_s *)camera;
2697 camera_cb_info_s *cb_info = NULL;
2698 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
2699 camera_state_e current_state = CAMERA_STATE_NONE;
2700 camera_msg_param param;
2704 if (!pc || !pc->cb_info) {
2705 LOGE("NULL handle");
2706 return CAMERA_ERROR_INVALID_PARAMETER;
2709 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
2710 LOGE("invalid type %d", type);
2711 return CAMERA_ERROR_INVALID_PARAMETER;
2714 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
2715 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
2716 return CAMERA_ERROR_INVALID_PARAMETER;
2719 cb_info = (camera_cb_info_s *)pc->cb_info;
2721 ret = camera_get_state(camera, ¤t_state);
2722 if (ret != CAMERA_ERROR_NONE) {
2723 LOGE("failed to get current state 0x%x", ret);
2727 if (current_state != CAMERA_STATE_CREATED) {
2728 LOGE("INVALID_STATE : current %d", current_state);
2729 return CAMERA_ERROR_INVALID_STATE;
2732 LOGD("Enter - display : %p", display);
2734 if (type == CAMERA_DISPLAY_TYPE_NONE) {
2735 set_display_handle = 0;
2736 LOGD("display type NONE");
2738 obj = (Evas_Object *)display;
2739 object_type = evas_object_type_get(obj);
2741 if (type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
2742 /* get wayland parent id */
2743 if (_camera_get_wl_info(obj, &pc->wl_info) != CAMERA_ERROR_NONE) {
2744 LOGE("failed to get wayland info");
2745 return CAMERA_ERROR_INVALID_OPERATION;
2748 set_display_handle = (void *)&pc->wl_info;
2749 LOGD("display type OVERLAY : handle %p", set_display_handle);
2750 } else if (type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
2751 /* evas object surface */
2752 set_display_handle = (void *)display;
2753 LOGD("display type EVAS : handle %p", set_display_handle);
2755 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2756 g_mutex_lock(&cb_info->evas_mutex);
2758 if (cb_info->evas_info) {
2759 LOGW("destroy existed evas renderer %p", cb_info->evas_info);
2760 ret = mm_evas_renderer_destroy(&cb_info->evas_info);
2761 if (ret != MM_ERROR_NONE) {
2762 LOGE("failed to destroy evas renderer %p", cb_info->evas_info);
2763 g_mutex_unlock(&cb_info->evas_mutex);
2764 return CAMERA_ERROR_INVALID_OPERATION;
2768 /* create evas renderer */
2769 ret = mm_evas_renderer_create(&cb_info->evas_info, (Evas_Object *)set_display_handle);
2770 if (ret == MM_ERROR_NONE) {
2771 camera_flip_e flip = CAMERA_FLIP_NONE;
2772 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
2773 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
2780 camera_get_display_flip(camera, &flip);
2781 camera_get_display_mode(camera, &mode);
2782 camera_get_display_rotation(camera, &rotation);
2783 camera_is_display_visible(camera, &visible);
2784 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
2786 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
2787 flip, mode, rotation, visible, x, y, width, height);
2789 ret = mm_evas_renderer_set_flip(cb_info->evas_info, flip);
2790 ret |= mm_evas_renderer_set_geometry(cb_info->evas_info, mode);
2791 ret |= mm_evas_renderer_set_rotation(cb_info->evas_info, rotation);
2792 ret |= mm_evas_renderer_set_visible(cb_info->evas_info, visible);
2794 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
2795 ret |= mm_evas_renderer_set_roi_area(cb_info->evas_info, x, y, width, height);
2798 g_mutex_unlock(&cb_info->evas_mutex);
2800 if (ret != MM_ERROR_NONE) {
2801 LOGE("mm_evas_renderer error 0x%x", ret);
2802 return CAMERA_ERROR_INVALID_OPERATION;
2804 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2805 LOGE("EVAS surface is not supported");
2806 return CAMERA_ERROR_NOT_SUPPORTED;
2807 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2809 LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type);
2810 return CAMERA_ERROR_INVALID_PARAMETER;
2813 LOGE("failed to get evas object type from %p", obj);
2814 return CAMERA_ERROR_INVALID_PARAMETER;
2818 pc->display_handle = (intptr_t)set_display_handle;
2820 if (type == CAMERA_DISPLAY_TYPE_OVERLAY) {
2821 length = sizeof(camera_wl_info_s) / sizeof(int) + \
2822 (sizeof(camera_wl_info_s) % sizeof(int) ? 1 : 0);
2824 msg = muse_core_msg_json_factory_new(api,
2825 MUSE_TYPE_INT, "type", type,
2826 MUSE_TYPE_ARRAY, "wl_info", length, (int *)&pc->wl_info,
2829 LOGE("msg creation failed: api %d", api);
2830 return CAMERA_ERROR_OUT_OF_MEMORY;
2833 if (muse_core_ipc_send_msg(pc->cb_info->fd, msg) < 0) {
2834 LOGE("message send failed");
2835 ret = CAMERA_ERROR_INVALID_OPERATION;
2837 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2840 muse_core_msg_json_factory_free(msg);
2842 LOGD("wayland parent id : %d, window %d,%d,%dx%d",
2843 pc->wl_info.parent_id, pc->wl_info.window_x, pc->wl_info.window_y,
2844 pc->wl_info.window_width, pc->wl_info.window_height);
2846 CAMERA_MSG_PARAM_SET(param, INT, type);
2848 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2851 if (ret != CAMERA_ERROR_NONE)
2852 LOGE("set display error 0x%x", ret);
2853 else if (type == CAMERA_DISPLAY_TYPE_EVAS)
2854 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
2860 int camera_set_preview_resolution(camera_h camera, int width, int height)
2862 int ret = CAMERA_ERROR_NONE;
2863 camera_cli_s *pc = (camera_cli_s *)camera;
2864 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
2865 camera_msg_param param;
2868 if (!pc || !pc->cb_info) {
2869 LOGE("NULL handle");
2870 return CAMERA_ERROR_INVALID_PARAMETER;
2873 value = (width << 16) | height;
2874 CAMERA_MSG_PARAM_SET(param, INT, value);
2876 LOGD("%dx%d -> 0x%x", width, height, value);
2878 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2880 LOGD("ret : 0x%x", ret);
2886 int camera_set_capture_resolution(camera_h camera, int width, int height)
2888 int ret = CAMERA_ERROR_NONE;
2889 camera_cli_s *pc = (camera_cli_s *)camera;
2890 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
2891 camera_msg_param param;
2894 if (!pc || !pc->cb_info) {
2895 LOGE("NULL handle");
2896 return CAMERA_ERROR_INVALID_PARAMETER;
2901 value = (width << 16) | height;
2902 CAMERA_MSG_PARAM_SET(param, INT, value);
2904 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2906 LOGD("ret : 0x%x", ret);
2912 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
2914 int ret = CAMERA_ERROR_NONE;
2915 int set_format = (int)format;
2916 camera_cli_s *pc = (camera_cli_s *)camera;
2917 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
2918 camera_msg_param param;
2920 if (!pc || !pc->cb_info) {
2921 LOGE("NULL handle");
2922 return CAMERA_ERROR_INVALID_PARAMETER;
2925 LOGD("Enter - format %d", set_format);
2927 CAMERA_MSG_PARAM_SET(param, INT, set_format);
2929 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2931 LOGD("ret : 0x%x", ret);
2937 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
2939 int ret = CAMERA_ERROR_NONE;
2940 int set_format = (int)format;
2941 camera_msg_param param;
2942 camera_cli_s *pc = (camera_cli_s *)camera;
2943 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
2945 if (!pc || !pc->cb_info) {
2946 LOGE("NULL handle");
2947 return CAMERA_ERROR_INVALID_PARAMETER;
2950 LOGD("Enter - capture_format %d", set_format);
2952 CAMERA_MSG_PARAM_SET(param, INT, set_format);
2954 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2956 LOGD("ret : 0x%x", ret);
2962 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
2964 int ret = CAMERA_ERROR_NONE;
2965 camera_cli_s *pc = (camera_cli_s *)camera;
2966 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
2970 if (!pc || !pc->cb_info || !width || !height) {
2971 LOGE("NULL pointer %p %p %p", pc, width, height);
2972 return CAMERA_ERROR_INVALID_PARAMETER;
2977 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2979 if (ret == CAMERA_ERROR_NONE) {
2980 muse_camera_msg_get(get_width, pc->cb_info->recv_msg);
2981 muse_camera_msg_get(get_height, pc->cb_info->recv_msg);
2983 *height = get_height;
2986 LOGD("ret : 0x%x", ret);
2992 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
2994 int ret = CAMERA_ERROR_NONE;
2995 int set_rotation = (int)rotation;
2996 camera_cli_s *pc = (camera_cli_s *)camera;
2997 camera_msg_param param;
2999 if (!pc || !pc->cb_info) {
3000 LOGE("NULL handle");
3001 return CAMERA_ERROR_INVALID_PARAMETER;
3004 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3005 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3006 g_mutex_lock(&pc->cb_info->evas_mutex);
3008 ret = mm_evas_renderer_set_rotation(pc->cb_info->evas_info, rotation);
3010 g_mutex_unlock(&pc->cb_info->evas_mutex);
3012 if (ret != MM_ERROR_NONE) {
3013 LOGE("failed to set rotation for evas surface 0x%x", ret);
3014 return CAMERA_ERROR_INVALID_OPERATION;
3017 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3019 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3021 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3027 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3029 int ret = CAMERA_ERROR_NONE;
3030 int get_rotation = CAMERA_ROTATION_NONE;
3031 camera_cli_s *pc = (camera_cli_s *)camera;
3033 if (!pc || !pc->cb_info || !rotation) {
3034 LOGE("NULL pointer %p %p", pc, rotation);
3035 return CAMERA_ERROR_INVALID_PARAMETER;
3038 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3040 if (ret == CAMERA_ERROR_NONE) {
3041 muse_camera_msg_get(get_rotation, pc->cb_info->recv_msg);
3042 *rotation = (camera_rotation_e)get_rotation;
3049 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3051 int ret = CAMERA_ERROR_NONE;
3052 int set_flip = (int)flip;
3053 camera_cli_s *pc = (camera_cli_s *)camera;
3054 camera_msg_param param;
3056 if (!pc || !pc->cb_info) {
3057 LOGE("NULL handle");
3058 return CAMERA_ERROR_INVALID_PARAMETER;
3061 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3062 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3063 g_mutex_lock(&pc->cb_info->evas_mutex);
3065 ret = mm_evas_renderer_set_flip(pc->cb_info->evas_info, flip);
3067 g_mutex_unlock(&pc->cb_info->evas_mutex);
3069 if (ret != MM_ERROR_NONE) {
3070 LOGE("failed to set flip for evas surface 0x%x", ret);
3071 return CAMERA_ERROR_INVALID_OPERATION;
3074 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3076 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3078 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3084 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3086 int ret = CAMERA_ERROR_NONE;
3087 int get_flip = CAMERA_FLIP_NONE;
3088 camera_cli_s *pc = (camera_cli_s *)camera;
3090 if (!pc || !pc->cb_info || !flip) {
3091 LOGE("NULL pointer %p %p", pc, flip);
3092 return CAMERA_ERROR_INVALID_PARAMETER;
3095 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3097 if (ret == CAMERA_ERROR_NONE) {
3098 muse_camera_msg_get(get_flip, pc->cb_info->recv_msg);
3099 *flip = (camera_flip_e)get_flip;
3106 int camera_set_display_visible(camera_h camera, bool visible)
3108 int ret = CAMERA_ERROR_NONE;
3109 int set_visible = (int)visible;
3110 camera_cli_s *pc = (camera_cli_s *)camera;
3111 camera_msg_param param;
3113 if (!pc || !pc->cb_info) {
3114 LOGE("NULL handle");
3115 return CAMERA_ERROR_INVALID_PARAMETER;
3118 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3119 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3120 g_mutex_lock(&pc->cb_info->evas_mutex);
3122 ret = mm_evas_renderer_set_visible(pc->cb_info->evas_info, visible);
3124 g_mutex_unlock(&pc->cb_info->evas_mutex);
3126 if (ret != MM_ERROR_NONE) {
3127 LOGE("failed to set visible for evas surface 0x%x", ret);
3128 return CAMERA_ERROR_INVALID_OPERATION;
3131 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3133 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3135 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3141 int camera_is_display_visible(camera_h camera, bool *visible)
3143 int ret = CAMERA_ERROR_NONE;
3144 int get_visible = true;
3145 camera_cli_s *pc = (camera_cli_s *)camera;
3147 if (!pc || !pc->cb_info || !visible) {
3148 LOGE("NULL pointer %p %p", pc, visible);
3149 return CAMERA_ERROR_INVALID_PARAMETER;
3152 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3154 if (ret == CAMERA_ERROR_NONE) {
3155 muse_camera_msg_get(get_visible, pc->cb_info->recv_msg);
3156 *visible = (bool)get_visible;
3163 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3165 int ret = CAMERA_ERROR_NONE;
3166 int set_mode = (int)mode;
3167 camera_cli_s *pc = (camera_cli_s *)camera;
3168 camera_msg_param param;
3170 if (!pc || !pc->cb_info) {
3171 LOGE("NULL handle");
3172 return CAMERA_ERROR_INVALID_PARAMETER;
3175 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3176 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3177 g_mutex_lock(&pc->cb_info->evas_mutex);
3179 ret = mm_evas_renderer_set_geometry(pc->cb_info->evas_info, mode);
3181 g_mutex_unlock(&pc->cb_info->evas_mutex);
3183 if (ret != MM_ERROR_NONE) {
3184 LOGE("failed to set geometry for evas surface 0x%x", ret);
3185 return CAMERA_ERROR_INVALID_OPERATION;
3188 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3190 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3192 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3198 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3200 int ret = CAMERA_ERROR_NONE;
3201 int get_mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3202 camera_cli_s *pc = (camera_cli_s *)camera;
3204 if (!pc || !pc->cb_info || !mode) {
3205 LOGE("NULL pointer %p %p", pc, mode);
3206 return CAMERA_ERROR_INVALID_PARAMETER;
3209 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3211 if (ret == CAMERA_ERROR_NONE) {
3212 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
3213 *mode = (camera_display_mode_e)get_mode;
3220 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3222 int ret = CAMERA_ERROR_NONE;
3223 int set_hint = (int)hint;
3224 camera_cli_s *pc = (camera_cli_s *)camera;
3225 camera_msg_param param;
3227 if (!pc || !pc->cb_info) {
3228 LOGE("NULL handle");
3229 return CAMERA_ERROR_INVALID_PARAMETER;
3232 LOGD("Enter - hint %d", set_hint);
3234 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3236 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3242 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3244 int ret = CAMERA_ERROR_NONE;
3246 camera_cli_s *pc = (camera_cli_s *)camera;
3247 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3249 if (!pc || !pc->cb_info || !hint) {
3250 LOGE("NULL pointer %p %p", pc, hint);
3251 return CAMERA_ERROR_INVALID_PARAMETER;
3254 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3256 if (ret == CAMERA_ERROR_NONE) {
3257 muse_camera_msg_get(get_hint, pc->cb_info->recv_msg);
3258 *hint = (bool)get_hint;
3260 LOGD("display reuse hint %d", *hint);
3267 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3269 int ret = CAMERA_ERROR_NONE;
3270 camera_cli_s *pc = (camera_cli_s *)camera;
3271 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3275 if (!pc || !pc->cb_info || !width || !height) {
3276 LOGE("NULL pointer %p %p %p", pc, width, height);
3277 return CAMERA_ERROR_INVALID_PARAMETER;
3282 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3284 if (ret == CAMERA_ERROR_NONE) {
3285 muse_camera_msg_get(get_width, pc->cb_info->recv_msg);
3286 muse_camera_msg_get(get_height, pc->cb_info->recv_msg);
3288 *height = get_height;
3291 LOGD("ret : 0x%x", ret);
3297 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3299 int ret = CAMERA_ERROR_NONE;
3300 camera_cli_s *pc = (camera_cli_s *)camera;
3301 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3304 if (!pc || !pc->cb_info || !format) {
3305 LOGE("NULL pointer %p %p", pc, format);
3306 return CAMERA_ERROR_INVALID_PARAMETER;
3311 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3313 if (ret == CAMERA_ERROR_NONE) {
3314 muse_camera_msg_get(get_format, pc->cb_info->recv_msg);
3315 *format = (camera_pixel_format_e)get_format;
3318 LOGD("ret : 0x%x", ret);
3324 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3326 int ret = CAMERA_ERROR_NONE;
3327 camera_cli_s *pc = (camera_cli_s *)camera;
3328 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3331 if (!pc || !pc->cb_info || !format) {
3332 LOGE("NULL pointer %p %p", pc, format);
3333 return CAMERA_ERROR_INVALID_PARAMETER;
3338 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3340 if (ret == CAMERA_ERROR_NONE) {
3341 muse_camera_msg_get(get_format, pc->cb_info->recv_msg);
3342 *format = (camera_pixel_format_e)get_format;
3345 LOGD("ret : 0x%x", ret);
3351 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3353 int ret = CAMERA_ERROR_NONE;
3354 camera_cli_s *pc = (camera_cli_s *)camera;
3355 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3356 int get_facing_direction = 0;
3358 if (!pc || !pc->cb_info || !facing_direction) {
3359 LOGE("NULL pointer %p %p", pc, facing_direction);
3360 return CAMERA_ERROR_INVALID_PARAMETER;
3365 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3367 if (ret == CAMERA_ERROR_NONE) {
3368 muse_camera_msg_get(get_facing_direction, pc->cb_info->recv_msg);
3369 *facing_direction = (camera_facing_direction_e)get_facing_direction;
3372 LOGD("ret : 0x%x", ret);
3378 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3380 int ret = CAMERA_ERROR_NONE;
3381 camera_cli_s *pc = (camera_cli_s *)camera;
3382 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3384 if (!pc || !pc->cb_info || !callback) {
3385 LOGE("NULL pointer %p %p", pc, callback);
3386 return CAMERA_ERROR_INVALID_PARAMETER;
3391 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3392 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3394 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3396 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3398 LOGD("ret : 0x%x", ret);
3404 int camera_unset_preview_cb(camera_h camera)
3406 int ret = CAMERA_ERROR_NONE;
3407 camera_cli_s *pc = (camera_cli_s *)camera;
3408 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3410 if (!pc || !pc->cb_info) {
3411 LOGE("NULL handle");
3412 return CAMERA_ERROR_INVALID_PARAMETER;
3417 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3418 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3420 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3422 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3424 LOGD("ret : 0x%x", ret);
3430 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3432 int ret = CAMERA_ERROR_NONE;
3433 camera_cli_s *pc = (camera_cli_s *)camera;
3434 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3436 if (!pc || !pc->cb_info) {
3437 LOGE("NULL handle");
3438 return CAMERA_ERROR_INVALID_PARAMETER;
3441 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3442 LOGE("NOT SUPPORTED");
3443 return CAMERA_ERROR_NOT_SUPPORTED;
3446 if (callback == NULL) {
3447 LOGE("NULL callback");
3448 return CAMERA_ERROR_INVALID_PARAMETER;
3453 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3454 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3456 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3458 LOGD("ret : 0x%x", ret);
3464 int camera_unset_media_packet_preview_cb(camera_h camera)
3466 int ret = CAMERA_ERROR_NONE;
3467 camera_cli_s *pc = (camera_cli_s *)camera;
3468 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3470 if (!pc || !pc->cb_info) {
3471 LOGE("NULL handle");
3472 return CAMERA_ERROR_INVALID_PARAMETER;
3477 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3478 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3480 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3482 LOGD("ret : 0x%x", ret);
3488 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3490 int ret = CAMERA_ERROR_NONE;
3491 camera_cli_s *pc = (camera_cli_s *)camera;
3492 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3494 if (!pc || !pc->cb_info || !callback) {
3495 LOGE("NULL pointer %p %p", pc, callback);
3496 return CAMERA_ERROR_INVALID_PARAMETER;
3501 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3502 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3504 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3506 LOGD("ret : 0x%x", ret);
3512 int camera_unset_state_changed_cb(camera_h camera)
3514 int ret = CAMERA_ERROR_NONE;
3515 camera_cli_s *pc = (camera_cli_s *)camera;
3516 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3518 if (!pc || !pc->cb_info) {
3519 LOGE("NULL handle");
3520 return CAMERA_ERROR_INVALID_PARAMETER;
3525 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3526 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3528 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3530 LOGD("ret : 0x%x", ret);
3536 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3538 int ret = CAMERA_ERROR_NONE;
3539 camera_cli_s *pc = (camera_cli_s *)camera;
3540 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3542 if (!pc || !pc->cb_info || !callback) {
3543 LOGE("NULL pointer %p %p", pc, callback);
3544 return CAMERA_ERROR_INVALID_PARAMETER;
3549 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3550 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3552 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3554 LOGD("ret : 0x%x", ret);
3560 int camera_unset_interrupted_cb(camera_h camera)
3562 int ret = CAMERA_ERROR_NONE;
3563 camera_cli_s *pc = (camera_cli_s *)camera;
3564 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3566 if (!pc || !pc->cb_info) {
3567 LOGE("NULL handle");
3568 return CAMERA_ERROR_INVALID_PARAMETER;
3573 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3574 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3576 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3578 LOGD("ret : 0x%x", ret);
3584 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
3586 int ret = CAMERA_ERROR_NONE;
3587 camera_cli_s *pc = (camera_cli_s *)camera;
3588 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3590 if (!pc || !pc->cb_info || !callback) {
3591 LOGE("NULL pointer %p %p", pc, callback);
3592 return CAMERA_ERROR_INVALID_PARAMETER;
3597 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3598 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3600 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3602 LOGD("ret : 0x%x", ret);
3608 int camera_unset_focus_changed_cb(camera_h camera)
3610 int ret = CAMERA_ERROR_NONE;
3611 camera_cli_s *pc = (camera_cli_s *)camera;
3612 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
3614 if (!pc || !pc->cb_info) {
3615 LOGE("NULL handle");
3616 return CAMERA_ERROR_INVALID_PARAMETER;
3621 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3622 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3624 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3626 LOGD("ret : 0x%x", ret);
3632 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
3634 int ret = CAMERA_ERROR_NONE;
3635 camera_cli_s *pc = (camera_cli_s *)camera;
3636 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
3638 if (!pc || !pc->cb_info || !callback) {
3639 LOGE("NULL pointer %p %p", pc, callback);
3640 return CAMERA_ERROR_INVALID_PARAMETER;
3645 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
3646 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
3648 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3650 LOGD("ret : 0x%x", ret);
3656 int camera_unset_error_cb(camera_h camera)
3658 int ret = CAMERA_ERROR_NONE;
3659 camera_cli_s *pc = (camera_cli_s *)camera;
3660 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
3662 if (!pc || !pc->cb_info) {
3663 LOGE("NULL handle");
3664 return CAMERA_ERROR_INVALID_PARAMETER;
3669 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
3670 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
3672 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3674 LOGD("ret : 0x%x", ret);
3680 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
3682 int ret = CAMERA_ERROR_NONE;
3683 camera_cli_s *pc = (camera_cli_s *)camera;
3684 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
3686 if (!pc || !pc->cb_info || !foreach_cb) {
3687 LOGE("NULL pointer %p %p", pc, foreach_cb);
3688 return CAMERA_ERROR_INVALID_PARAMETER;
3693 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
3694 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
3696 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3698 LOGD("ret : 0x%x", ret);
3704 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
3706 int ret = CAMERA_ERROR_NONE;
3707 camera_cli_s *pc = (camera_cli_s *)camera;
3708 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
3710 if (!pc || !pc->cb_info || !foreach_cb) {
3711 LOGE("NULL pointer %p %p", pc, foreach_cb);
3712 return CAMERA_ERROR_INVALID_PARAMETER;
3717 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
3718 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
3720 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3722 LOGD("ret : 0x%x", ret);
3728 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
3730 int ret = CAMERA_ERROR_NONE;
3731 camera_cli_s *pc = (camera_cli_s *)camera;
3732 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
3734 if (!pc || !pc->cb_info || !foreach_cb) {
3735 LOGE("NULL pointer %p %p", pc, foreach_cb);
3736 return CAMERA_ERROR_INVALID_PARAMETER;
3741 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
3742 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
3744 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3746 LOGD("ret : 0x%x", ret);
3752 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
3754 int ret = CAMERA_ERROR_NONE;
3755 camera_cli_s *pc = (camera_cli_s *)camera;
3756 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
3758 if (!pc || !pc->cb_info || !foreach_cb) {
3759 LOGE("NULL pointer %p %p", pc, foreach_cb);
3760 return CAMERA_ERROR_INVALID_PARAMETER;
3765 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
3766 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
3768 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3770 LOGD("ret : 0x%x", ret);
3776 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
3778 int ret = CAMERA_ERROR_NONE;
3779 camera_cli_s *pc = (camera_cli_s *)camera;
3780 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
3784 if (!pc || !pc->cb_info || !width || !height) {
3785 LOGE("NULL pointer %p %p %p", pc, width, height);
3786 return CAMERA_ERROR_INVALID_PARAMETER;
3790 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3792 if (ret == CAMERA_ERROR_NONE) {
3793 muse_camera_msg_get(get_width, pc->cb_info->recv_msg);
3794 muse_camera_msg_get(get_height, pc->cb_info->recv_msg);
3796 *height = get_height;
3799 LOGD("ret : 0x%x", ret);
3805 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
3807 int ret = CAMERA_ERROR_NONE;
3808 camera_cli_s *pc = (camera_cli_s *)camera;
3809 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
3812 if (!pc || !pc->cb_info || !angle) {
3813 LOGE("NULL pointer %p %p", pc, angle);
3814 return CAMERA_ERROR_INVALID_PARAMETER;
3819 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3821 if (ret == CAMERA_ERROR_NONE) {
3822 muse_camera_msg_get(get_angle, pc->cb_info->recv_msg);
3826 LOGD("ret : 0x%x", ret);
3832 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
3834 int ret = CAMERA_ERROR_NONE;
3835 camera_cli_s *pc = (camera_cli_s *)camera;
3836 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
3837 camera_msg_param param;
3838 int set_mode = (int)mode;
3840 if (!pc || !pc->cb_info) {
3841 LOGE("NULL handle");
3842 return CAMERA_ERROR_INVALID_PARAMETER;
3847 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3849 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3851 LOGD("ret : 0x%x", ret);
3857 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
3859 int ret = CAMERA_ERROR_NONE;
3860 camera_cli_s *pc = (camera_cli_s *)camera;
3861 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
3864 if (!pc || !pc->cb_info || !mode) {
3865 LOGE("NULL pointer %p %p", pc, mode);
3866 return CAMERA_ERROR_INVALID_PARAMETER;
3871 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3873 if (ret == CAMERA_ERROR_NONE) {
3874 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
3875 *mode = (camera_attr_theater_mode_e)get_mode;
3878 LOGD("ret : 0x%x", ret);
3884 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
3886 int ret = CAMERA_ERROR_NONE;
3887 camera_cli_s *pc = (camera_cli_s *)camera;
3888 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
3890 if (!pc || !pc->cb_info || !foreach_cb) {
3891 LOGE("NULL pointer %p %p", pc, foreach_cb);
3892 return CAMERA_ERROR_INVALID_PARAMETER;
3897 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
3898 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
3900 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3902 LOGD("Finish, return :%x", ret);
3908 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
3910 int ret = CAMERA_ERROR_NONE;
3911 camera_cli_s *pc = (camera_cli_s *)camera;
3912 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
3913 camera_msg_param param;
3914 int set_fps = (int)fps;
3916 if (!pc || !pc->cb_info) {
3917 LOGE("NULL handle");
3918 return CAMERA_ERROR_INVALID_PARAMETER;
3923 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
3925 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3927 LOGD("ret : 0x%x", ret);
3933 int camera_attr_set_image_quality(camera_h camera, int quality)
3935 int ret = CAMERA_ERROR_NONE;
3936 camera_cli_s *pc = (camera_cli_s *)camera;
3937 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
3938 camera_msg_param param;
3940 if (!pc || !pc->cb_info) {
3941 LOGE("NULL handle");
3942 return CAMERA_ERROR_INVALID_PARAMETER;
3947 CAMERA_MSG_PARAM_SET(param, INT, quality);
3949 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3951 LOGD("ret : 0x%x", ret);
3957 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
3959 int ret = CAMERA_ERROR_NONE;
3960 camera_cli_s *pc = (camera_cli_s *)camera;
3961 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
3964 if (!pc || !pc->cb_info || !fps) {
3965 LOGE("NULL pointer %p %p", pc, fps);
3966 return CAMERA_ERROR_INVALID_PARAMETER;
3971 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3973 if (ret == CAMERA_ERROR_NONE) {
3974 muse_camera_msg_get(get_fps, pc->cb_info->recv_msg);
3975 *fps = (camera_attr_fps_e)get_fps;
3978 LOGD("ret : 0x%x", ret);
3984 int camera_attr_get_image_quality(camera_h camera, int *quality)
3986 int ret = CAMERA_ERROR_NONE;
3987 camera_cli_s *pc = (camera_cli_s *)camera;
3988 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
3989 int get_quality = 0;
3991 if (!pc || !pc->cb_info || !quality) {
3992 LOGE("NULL pointer %p %p", pc, quality);
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 muse_camera_msg_get(get_quality, pc->cb_info->recv_msg);
4002 *quality = get_quality;
4005 LOGD("ret : 0x%x", ret);
4011 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4013 int ret = CAMERA_ERROR_NONE;
4014 camera_cli_s *pc = (camera_cli_s *)camera;
4015 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4016 int get_bitrate = 0;
4018 if (!pc || !pc->cb_info || !bitrate) {
4019 LOGE("NULL pointer %p %p", pc, bitrate);
4020 return CAMERA_ERROR_INVALID_PARAMETER;
4025 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4027 if (ret == CAMERA_ERROR_NONE) {
4028 muse_camera_msg_get(get_bitrate, pc->cb_info->recv_msg);
4029 *bitrate = get_bitrate;
4032 LOGD("ret : 0x%x", ret);
4038 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4040 int ret = CAMERA_ERROR_NONE;
4041 camera_cli_s *pc = (camera_cli_s *)camera;
4042 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4043 camera_msg_param param;
4044 int set_bitrate = bitrate;
4046 if (!pc || !pc->cb_info) {
4047 LOGE("NULL handle");
4048 return CAMERA_ERROR_INVALID_PARAMETER;
4053 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4055 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4057 LOGD("ret : 0x%x", ret);
4063 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4065 int ret = CAMERA_ERROR_NONE;
4066 camera_cli_s *pc = (camera_cli_s *)camera;
4067 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4068 int get_gop_interval = 0;
4070 if (!pc || !pc->cb_info || !interval) {
4071 LOGE("NULL pointer %p %p", pc, interval);
4072 return CAMERA_ERROR_INVALID_PARAMETER;
4077 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4079 if (ret == CAMERA_ERROR_NONE) {
4080 muse_camera_msg_get(get_gop_interval, pc->cb_info->recv_msg);
4081 *interval = get_gop_interval;
4084 LOGD("ret : 0x%x", ret);
4090 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4092 int ret = CAMERA_ERROR_NONE;
4093 camera_cli_s *pc = (camera_cli_s *)camera;
4094 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4095 camera_msg_param param;
4096 int set_gop_interval = interval;
4098 if (!pc || !pc->cb_info) {
4099 LOGE("NULL handle");
4100 return CAMERA_ERROR_INVALID_PARAMETER;
4105 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4107 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4109 LOGD("ret : 0x%x", ret);
4115 int camera_attr_set_zoom(camera_h camera, int zoom)
4117 int ret = CAMERA_ERROR_NONE;
4118 camera_cli_s *pc = (camera_cli_s *)camera;
4119 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4120 camera_msg_param param;
4122 if (!pc || !pc->cb_info) {
4123 LOGE("NULL handle");
4124 return CAMERA_ERROR_INVALID_PARAMETER;
4127 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4129 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4131 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4133 LOGD("ret : 0x%x", ret);
4139 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4141 int ret = CAMERA_ERROR_NONE;
4142 camera_cli_s *pc = (camera_cli_s *)camera;
4143 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4144 camera_msg_param param;
4145 int set_mode = (int)mode;
4147 if (!pc || !pc->cb_info) {
4148 LOGE("NULL handle");
4149 return CAMERA_ERROR_INVALID_PARAMETER;
4152 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4154 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4156 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4162 int camera_attr_set_af_area(camera_h camera, int x, int y)
4164 int ret = CAMERA_ERROR_NONE;
4165 camera_cli_s *pc = (camera_cli_s *)camera;
4166 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4167 camera_msg_param param;
4170 if (!pc || !pc->cb_info) {
4171 LOGE("NULL handle");
4172 return CAMERA_ERROR_INVALID_PARAMETER;
4175 LOGD("Enter - %d,%d", x, y);
4177 value = (x << 16) | y;
4178 CAMERA_MSG_PARAM_SET(param, INT, value);
4180 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4182 LOGD("ret : 0x%x", ret);
4188 int camera_attr_clear_af_area(camera_h camera)
4190 int ret = CAMERA_ERROR_NONE;
4191 camera_cli_s *pc = (camera_cli_s *)camera;
4192 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4194 if (!pc || !pc->cb_info) {
4195 LOGE("NULL handle");
4196 return CAMERA_ERROR_INVALID_PARAMETER;
4201 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4203 LOGD("ret : 0x%x", ret);
4209 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4211 int ret = CAMERA_ERROR_NONE;
4212 camera_cli_s *pc = (camera_cli_s *)camera;
4213 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4214 camera_msg_param param;
4215 int set_mode = (int)mode;
4217 if (!pc || !pc->cb_info) {
4218 LOGE("NULL handle");
4219 return CAMERA_ERROR_INVALID_PARAMETER;
4224 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4226 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4228 LOGD("ret : 0x%x", ret);
4234 int camera_attr_set_exposure(camera_h camera, int value)
4236 int ret = CAMERA_ERROR_NONE;
4237 camera_cli_s *pc = (camera_cli_s *)camera;
4238 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4239 camera_msg_param param;
4241 if (!pc || !pc->cb_info) {
4242 LOGE("NULL handle");
4243 return CAMERA_ERROR_INVALID_PARAMETER;
4248 CAMERA_MSG_PARAM_SET(param, INT, value);
4250 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4252 LOGD("ret : 0x%x", ret);
4258 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4260 int ret = CAMERA_ERROR_NONE;
4261 camera_cli_s *pc = (camera_cli_s *)camera;
4262 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4263 camera_msg_param param;
4264 int set_iso = (int)iso;
4266 if (!pc || !pc->cb_info) {
4267 LOGE("NULL handle");
4268 return CAMERA_ERROR_INVALID_PARAMETER;
4273 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4275 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4277 LOGD("ret : 0x%x", ret);
4283 int camera_attr_set_brightness(camera_h camera, int level)
4285 int ret = CAMERA_ERROR_NONE;
4286 camera_cli_s *pc = (camera_cli_s *)camera;
4287 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4288 camera_msg_param param;
4290 if (!pc || !pc->cb_info) {
4291 LOGE("NULL handle");
4292 return CAMERA_ERROR_INVALID_PARAMETER;
4297 CAMERA_MSG_PARAM_SET(param, INT, level);
4299 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4301 LOGD("ret : 0x%x", ret);
4307 int camera_attr_set_contrast(camera_h camera, int level)
4309 int ret = CAMERA_ERROR_NONE;
4310 camera_cli_s *pc = (camera_cli_s *)camera;
4311 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4312 camera_msg_param param;
4314 if (!pc || !pc->cb_info) {
4315 LOGE("NULL handle");
4316 return CAMERA_ERROR_INVALID_PARAMETER;
4321 CAMERA_MSG_PARAM_SET(param, INT, level);
4323 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4325 LOGD("ret : 0x%x", ret);
4331 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4333 int ret = CAMERA_ERROR_NONE;
4334 camera_cli_s *pc = (camera_cli_s *)camera;
4335 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4336 camera_msg_param param;
4337 int set_whitebalance = (int)wb;
4339 if (!pc || !pc->cb_info) {
4340 LOGE("NULL handle");
4341 return CAMERA_ERROR_INVALID_PARAMETER;
4346 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4348 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4350 LOGD("ret : 0x%x", ret);
4356 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4358 int ret = CAMERA_ERROR_NONE;
4359 camera_cli_s *pc = (camera_cli_s *)camera;
4360 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4361 camera_msg_param param;
4362 int set_effect = (int)effect;
4364 if (!pc || !pc->cb_info) {
4365 LOGE("NULL handle");
4366 return CAMERA_ERROR_INVALID_PARAMETER;
4371 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4373 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4375 LOGD("ret : 0x%x", ret);
4381 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4383 int ret = CAMERA_ERROR_NONE;
4384 camera_cli_s *pc = (camera_cli_s *)camera;
4385 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4386 camera_msg_param param;
4387 int set_mode = (int)mode;
4389 if (!pc || !pc->cb_info) {
4390 LOGE("NULL handle");
4391 return CAMERA_ERROR_INVALID_PARAMETER;
4396 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4398 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4400 LOGD("ret : 0x%x", ret);
4406 int camera_attr_enable_tag(camera_h camera, bool enable)
4408 int ret = CAMERA_ERROR_NONE;
4409 camera_cli_s *pc = (camera_cli_s *)camera;
4410 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4411 camera_msg_param param;
4412 int set_enable = (int)enable;
4414 if (!pc || !pc->cb_info) {
4415 LOGE("NULL handle");
4416 return CAMERA_ERROR_INVALID_PARAMETER;
4421 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4423 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4425 LOGD("ret : 0x%x", ret);
4431 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4433 int ret = CAMERA_ERROR_NONE;
4434 camera_cli_s *pc = (camera_cli_s *)camera;
4435 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4436 camera_msg_param param;
4438 if (!pc || !pc->cb_info || !description) {
4439 LOGE("NULL pointer %p %p", pc, description);
4440 return CAMERA_ERROR_INVALID_PARAMETER;
4445 CAMERA_MSG_PARAM_SET(param, STRING, description);
4447 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4449 LOGD("ret : 0x%x", ret);
4455 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4457 int ret = CAMERA_ERROR_NONE;
4458 camera_cli_s *pc = (camera_cli_s *)camera;
4459 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4460 camera_msg_param param;
4461 int set_orientation = (int)orientation;
4463 if (!pc || !pc->cb_info) {
4464 LOGE("NULL handle");
4465 return CAMERA_ERROR_INVALID_PARAMETER;
4470 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4472 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4474 LOGD("ret : 0x%x", ret);
4480 int camera_attr_set_tag_software(camera_h camera, const char *software)
4482 int ret = CAMERA_ERROR_NONE;
4483 camera_cli_s *pc = (camera_cli_s *)camera;
4484 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4485 camera_msg_param param;
4487 if (!pc || !pc->cb_info || !software) {
4488 LOGE("NULL pointer %p %p", pc, software);
4489 return CAMERA_ERROR_INVALID_PARAMETER;
4492 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4494 CAMERA_MSG_PARAM_SET(param, STRING, software);
4496 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4498 LOGD("ret : 0x%x", ret);
4504 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4506 int ret = CAMERA_ERROR_NONE;
4507 camera_cli_s *pc = (camera_cli_s *)camera;
4508 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4509 double set_geotag[3] = {latitude, longitude, altitude};
4513 if (!pc || !pc->cb_info) {
4514 LOGE("NULL handle");
4515 return CAMERA_ERROR_INVALID_PARAMETER;
4520 length = sizeof(set_geotag) / sizeof(int) + \
4521 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4523 msg = muse_core_msg_json_factory_new(api,
4524 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4527 LOGE("msg creation failed: api %d", api);
4528 return CAMERA_ERROR_OUT_OF_MEMORY;
4531 if (muse_core_ipc_send_msg(pc->cb_info->fd, msg) < 0) {
4532 LOGE("message send failed");
4533 ret = CAMERA_ERROR_INVALID_OPERATION;
4535 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
4538 muse_core_msg_json_factory_free(msg);
4540 LOGD("ret : 0x%x", ret);
4546 int camera_attr_remove_geotag(camera_h camera)
4548 int ret = CAMERA_ERROR_NONE;
4549 camera_cli_s *pc = (camera_cli_s *)camera;
4550 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4552 if (!pc || !pc->cb_info) {
4553 LOGE("NULL handle");
4554 return CAMERA_ERROR_INVALID_PARAMETER;
4559 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4561 LOGD("ret : 0x%x", ret);
4567 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4569 int ret = CAMERA_ERROR_NONE;
4570 camera_cli_s *pc = (camera_cli_s *)camera;
4571 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
4572 camera_msg_param param;
4573 int set_mode = (int)mode;
4575 if (!pc || !pc->cb_info) {
4576 LOGE("NULL handle");
4577 return CAMERA_ERROR_INVALID_PARAMETER;
4582 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4584 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4586 LOGD("ret : 0x%x", ret);
4592 int camera_attr_get_zoom(camera_h camera, int *zoom)
4594 int ret = CAMERA_ERROR_NONE;
4595 camera_cli_s *pc = (camera_cli_s *)camera;
4596 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4599 if (!pc || !pc->cb_info || !zoom) {
4600 LOGE("NULL pointer %p %p", pc, zoom);
4601 return CAMERA_ERROR_INVALID_PARAMETER;
4606 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4608 if (ret == CAMERA_ERROR_NONE) {
4609 muse_camera_msg_get(get_zoom, pc->cb_info->recv_msg);
4613 LOGD("ret : 0x%x", ret);
4619 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
4621 int ret = CAMERA_ERROR_NONE;
4622 camera_cli_s *pc = (camera_cli_s *)camera;
4623 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
4627 if (!pc || !pc->cb_info || !min || !max) {
4628 LOGE("NULL pointer %p %p %p", pc, min, max);
4629 return CAMERA_ERROR_INVALID_PARAMETER;
4634 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4636 if (ret == CAMERA_ERROR_NONE) {
4637 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
4638 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
4643 LOGD("ret : 0x%x", ret);
4649 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
4651 int ret = CAMERA_ERROR_NONE;
4652 camera_cli_s *pc = (camera_cli_s *)camera;
4653 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
4656 if (!pc || !pc->cb_info || !mode) {
4657 LOGE("NULL pointer %p %p", pc, mode);
4658 return CAMERA_ERROR_INVALID_PARAMETER;
4663 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4665 if (ret == CAMERA_ERROR_NONE) {
4666 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
4667 *mode = (camera_attr_af_mode_e)get_mode;
4670 LOGD("ret : 0x%x", ret);
4676 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
4678 int ret = CAMERA_ERROR_NONE;
4679 camera_cli_s *pc = (camera_cli_s *)camera;
4680 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
4683 if (!pc || !pc->cb_info || !mode) {
4684 LOGE("NULL pointer %p %p", pc, mode);
4685 return CAMERA_ERROR_INVALID_PARAMETER;
4690 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4692 if (ret == CAMERA_ERROR_NONE) {
4693 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
4694 *mode = (camera_attr_exposure_mode_e)get_mode;
4697 LOGD("ret : 0x%x", ret);
4703 int camera_attr_get_exposure(camera_h camera, int *value)
4705 int ret = CAMERA_ERROR_NONE;
4706 camera_cli_s *pc = (camera_cli_s *)camera;
4707 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
4710 if (!pc || !pc->cb_info || !value) {
4711 LOGE("NULL pointer %p %p", pc, value);
4712 return CAMERA_ERROR_INVALID_PARAMETER;
4717 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4719 if (ret == CAMERA_ERROR_NONE) {
4720 muse_camera_msg_get(get_value, pc->cb_info->recv_msg);
4724 LOGD("ret : 0x%x", ret);
4730 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
4732 int ret = CAMERA_ERROR_NONE;
4733 camera_cli_s *pc = (camera_cli_s *)camera;
4734 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
4738 if (!pc || !pc->cb_info || !min || !max) {
4739 LOGE("NULL pointer %p %p %p", pc, min, max);
4740 return CAMERA_ERROR_INVALID_PARAMETER;
4745 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4747 if (ret == CAMERA_ERROR_NONE) {
4748 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
4749 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
4754 LOGD("ret : 0x%x", ret);
4760 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
4762 int ret = CAMERA_ERROR_NONE;
4763 camera_cli_s *pc = (camera_cli_s *)camera;
4764 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
4767 if (!pc || !pc->cb_info || !iso) {
4768 LOGE("NULL pointer %p %p", pc, iso);
4769 return CAMERA_ERROR_INVALID_PARAMETER;
4774 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4776 if (ret == CAMERA_ERROR_NONE) {
4777 muse_camera_msg_get(get_iso, pc->cb_info->recv_msg);
4778 *iso = (camera_attr_iso_e)get_iso;
4781 LOGD("ret : 0x%x", ret);
4787 int camera_attr_get_brightness(camera_h camera, int *level)
4789 int ret = CAMERA_ERROR_NONE;
4790 camera_cli_s *pc = (camera_cli_s *)camera;
4791 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
4794 if (!pc || !pc->cb_info || !level) {
4795 LOGE("NULL pointer %p %p", pc, level);
4796 return CAMERA_ERROR_INVALID_PARAMETER;
4801 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4803 if (ret == CAMERA_ERROR_NONE) {
4804 muse_camera_msg_get(get_level, pc->cb_info->recv_msg);
4808 LOGD("ret : 0x%x", ret);
4814 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
4816 int ret = CAMERA_ERROR_NONE;
4817 camera_cli_s *pc = (camera_cli_s *)camera;
4818 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
4822 if (!pc || !pc->cb_info || !min || !max) {
4823 LOGE("NULL pointer %p %p %p", pc, min, max);
4824 return CAMERA_ERROR_INVALID_PARAMETER;
4829 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4831 if (ret == CAMERA_ERROR_NONE) {
4832 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
4833 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
4838 LOGD("ret : 0x%x", ret);
4844 int camera_attr_get_contrast(camera_h camera, int *level)
4846 int ret = CAMERA_ERROR_NONE;
4847 camera_cli_s *pc = (camera_cli_s *)camera;
4848 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
4851 if (!pc || !pc->cb_info || !level) {
4852 LOGE("NULL pointer %p %p", pc, level);
4853 return CAMERA_ERROR_INVALID_PARAMETER;
4858 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4860 if (ret == CAMERA_ERROR_NONE) {
4861 muse_camera_msg_get(get_level, pc->cb_info->recv_msg);
4865 LOGD("ret : 0x%x", ret);
4871 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
4873 int ret = CAMERA_ERROR_NONE;
4874 camera_cli_s *pc = (camera_cli_s *)camera;
4875 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
4879 if (!pc || !pc->cb_info || !min || !max) {
4880 LOGE("NULL pointer %p %p %p", pc, min, max);
4881 return CAMERA_ERROR_INVALID_PARAMETER;
4886 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4888 if (ret == CAMERA_ERROR_NONE) {
4889 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
4890 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
4895 LOGD("ret : 0x%x", ret);
4901 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
4903 int ret = CAMERA_ERROR_NONE;
4904 camera_cli_s *pc = (camera_cli_s *)camera;
4905 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
4908 if (!pc || !pc->cb_info || !wb) {
4909 LOGE("NULL pointer %p %p", pc, wb);
4910 return CAMERA_ERROR_INVALID_PARAMETER;
4915 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4917 if (ret == CAMERA_ERROR_NONE) {
4918 muse_camera_msg_get(get_wb, pc->cb_info->recv_msg);
4919 *wb = (camera_attr_whitebalance_e)get_wb;
4922 LOGD("ret : 0x%x", ret);
4928 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
4930 int ret = CAMERA_ERROR_NONE;
4931 camera_cli_s *pc = (camera_cli_s *)camera;
4932 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
4935 if (!pc || !pc->cb_info || !effect) {
4936 LOGE("NULL pointer %p %p", pc, effect);
4937 return CAMERA_ERROR_INVALID_PARAMETER;
4942 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4944 if (ret == CAMERA_ERROR_NONE) {
4945 muse_camera_msg_get(get_effect, pc->cb_info->recv_msg);
4946 *effect = (camera_attr_effect_mode_e)get_effect;
4949 LOGD("ret : 0x%x", ret);
4955 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
4957 int ret = CAMERA_ERROR_NONE;
4958 camera_cli_s *pc = (camera_cli_s *)camera;
4959 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
4962 if (!pc || !pc->cb_info || !mode) {
4963 LOGE("NULL pointer %p %p", pc, mode);
4964 return CAMERA_ERROR_INVALID_PARAMETER;
4969 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4971 if (ret == CAMERA_ERROR_NONE) {
4972 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
4973 *mode = (camera_attr_scene_mode_e)get_mode;
4976 LOGD("ret : 0x%x", ret);
4982 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
4984 int ret = CAMERA_ERROR_NONE;
4985 camera_cli_s *pc = (camera_cli_s *)camera;
4986 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
4987 int get_enabled = 0;
4989 if (!pc || !pc->cb_info || !enable) {
4990 LOGE("NULL pointer %p %p", pc, enable);
4991 return CAMERA_ERROR_INVALID_PARAMETER;
4996 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4998 if (ret == CAMERA_ERROR_NONE) {
4999 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
5000 *enable = (bool)get_enabled;
5003 LOGD("ret : 0x%x", ret);
5009 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5011 int ret = CAMERA_ERROR_NONE;
5012 camera_cli_s *pc = (camera_cli_s *)camera;
5013 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5014 char get_description[MUSE_CAMERA_MSG_MAX_LENGTH] = {0, };
5016 if (!pc || !pc->cb_info || !description) {
5017 LOGE("NULL pointer %p %p", pc, description);
5018 return CAMERA_ERROR_INVALID_PARAMETER;
5023 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5025 if (ret == CAMERA_ERROR_NONE) {
5026 muse_camera_msg_get_string(get_description, pc->cb_info->recv_msg);
5027 *description = strdup(get_description);
5030 LOGD("ret : 0x%x", ret);
5036 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5038 int ret = CAMERA_ERROR_NONE;
5039 camera_cli_s *pc = (camera_cli_s *)camera;
5040 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5041 int get_orientation = 0;
5043 if (!pc || !pc->cb_info || !orientation) {
5044 LOGE("NULL pointer %p %p", pc, orientation);
5045 return CAMERA_ERROR_INVALID_PARAMETER;
5050 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5052 if (ret == CAMERA_ERROR_NONE) {
5053 muse_camera_msg_get(get_orientation, pc->cb_info->recv_msg);
5054 *orientation = (camera_attr_tag_orientation_e)get_orientation;
5057 LOGD("ret : 0x%x", ret);
5063 int camera_attr_get_tag_software(camera_h camera, char **software)
5065 int ret = CAMERA_ERROR_NONE;
5066 camera_cli_s *pc = (camera_cli_s *)camera;
5067 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5068 char get_software[MUSE_CAMERA_MSG_MAX_LENGTH] = {0, };
5070 if (!pc || !pc->cb_info || !software) {
5071 LOGE("NULL pointer %p %p", pc, software);
5072 return CAMERA_ERROR_INVALID_PARAMETER;
5077 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5079 if (ret == CAMERA_ERROR_NONE) {
5080 muse_camera_msg_get_string(get_software, pc->cb_info->recv_msg);
5081 *software = strdup(get_software);
5084 LOGD("ret : 0x%x", ret);
5090 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5092 int ret = CAMERA_ERROR_NONE;
5093 camera_cli_s *pc = (camera_cli_s *)camera;
5094 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5095 double get_geotag[3] = {0.0, };
5097 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5098 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5099 return CAMERA_ERROR_INVALID_PARAMETER;
5104 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5106 if (ret == CAMERA_ERROR_NONE) {
5107 muse_camera_msg_get_array(get_geotag, pc->cb_info->recv_msg);
5108 *latitude = get_geotag[0];
5109 *longitude = get_geotag[1];
5110 *altitude = get_geotag[2];
5113 LOGD("ret : 0x%x", ret);
5119 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5121 int ret = CAMERA_ERROR_NONE;
5122 camera_cli_s *pc = (camera_cli_s *)camera;
5123 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5126 if (!pc || !pc->cb_info || !mode) {
5127 LOGE("NULL pointer %p %p", pc, mode);
5128 return CAMERA_ERROR_INVALID_PARAMETER;
5133 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5135 if (ret == CAMERA_ERROR_NONE) {
5136 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
5137 *mode = (camera_attr_flash_mode_e)get_mode;
5140 LOGD("ret : 0x%x", ret);
5146 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5150 int ret = CAMERA_ERROR_NONE;
5152 camera_cli_s *pc = NULL;
5153 int get_flash_state = 0;
5155 /* create muse connection */
5156 muse_camera_api_e api = MUSE_CAMERA_API_GET_FLASH_STATE;
5157 muse_core_api_module_e muse_module = MUSE_CAMERA;
5158 int device_type = (int)device;
5161 LOGE("NULL pointer");
5162 return CAMERA_ERROR_INVALID_PARAMETER;
5165 sock_fd = muse_core_client_new();
5167 LOGE("muse_core_client_new failed");
5168 return CAMERA_ERROR_INVALID_OPERATION;
5171 msg = muse_core_msg_json_factory_new(api,
5172 MUSE_TYPE_INT, "module", muse_module,
5173 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
5177 ret = CAMERA_ERROR_OUT_OF_MEMORY;
5181 send_ret = muse_core_ipc_send_msg(sock_fd, msg);
5183 muse_core_msg_json_factory_free(msg);
5187 LOGE("send msg failed");
5188 ret = CAMERA_ERROR_INVALID_OPERATION;
5192 pc = g_new0(camera_cli_s, 1);
5194 LOGE("handle alloc failed");
5195 ret = CAMERA_ERROR_OUT_OF_MEMORY;
5199 pc->cb_info = _camera_client_callback_new(sock_fd, false);
5201 LOGE("cb_info alloc failed");
5202 ret = CAMERA_ERROR_OUT_OF_MEMORY;
5208 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
5210 if (ret == CAMERA_ERROR_NONE) {
5211 muse_camera_msg_get(get_flash_state, pc->cb_info->recv_msg);
5212 *state = (camera_flash_state_e)get_flash_state;
5215 LOGD("Flash state : %d", *state);
5218 /* release resources */
5221 _camera_client_callback_destroy(pc->cb_info);
5230 muse_core_connection_close(sock_fd);
5238 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5240 int ret = CAMERA_ERROR_NONE;
5241 camera_cli_s *pc = (camera_cli_s *)camera;
5242 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5244 if (!pc || !pc->cb_info || !foreach_cb) {
5245 LOGE("NULL pointer %p %p", pc, foreach_cb);
5246 return CAMERA_ERROR_INVALID_PARAMETER;
5251 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5252 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5254 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5256 LOGD("ret : 0x%x", ret);
5262 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5264 int ret = CAMERA_ERROR_NONE;
5265 camera_cli_s *pc = (camera_cli_s *)camera;
5266 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5268 if (!pc || !pc->cb_info || !foreach_cb) {
5269 LOGE("NULL pointer %p %p", pc, foreach_cb);
5270 return CAMERA_ERROR_INVALID_PARAMETER;
5275 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5276 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5278 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5280 LOGD("ret : 0x%x", ret);
5286 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5288 int ret = CAMERA_ERROR_NONE;
5289 camera_cli_s *pc = (camera_cli_s *)camera;
5290 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5292 if (!pc || !pc->cb_info || !foreach_cb) {
5293 LOGE("NULL pointer %p %p", pc, foreach_cb);
5294 return CAMERA_ERROR_INVALID_PARAMETER;
5299 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5300 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5302 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5304 LOGD("ret : 0x%x", ret);
5310 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5312 int ret = CAMERA_ERROR_NONE;
5313 camera_cli_s *pc = (camera_cli_s *)camera;
5314 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5316 if (!pc || !pc->cb_info || !foreach_cb) {
5317 LOGE("NULL pointer %p %p", pc, foreach_cb);
5318 return CAMERA_ERROR_INVALID_PARAMETER;
5323 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5324 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5326 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5328 LOGD("ret : 0x%x", ret);
5334 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5336 int ret = CAMERA_ERROR_NONE;
5337 camera_cli_s *pc = (camera_cli_s *)camera;
5338 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5340 if (!pc || !pc->cb_info || !foreach_cb) {
5341 LOGE("NULL pointer %p %p", pc, foreach_cb);
5342 return CAMERA_ERROR_INVALID_PARAMETER;
5347 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5348 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5350 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5352 LOGD("ret : 0x%x", ret);
5358 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5360 int ret = CAMERA_ERROR_NONE;
5361 camera_cli_s *pc = (camera_cli_s *)camera;
5362 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5364 if (!pc || !pc->cb_info || !foreach_cb) {
5365 LOGE("NULL pointer %p %p", pc, foreach_cb);
5366 return CAMERA_ERROR_INVALID_PARAMETER;
5371 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5372 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5374 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5376 LOGD("ret : 0x%x", ret);
5382 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5384 int ret = CAMERA_ERROR_NONE;
5385 camera_cli_s *pc = (camera_cli_s *)camera;
5386 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5388 if (!pc || !pc->cb_info || !foreach_cb) {
5389 LOGE("NULL pointer %p %p", pc, foreach_cb);
5390 return CAMERA_ERROR_INVALID_PARAMETER;
5395 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5396 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5398 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5400 LOGD("ret : 0x%x", ret);
5406 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5408 int ret = CAMERA_ERROR_NONE;
5409 camera_cli_s *pc = (camera_cli_s *)camera;
5410 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5412 if (!pc || !pc->cb_info || !foreach_cb) {
5413 LOGE("NULL pointer %p %p", pc, foreach_cb);
5414 return CAMERA_ERROR_INVALID_PARAMETER;
5419 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5420 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5422 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5424 LOGD("Enter, handle :%x", pc->remote_handle);
5430 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)
5432 int ret = CAMERA_ERROR_NONE;
5433 camera_cli_s *pc = (camera_cli_s *)camera;
5434 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5435 camera_msg_param param;
5438 if (!pc || !pc->cb_info || !foreach_cb) {
5439 LOGE("NULL pointer %p %p", pc, foreach_cb);
5440 return CAMERA_ERROR_INVALID_PARAMETER;
5445 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5446 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5448 value = (width << 16) | height;
5449 CAMERA_MSG_PARAM_SET(param, INT, value);
5451 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5453 LOGD("ret : 0x%x", ret);
5459 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5461 int ret = CAMERA_ERROR_NONE;
5462 camera_cli_s *pc = (camera_cli_s *)camera;
5463 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5465 if (!pc || !pc->cb_info || !foreach_cb) {
5466 LOGE("NULL pointer %p %p", pc, foreach_cb);
5467 return CAMERA_ERROR_INVALID_PARAMETER;
5472 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5473 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5475 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5477 LOGD("ret : 0x%x", ret);
5483 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5485 int ret = CAMERA_ERROR_NONE;
5486 camera_cli_s *pc = (camera_cli_s *)camera;
5487 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5489 if (!pc || !pc->cb_info || !foreach_cb) {
5490 LOGE("NULL pointer %p %p", pc, foreach_cb);
5491 return CAMERA_ERROR_INVALID_PARAMETER;
5496 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5497 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5499 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5501 LOGD("ret : 0x%x", ret);
5507 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5509 int ret = CAMERA_ERROR_NONE;
5510 camera_cli_s *pc = (camera_cli_s *)camera;
5511 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5512 camera_msg_param param;
5513 int set_rotation = (int)rotation;
5515 if (!pc || !pc->cb_info) {
5516 LOGE("NULL handle");
5517 return CAMERA_ERROR_INVALID_PARAMETER;
5522 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5524 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5526 LOGD("ret : 0x%x", ret);
5532 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5534 int ret = CAMERA_ERROR_NONE;
5535 camera_cli_s *pc = (camera_cli_s *)camera;
5536 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5537 int get_rotation = 0;
5539 if (!pc || !pc->cb_info || !rotation) {
5540 LOGE("NULL pointer %p %p", pc, rotation);
5541 return CAMERA_ERROR_INVALID_PARAMETER;
5546 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5548 if (ret == CAMERA_ERROR_NONE) {
5549 muse_camera_msg_get(get_rotation, pc->cb_info->recv_msg);
5550 *rotation = (camera_rotation_e)get_rotation;
5553 LOGD("ret : 0x%x", ret);
5559 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5561 int ret = CAMERA_ERROR_NONE;
5562 camera_cli_s *pc = (camera_cli_s *)camera;
5563 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5564 camera_msg_param param;
5565 int set_flip = (int)flip;
5567 if (!pc || !pc->cb_info) {
5568 LOGE("NULL handle");
5569 return CAMERA_ERROR_INVALID_PARAMETER;
5574 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5576 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5578 LOGD("ret : 0x%x", ret);
5584 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5586 int ret = CAMERA_ERROR_NONE;
5587 camera_cli_s *pc = (camera_cli_s *)camera;
5588 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5591 if (!pc || !pc->cb_info || !flip) {
5592 LOGE("NULL pointer %p %p", pc, flip);
5593 return CAMERA_ERROR_INVALID_PARAMETER;
5598 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5600 if (ret == CAMERA_ERROR_NONE) {
5601 muse_camera_msg_get(get_flip, pc->cb_info->recv_msg);
5602 *flip = (camera_flip_e)get_flip;
5605 LOGD("ret : 0x%x", ret);
5610 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
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_SET_HDR_MODE;
5615 camera_msg_param param;
5616 int set_mode = (int)mode;
5618 if (!pc || !pc->cb_info) {
5619 LOGE("NULL handle");
5620 return CAMERA_ERROR_INVALID_PARAMETER;
5625 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5627 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5629 LOGD("ret : 0x%x", ret);
5635 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5637 int ret = CAMERA_ERROR_NONE;
5638 camera_cli_s *pc = (camera_cli_s *)camera;
5639 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5642 if (!pc || !pc->cb_info || !mode) {
5643 LOGE("NULL pointer %p %p", pc, mode);
5644 return CAMERA_ERROR_INVALID_PARAMETER;
5649 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5651 if (ret == CAMERA_ERROR_NONE) {
5652 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
5653 *mode = (camera_attr_hdr_mode_e)get_mode;
5656 LOGD("ret : 0x%x", ret);
5662 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5664 int ret = CAMERA_ERROR_NONE;
5665 camera_cli_s *pc = (camera_cli_s *)camera;
5666 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
5668 if (!pc || !pc->cb_info) {
5669 LOGE("NULL handle");
5670 return CAMERA_ERROR_INVALID_PARAMETER;
5675 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5677 LOGD("ret : 0x%x", ret);
5683 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5685 int ret = CAMERA_ERROR_NONE;
5686 camera_cli_s *pc = (camera_cli_s *)camera;
5687 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5689 if (!pc || !pc->cb_info) {
5690 LOGE("NULL handle");
5691 return CAMERA_ERROR_INVALID_PARAMETER;
5696 if (!camera_attr_is_supported_hdr_capture(camera)) {
5697 LOGE("HDR not supported");
5698 return CAMERA_ERROR_NOT_SUPPORTED;
5702 LOGE("NULL callback");
5703 return CAMERA_ERROR_INVALID_PARAMETER;
5706 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5707 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5709 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5711 LOGD("ret : 0x%x", ret);
5717 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5719 int ret = CAMERA_ERROR_NONE;
5720 camera_cli_s *pc = (camera_cli_s *)camera;
5721 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5723 if (!pc || !pc->cb_info) {
5724 LOGE("NULL handle");
5725 return CAMERA_ERROR_INVALID_PARAMETER;
5730 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5731 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5733 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5735 LOGD("ret : 0x%x", ret);
5741 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
5743 int ret = CAMERA_ERROR_NONE;
5744 camera_cli_s *pc = (camera_cli_s *)camera;
5745 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
5746 camera_msg_param param;
5747 int set_enable = (int)enable;
5749 if (!pc || !pc->cb_info) {
5750 LOGE("NULL handle");
5751 return CAMERA_ERROR_INVALID_PARAMETER;
5756 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
5758 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5760 LOGD("ret : 0x%x", ret);
5766 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
5768 int ret = CAMERA_ERROR_NONE;
5769 camera_cli_s *pc = (camera_cli_s *)camera;
5770 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
5771 int get_enabled = 0;
5773 if (!pc || !pc->cb_info || !enabled) {
5774 LOGE("NULL pointer %p %p", pc, enabled);
5775 return CAMERA_ERROR_INVALID_PARAMETER;
5780 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5782 if (ret == CAMERA_ERROR_NONE) {
5783 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
5784 *enabled = (bool)get_enabled;
5787 LOGD("ret : 0x%x", ret);
5793 bool camera_attr_is_supported_anti_shake(camera_h camera)
5795 int ret = CAMERA_ERROR_NONE;
5796 camera_cli_s *pc = (camera_cli_s *)camera;
5797 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
5799 if (!pc || !pc->cb_info) {
5800 LOGE("NULL handle");
5801 return CAMERA_ERROR_INVALID_PARAMETER;
5806 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5808 LOGD("ret : 0x%x", ret);
5814 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
5816 int ret = CAMERA_ERROR_NONE;
5817 camera_cli_s *pc = (camera_cli_s *)camera;
5818 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
5819 camera_msg_param param;
5820 int set_enable = (int)enable;
5822 if (!pc || !pc->cb_info) {
5823 LOGE("NULL handle");
5824 return CAMERA_ERROR_INVALID_PARAMETER;
5829 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
5831 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5833 LOGD("ret : 0x%x", ret);
5839 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
5841 int ret = CAMERA_ERROR_NONE;
5842 camera_cli_s *pc = (camera_cli_s *)camera;
5843 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
5844 int get_enabled = 0;
5846 if (!pc || !pc->cb_info || !enabled) {
5847 LOGE("NULL pointer %p %p", pc, enabled);
5848 return CAMERA_ERROR_INVALID_PARAMETER;
5853 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5855 if (ret == CAMERA_ERROR_NONE) {
5856 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
5857 *enabled = (bool)get_enabled;
5860 LOGD("ret : 0x%x", ret);
5866 bool camera_attr_is_supported_video_stabilization(camera_h camera)
5868 int ret = CAMERA_ERROR_NONE;
5869 camera_cli_s *pc = (camera_cli_s *)camera;
5870 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
5872 if (!pc || !pc->cb_info) {
5873 LOGE("NULL handle");
5874 return CAMERA_ERROR_INVALID_PARAMETER;
5879 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5881 LOGD("ret : 0x%x", ret);
5887 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
5889 int ret = CAMERA_ERROR_NONE;
5890 camera_cli_s *pc = (camera_cli_s *)camera;
5891 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
5892 camera_msg_param param;
5893 int set_enable = (int)enable;
5895 if (!pc || !pc->cb_info) {
5896 LOGE("NULL handle");
5897 return CAMERA_ERROR_INVALID_PARAMETER;
5902 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
5904 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5906 LOGD("ret : 0x%x", ret);
5912 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
5914 int ret = CAMERA_ERROR_NONE;
5915 camera_cli_s *pc = (camera_cli_s *)camera;
5916 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
5917 int get_enabled = 0;
5919 if (!pc || !pc->cb_info || !enabled) {
5920 LOGE("NULL pointer %p %p", pc, enabled);
5921 return CAMERA_ERROR_INVALID_PARAMETER;
5926 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5928 if (ret == CAMERA_ERROR_NONE) {
5929 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
5930 *enabled = (bool)get_enabled;
5933 LOGD("ret : 0x%x", ret);
5939 bool camera_attr_is_supported_auto_contrast(camera_h camera)
5941 int ret = CAMERA_ERROR_NONE;
5942 camera_cli_s *pc = (camera_cli_s *)camera;
5943 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
5945 if (!pc || !pc->cb_info) {
5946 LOGE("NULL handle");
5947 return CAMERA_ERROR_INVALID_PARAMETER;
5952 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5954 LOGD("ret : 0x%x", ret);
5960 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
5962 int ret = CAMERA_ERROR_NONE;
5963 camera_cli_s *pc = (camera_cli_s *)camera;
5964 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
5965 camera_msg_param param;
5966 int set_disable = (int)disable;
5968 if (!pc || !pc->cb_info) {
5969 LOGE("NULL handle");
5970 return CAMERA_ERROR_INVALID_PARAMETER;
5975 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
5977 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5979 LOGD("ret : 0x%x", ret);
5985 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
5987 int ret = CAMERA_ERROR_NONE;
5988 camera_cli_s *pc = (camera_cli_s *)camera;
5989 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
5990 camera_msg_param param;
5991 int set_move_type = (int)move_type;
5994 if (!pc || !pc->cb_info) {
5995 LOGE("NULL handle");
5996 return CAMERA_ERROR_INVALID_PARAMETER;
6001 value = (set_move_type << 16) | pan_step;
6002 CAMERA_MSG_PARAM_SET(param, INT, value);
6004 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6006 LOGD("ret : 0x%x", ret);
6012 int camera_attr_get_pan(camera_h camera, int *pan_step)
6014 int ret = CAMERA_ERROR_NONE;
6015 camera_cli_s *pc = (camera_cli_s *)camera;
6016 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6017 int get_pan_step = 0;
6019 if (!pc || !pc->cb_info || !pan_step) {
6020 LOGE("NULL pointer %p %p", pc, pan_step);
6021 return CAMERA_ERROR_INVALID_PARAMETER;
6026 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6028 if (ret == CAMERA_ERROR_NONE) {
6029 muse_camera_msg_get(get_pan_step, pc->cb_info->recv_msg);
6030 *pan_step = get_pan_step;
6033 LOGD("ret : 0x%x", ret);
6039 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6041 int ret = CAMERA_ERROR_NONE;
6042 camera_cli_s *pc = (camera_cli_s *)camera;
6043 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6047 if (!pc || !pc->cb_info || !min || !max) {
6048 LOGE("NULL pointer %p %p", pc, min, max);
6049 return CAMERA_ERROR_INVALID_PARAMETER;
6054 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6056 if (ret == CAMERA_ERROR_NONE) {
6057 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
6058 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
6063 LOGD("ret : 0x%x", ret);
6069 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6071 int ret = CAMERA_ERROR_NONE;
6072 camera_cli_s *pc = (camera_cli_s *)camera;
6073 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6074 camera_msg_param param;
6075 int set_move_type = (int)move_type;
6078 if (!pc || !pc->cb_info) {
6079 LOGE("NULL handle");
6080 return CAMERA_ERROR_INVALID_PARAMETER;
6085 value = (set_move_type << 16) | tilt_step;
6086 CAMERA_MSG_PARAM_SET(param, INT, value);
6088 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6090 LOGD("ret : 0x%x", ret);
6096 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6098 int ret = CAMERA_ERROR_NONE;
6099 camera_cli_s *pc = (camera_cli_s *)camera;
6100 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6101 int get_tilt_step = 0;
6103 if (!pc || !pc->cb_info || !tilt_step) {
6104 LOGE("NULL pointer %p %p", pc, tilt_step);
6105 return CAMERA_ERROR_INVALID_PARAMETER;
6110 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6112 if (ret == CAMERA_ERROR_NONE) {
6113 muse_camera_msg_get(get_tilt_step, pc->cb_info->recv_msg);
6114 *tilt_step = get_tilt_step;
6117 LOGD("ret : 0x%x", ret);
6123 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6125 int ret = CAMERA_ERROR_NONE;
6126 camera_cli_s *pc = (camera_cli_s *)camera;
6127 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6131 if (!pc || !pc->cb_info || !min || !max) {
6132 LOGE("NULL pointer %p %p %p", pc, min, max);
6133 return CAMERA_ERROR_INVALID_PARAMETER;
6138 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6140 if (ret == CAMERA_ERROR_NONE) {
6141 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
6142 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
6147 LOGD("ret : 0x%x", ret);
6153 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6155 int ret = CAMERA_ERROR_NONE;
6156 camera_cli_s *pc = (camera_cli_s *)camera;
6157 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6158 camera_msg_param param;
6159 int set_ptz_type = (int)ptz_type;
6161 if (!pc || !pc->cb_info) {
6162 LOGE("NULL handle");
6163 return CAMERA_ERROR_INVALID_PARAMETER;
6168 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6170 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6172 LOGD("ret : 0x%x", ret);
6178 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6180 int ret = CAMERA_ERROR_NONE;
6181 camera_cli_s *pc = (camera_cli_s *)camera;
6182 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6184 if (!pc || !pc->cb_info || !foreach_cb) {
6185 LOGE("NULL pointer %p %p", pc, foreach_cb);
6186 return CAMERA_ERROR_INVALID_PARAMETER;
6191 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6192 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6194 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6196 LOGD("ret : 0x%x", ret);
6202 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6204 int ret = CAMERA_ERROR_NONE;
6205 camera_cli_s *pc = (camera_cli_s *)camera;
6206 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6207 int set_display_roi_area[4] = {x, y, width, height};
6211 if (!pc || !pc->cb_info) {
6212 LOGE("NULL handle");
6213 return CAMERA_ERROR_INVALID_PARAMETER;
6218 #ifdef TIZEN_FEATURE_EVAS_RENDERER
6219 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6220 g_mutex_lock(&pc->cb_info->evas_mutex);
6222 ret = mm_evas_renderer_set_roi_area(pc->cb_info->evas_info, x, y, width, height);
6224 g_mutex_unlock(&pc->cb_info->evas_mutex);
6226 if (ret != MM_ERROR_NONE) {
6227 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6228 return CAMERA_ERROR_INVALID_OPERATION;
6231 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
6233 length = sizeof(set_display_roi_area) / sizeof(int) + \
6234 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6236 msg = muse_core_msg_json_factory_new(api,
6237 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6240 LOGE("msg creation failed: api %d", api);
6241 return CAMERA_ERROR_OUT_OF_MEMORY;
6244 if (muse_core_ipc_send_msg(pc->cb_info->fd, msg) < 0) {
6245 LOGE("message send failed");
6246 ret = CAMERA_ERROR_INVALID_OPERATION;
6248 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6251 muse_core_msg_json_factory_free(msg);
6253 LOGD("ret : 0x%x", ret);
6259 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6261 camera_cli_s *pc = (camera_cli_s *)camera;
6262 int ret = CAMERA_ERROR_NONE;
6263 int get_display_roi_area[4] = {0,};
6264 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6266 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6267 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6268 return CAMERA_ERROR_INVALID_PARAMETER;
6273 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6275 if (ret == CAMERA_ERROR_NONE) {
6276 muse_camera_msg_get_array(get_display_roi_area, pc->cb_info->recv_msg);
6277 *x = get_display_roi_area[0];
6278 *y = get_display_roi_area[1];
6279 *width = get_display_roi_area[2];
6280 *height = get_display_roi_area[3];
6283 LOGD("ret : 0x%x", ret);