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 if (!cb_info->is_server_connected) {
285 LOGE("server is disconnected");
286 return CAMERA_ERROR_SERVICE_DISCONNECTED;
289 g_mutex_lock(&(cb_info->api_mutex[api]));
291 if (cb_info->api_activating[api] == 0) {
292 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
293 if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
294 ret = cb_info->api_ret[api];
295 cb_info->api_activating[api] = 0;
297 /*LOGD("return value : 0x%x", ret);*/
299 ret = CAMERA_ERROR_INVALID_OPERATION;
300 LOGE("api %d was TIMED OUT!", api);
303 ret = cb_info->api_ret[api];
304 cb_info->api_activating[api] = 0;
306 /*LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);*/
309 g_mutex_unlock(&(cb_info->api_mutex[api]));
311 if (ret != CAMERA_ERROR_NONE) {
312 LOGE("api %d : error 0x%x", api, ret);
314 if (ret == CAMERA_ERROR_SOUND_POLICY)
315 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
316 else if (ret == CAMERA_ERROR_SOUND_POLICY_BY_CALL)
317 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
318 else if (ret == CAMERA_ERROR_SOUND_POLICY_BY_ALARM)
319 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
326 static void _camera_msg_send(int api, camera_cb_info_s *cb_info,
327 int *ret, int timeout)
333 LOGE("NULL info - api %d", api);
336 *ret = CAMERA_ERROR_INVALID_PARAMETER;
341 msg = muse_core_msg_json_factory_new(api, NULL);
343 LOGE("msg failed: api %d", api);
346 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
351 /*LOGD("send msg %s", msg);*/
353 if (cb_info->is_server_connected)
354 send_ret = muse_core_ipc_send_msg(cb_info->fd, msg);
357 LOGE("msg send failed");
359 *ret = CAMERA_ERROR_INVALID_OPERATION;
362 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
365 muse_core_msg_json_factory_free(msg);
371 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
372 int *ret, camera_msg_param *param, int timeout)
377 if (!cb_info || !param) {
378 LOGE("invalid pointer : api %d - %p %p", api, cb_info, param);
381 *ret = CAMERA_ERROR_INVALID_PARAMETER;
386 /*LOGD("type %d, name %s", param->type, param->name);*/
388 switch (param->type) {
390 msg = muse_core_msg_json_factory_new(api,
391 param->type, param->name, param->value.value_INT,
394 case MUSE_TYPE_STRING:
395 msg = muse_core_msg_json_factory_new(api,
396 param->type, param->name, param->value.value_STRING,
400 LOGE("unknown type %d", param->type);
405 LOGE("msg failed: api %d", api);
408 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
413 /*LOGD("send msg %s", msg);*/
415 if (cb_info->is_server_connected)
416 send_ret = muse_core_ipc_send_msg(cb_info->fd, msg);
419 LOGE("msg send failed");
422 *ret = CAMERA_ERROR_INVALID_OPERATION;
425 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
428 muse_core_msg_json_factory_free(msg);
434 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
436 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
437 in_format >= MM_PIXEL_FORMAT_NUM ||
438 out_format == NULL) {
439 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
440 return CAMERA_ERROR_INVALID_PARAMETER;
444 case MM_PIXEL_FORMAT_NV12:
445 case MM_PIXEL_FORMAT_NV12T:
446 *out_format = TBM_FORMAT_NV12;
448 case MM_PIXEL_FORMAT_NV16:
449 *out_format = TBM_FORMAT_NV16;
451 case MM_PIXEL_FORMAT_NV21:
452 *out_format = TBM_FORMAT_NV21;
454 case MM_PIXEL_FORMAT_YUYV:
455 *out_format = TBM_FORMAT_YUYV;
457 case MM_PIXEL_FORMAT_UYVY:
458 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
459 *out_format = TBM_FORMAT_UYVY;
461 case MM_PIXEL_FORMAT_422P:
462 *out_format = TBM_FORMAT_YUV422;
464 case MM_PIXEL_FORMAT_I420:
465 *out_format = TBM_FORMAT_YUV420;
467 case MM_PIXEL_FORMAT_YV12:
468 *out_format = TBM_FORMAT_YVU420;
470 case MM_PIXEL_FORMAT_RGB565:
471 *out_format = TBM_FORMAT_RGB565;
473 case MM_PIXEL_FORMAT_RGB888:
474 *out_format = TBM_FORMAT_RGB888;
476 case MM_PIXEL_FORMAT_RGBA:
477 *out_format = TBM_FORMAT_RGBA8888;
479 case MM_PIXEL_FORMAT_ARGB:
480 *out_format = TBM_FORMAT_ARGB8888;
483 LOGE("invalid in_format %d", in_format);
484 return CAMERA_ERROR_INVALID_PARAMETER;
487 return CAMERA_ERROR_NONE;
491 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
493 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
494 in_format >= MM_PIXEL_FORMAT_NUM ||
496 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
497 return CAMERA_ERROR_INVALID_PARAMETER;
501 case MM_PIXEL_FORMAT_NV12:
502 case MM_PIXEL_FORMAT_NV12T:
503 *mimetype = MEDIA_FORMAT_NV12;
505 case MM_PIXEL_FORMAT_NV16:
506 *mimetype = MEDIA_FORMAT_NV16;
508 case MM_PIXEL_FORMAT_NV21:
509 *mimetype = MEDIA_FORMAT_NV21;
511 case MM_PIXEL_FORMAT_YUYV:
512 *mimetype = MEDIA_FORMAT_YUYV;
514 case MM_PIXEL_FORMAT_UYVY:
515 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
516 *mimetype = MEDIA_FORMAT_UYVY;
518 case MM_PIXEL_FORMAT_422P:
519 *mimetype = MEDIA_FORMAT_422P;
521 case MM_PIXEL_FORMAT_I420:
522 *mimetype = MEDIA_FORMAT_I420;
524 case MM_PIXEL_FORMAT_YV12:
525 *mimetype = MEDIA_FORMAT_YV12;
527 case MM_PIXEL_FORMAT_RGB565:
528 *mimetype = MEDIA_FORMAT_RGB565;
530 case MM_PIXEL_FORMAT_RGB888:
531 *mimetype = MEDIA_FORMAT_RGB888;
533 case MM_PIXEL_FORMAT_RGBA:
534 *mimetype = MEDIA_FORMAT_RGBA;
536 case MM_PIXEL_FORMAT_ARGB:
537 *mimetype = MEDIA_FORMAT_ARGB;
540 LOGE("invalid in_format %d", in_format);
541 return CAMERA_ERROR_INVALID_PARAMETER;
544 return CAMERA_ERROR_NONE;
547 void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_key,
548 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame)
551 unsigned char *buf_pos = NULL;
553 if (stream == NULL || buffer_bo_handle == NULL || frame == NULL) {
554 LOGE("invalid parameter - stream:%p, buffer_bo_handle:%p", stream, buffer_bo_handle);
559 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
560 frame->format = MM_PIXEL_FORMAT_UYVY;
562 frame->format = stream->format;
564 frame->width = stream->width;
565 frame->height = stream->height;
566 frame->timestamp = stream->timestamp;
567 frame->num_of_planes = stream->num_planes;
569 if (num_buffer_key == 0) {
571 if (!data_bo_handle || !data_bo_handle->ptr) {
572 LOGE("NULL pointer");
576 buf_pos = data_bo_handle->ptr;
578 if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) {
579 frame->data.encoded_plane.data = buf_pos;
580 frame->data.encoded_plane.size = stream->data.encoded.length_data;
581 total_size = stream->data.encoded.length_data;
583 switch (stream->num_planes) {
585 frame->data.single_plane.yuv = buf_pos;
586 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
587 total_size = stream->data.yuv420.length_yuv;
590 frame->data.double_plane.y = buf_pos;
591 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
592 buf_pos += stream->data.yuv420sp.length_y;
593 frame->data.double_plane.uv = buf_pos;
594 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
595 total_size = stream->data.yuv420sp.length_y + \
596 stream->data.yuv420sp.length_uv;
599 frame->data.triple_plane.y = buf_pos;
600 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
601 buf_pos += stream->data.yuv420p.length_y;
602 frame->data.triple_plane.u = buf_pos;
603 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
604 buf_pos += stream->data.yuv420p.length_u;
605 frame->data.triple_plane.v = buf_pos;
606 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
607 total_size = stream->data.yuv420p.length_y + \
608 stream->data.yuv420p.length_u + \
609 stream->data.yuv420p.length_v;
617 switch (stream->num_planes) {
619 frame->data.single_plane.yuv = buffer_bo_handle[0].ptr;
620 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
621 total_size = stream->data.yuv420.length_yuv;
624 frame->data.double_plane.y = buffer_bo_handle[0].ptr;
625 if (stream->num_planes == (unsigned int)num_buffer_key)
626 frame->data.double_plane.uv = buffer_bo_handle[1].ptr;
628 frame->data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
629 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
630 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
631 total_size = stream->data.yuv420sp.length_y + \
632 stream->data.yuv420sp.length_uv;
635 frame->data.triple_plane.y = buffer_bo_handle[0].ptr;
636 if (stream->num_planes == (unsigned int)num_buffer_key) {
637 frame->data.triple_plane.u = buffer_bo_handle[1].ptr;
638 frame->data.triple_plane.v = buffer_bo_handle[2].ptr;
640 frame->data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y;
641 frame->data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u;
643 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
644 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
645 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
646 total_size = stream->data.yuv420p.length_y + \
647 stream->data.yuv420p.length_u + \
648 stream->data.yuv420p.length_v;
656 LOGD("format %d, %dx%d, size %d plane num %d",
657 frame.format, frame.width, frame.height, total_size, frame.num_of_planes);
663 int _camera_media_packet_data_create(int tbm_key, int num_buffer_key, tbm_bo bo,
664 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
667 int ret = CAMERA_ERROR_NONE;
668 camera_media_packet_data *tmp_mp_data = NULL;
670 if (*mp_data == NULL) {
671 tmp_mp_data = g_new0(camera_media_packet_data, 1);
673 tmp_mp_data->tbm_key = tbm_key;
674 tmp_mp_data->num_buffer_key = num_buffer_key;
675 tmp_mp_data->bo = bo;
676 tmp_mp_data->data_bo = data_bo;
677 tmp_mp_data->ref_cnt++;
679 for (i = 0 ; i < num_buffer_key ; i++)
680 tmp_mp_data->buffer_bo[i] = buffer_bo[i];
682 *mp_data = tmp_mp_data;
683 /*LOGD("mp_data %p", tmp_mp_data);*/
685 ret = CAMERA_ERROR_OUT_OF_MEMORY;
686 LOGE("failed to alloc media packet data");
689 ((camera_media_packet_data *)*mp_data)->ref_cnt++;
695 void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
699 camera_msg_param param;
701 if (!mp_data || !cb_info) {
702 LOGE("NULL pointer %p %p", mp_data, cb_info);
706 if (mp_data->ref_cnt > 1) {
708 LOGD("ref count %d", mp_data->ref_cnt);
710 /* release imported bo */
711 for (i = 0 ; i < mp_data->num_buffer_key ; i++) {
712 tbm_bo_unref(mp_data->buffer_bo[i]);
713 mp_data->buffer_bo[i] = NULL;
717 _camera_release_imported_bo(&mp_data->bo);
718 _camera_release_imported_bo(&mp_data->data_bo);
721 tbm_key = mp_data->tbm_key;
723 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
725 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
734 int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
735 camera_media_packet_data *mp_data, media_packet_h *packet)
737 media_packet_h pkt = NULL;
738 bool make_pkt_fmt = false;
739 tbm_surface_h tsurf = NULL;
740 tbm_surface_info_s tsurf_info;
741 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
742 uint32_t bo_format = 0;
745 int num_buffer_key = 0;
746 tbm_bo *buffer_bo = NULL;
748 if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) {
749 LOGE("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p",
750 cb_info, stream, mp_data, packet);
751 return CAMERA_ERROR_INVALID_PARAMETER;
754 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
755 buffer_bo = mp_data->buffer_bo;
756 num_buffer_key = mp_data->num_buffer_key;
758 /* create tbm surface */
759 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
760 tsurf_info.planes[i].stride = stream->stride[i];
762 /* get tbm surface format */
763 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
764 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
766 if (ret == CAMERA_ERROR_NONE) {
767 tsurf_info.width = stream->width;
768 tsurf_info.height = stream->height;
769 tsurf_info.format = bo_format;
770 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
771 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
773 if (num_buffer_key > 0) {
775 case TBM_FORMAT_NV12:
776 case TBM_FORMAT_NV21:
777 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
778 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
779 tsurf_info.planes[0].offset = 0;
780 if (num_buffer_key == 1)
781 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
782 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
784 case TBM_FORMAT_YUV420:
785 case TBM_FORMAT_YVU420:
786 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
787 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
788 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
789 tsurf_info.planes[0].offset = 0;
790 if (num_buffer_key == 1) {
791 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
792 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
794 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
796 case TBM_FORMAT_UYVY:
797 case TBM_FORMAT_YUYV:
798 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
799 tsurf_info.planes[0].offset = 0;
800 tsurf_info.size = tsurf_info.planes[0].size;
806 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_key);
807 } else if (mp_data->data_bo) {
809 case TBM_FORMAT_NV12:
810 case TBM_FORMAT_NV21:
811 tsurf_info.planes[0].size = stream->width * stream->height;
812 tsurf_info.planes[1].size = (tsurf_info.planes[0].size) >> 1;
813 tsurf_info.planes[0].offset = 0;
814 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
815 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
817 case TBM_FORMAT_YUV420:
818 case TBM_FORMAT_YVU420:
819 tsurf_info.planes[0].size = stream->width * stream->height;
820 tsurf_info.planes[1].size = (stream->width >> 1) * (stream->height >> 1);
821 tsurf_info.planes[2].size = tsurf_info.planes[1].size;
822 tsurf_info.planes[0].offset = 0;
823 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
824 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
825 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
827 case TBM_FORMAT_UYVY:
828 case TBM_FORMAT_YUYV:
829 tsurf_info.planes[0].size = (stream->width * stream->height) << 1;
830 tsurf_info.planes[0].offset = 0;
831 tsurf_info.size = tsurf_info.planes[0].size;
837 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1);
839 /*LOGD("tbm surface %p", tsurf);*/
843 /* check media packet format */
844 if (cb_info->pkt_fmt) {
845 int pkt_fmt_width = 0;
846 int pkt_fmt_height = 0;
847 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
849 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
850 if (pkt_fmt_mimetype != mimetype ||
851 pkt_fmt_width != stream->width ||
852 pkt_fmt_height != stream->height) {
853 LOGW("change fmt: current 0x%x, %dx%d",
854 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
855 media_format_unref(cb_info->pkt_fmt);
856 cb_info->pkt_fmt = NULL;
863 /* create packet format */
865 LOGW("make new pkt_fmt - 0x%x, %dx%d", mimetype, stream->width, stream->height);
866 ret = media_format_create(&cb_info->pkt_fmt);
867 if (ret == MEDIA_FORMAT_ERROR_NONE) {
868 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
869 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
870 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
871 LOGW("media_format_set : 0x%x", ret);
873 LOGW("media_format_create failed 0x%x", ret);
877 /* create media packet */
878 ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt,
879 tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
880 (void *)cb_info, &pkt);
881 if (ret != MEDIA_PACKET_ERROR_NONE) {
882 LOGE("media_packet_create failed 0x%x", ret);
883 tbm_surface_destroy(tsurf);
887 LOGE("tbm surface failed. %dx%d, format %d, num_buffer_key %d, data_bo %p",
888 stream->width, stream->height, stream->format, num_buffer_key, mp_data->data_bo);
892 /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
893 /* set media packet data */
894 ret = media_packet_set_extra(pkt, (void *)mp_data);
895 if (ret != MEDIA_PACKET_ERROR_NONE) {
896 LOGE("media_packet_set_extra failed");
898 _camera_media_packet_data_release(mp_data, cb_info);
901 media_packet_destroy(pkt);
904 /* set timestamp : msec -> nsec */
905 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
906 LOGW("media_packet_set_pts failed");
915 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
918 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
919 camera_media_packet_data *mp_data = NULL;
920 tbm_surface_h tsurf = NULL;
922 if (!pkt || !cb_info) {
923 LOGE("NULL pointer %p %p", pkt, cb_info);
924 return MEDIA_PACKET_FINALIZE;
927 ret = media_packet_get_extra(pkt, (void **)&mp_data);
928 if (ret != MEDIA_PACKET_ERROR_NONE) {
929 LOGE("media_packet_get_extra failed 0x%x", ret);
930 return MEDIA_PACKET_FINALIZE;
933 /*LOGD("mp_data %p", mp_data);*/
935 g_mutex_lock(&cb_info->mp_data_mutex);
937 _camera_media_packet_data_release(mp_data, cb_info);
940 g_mutex_unlock(&cb_info->mp_data_mutex);
942 ret = media_packet_get_tbm_surface(pkt, &tsurf);
943 if (ret != MEDIA_PACKET_ERROR_NONE)
944 LOGE("get tbm_surface failed 0x%x", ret);
947 tbm_surface_destroy(tsurf);
951 return MEDIA_PACKET_FINALIZE;
954 static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event)
960 tbm_bo_handle bo_handle = {NULL, };
961 camera_msg_param param;
963 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
964 LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event);
968 /*LOGD("get camera msg %s, event %d", recv_msg, event);*/
970 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
971 if (!(CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) &&
972 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] == NULL &&
973 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] == NULL) {
974 LOGW("all preview callback from user are NULL");
977 } else if (cb_info->user_cb[event] == NULL) {
978 LOGW("user callback for event %d is not set", event);
983 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
989 muse_camera_msg_get(previous, recv_msg);
990 muse_camera_msg_get(current, recv_msg);
991 muse_camera_msg_get(by_policy, recv_msg);
993 LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
994 previous, current, by_policy);
996 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
997 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1000 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1004 muse_camera_msg_get(state, recv_msg);
1006 LOGD("FOCUS state - %d", state);
1008 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1011 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1012 LOGD("CAPTURE_COMPLETED");
1013 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1015 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1016 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1020 int num_buffer_key = 0;
1021 int buffer_key[BUFFER_MAX_PLANE_NUM] = {0, };
1023 unsigned char *buf_pos = NULL;
1025 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
1026 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
1027 tbm_bo data_bo = NULL;
1028 tbm_bo_handle data_bo_handle = {.ptr = NULL};
1030 camera_preview_data_s frame;
1031 camera_stream_data_s *stream = NULL;
1032 camera_media_packet_data *mp_data = NULL;
1033 media_packet_h pkt = NULL;
1035 muse_camera_msg_get(tbm_key, recv_msg);
1036 muse_camera_msg_get(num_buffer_key, recv_msg);
1037 muse_camera_msg_get_array(buffer_key, recv_msg);
1038 muse_camera_msg_get(data_key, recv_msg);
1040 memset(&frame, 0x0, sizeof(camera_preview_data_s));
1043 LOGE("invalid key %d", tbm_key);
1047 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1050 /* import tbm data_bo and get virtual address */
1051 if (!_camera_import_tbm_key(cb_info->bufmgr, data_key, &data_bo, &data_bo_handle)) {
1052 LOGE("failed to import data key %d", data_key);
1053 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1058 /* import tbm bo and get virtual address */
1059 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
1060 LOGE("failed to import key %d", tbm_key);
1061 _camera_release_imported_bo(&data_bo);
1062 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1066 buf_pos = (unsigned char *)bo_handle.ptr;
1068 /* get stream info */
1069 stream = (camera_stream_data_s *)buf_pos;
1071 for (i = 0 ; i < num_buffer_key ; i++) {
1072 /* import buffer bo and get virtual address */
1073 if (!_camera_import_tbm_key(cb_info->bufmgr, buffer_key[i], &buffer_bo[i], &buffer_bo_handle[i])) {
1074 LOGE("failed to import buffer key %d", buffer_key[i]);
1076 /* release imported bo */
1077 _camera_release_imported_bo(&data_bo);
1078 _camera_release_imported_bo(&bo);
1080 for (i -= 1 ; i >= 0 ; i--)
1081 _camera_release_imported_bo(&buffer_bo[i]);
1083 /* send return buffer */
1084 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1090 /* call preview callback */
1091 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
1092 _camera_preview_frame_create(stream, num_buffer_key, buffer_bo_handle, &data_bo_handle, &frame);
1094 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
1095 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
1098 /* call media packet callback */
1099 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
1100 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
1102 if (ret == CAMERA_ERROR_NONE) {
1103 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt);
1105 if (ret == CAMERA_ERROR_NONE) {
1106 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
1107 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
1109 _camera_media_packet_data_release(mp_data, cb_info);
1115 /* call evas renderer */
1116 if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
1117 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1118 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
1120 if (ret == CAMERA_ERROR_NONE) {
1121 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt);
1123 if (ret == CAMERA_ERROR_NONE) {
1124 g_mutex_lock(&cb_info->evas_mutex);
1126 if (cb_info->run_evas_render) {
1127 mm_evas_renderer_write(pkt, cb_info->evas_info);
1129 LOGW("evas renderer is stopped, skip this buffer...");
1130 media_packet_destroy(pkt);
1135 g_mutex_unlock(&cb_info->evas_mutex);
1137 _camera_media_packet_data_release(mp_data, cb_info);
1141 #else /* TIZEN_FEATURE_EVAS_RENDERER */
1142 LOGW("evas renderer is not supported");
1143 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1146 /* send message for preview callback return */
1147 if (!CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS))
1148 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info, NULL, 0);
1150 if (mp_data == NULL) {
1151 /* release imported bo */
1152 for (i = 0 ; i < num_buffer_key ; i++)
1153 _camera_release_imported_bo(&buffer_bo[i]);
1155 /* unmap and unref tbm bo */
1156 _camera_release_imported_bo(&data_bo);
1157 _camera_release_imported_bo(&bo);
1160 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1162 /*LOGD("return buffer Done");*/
1166 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1170 muse_camera_msg_get(percent, recv_msg);
1172 LOGD("HDR progress - %d \%", percent);
1174 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1177 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1183 muse_camera_msg_get(policy, recv_msg);
1184 muse_camera_msg_get(previous, recv_msg);
1185 muse_camera_msg_get(current, recv_msg);
1187 LOGW("INTERRUPTED - policy %d, state previous %d, current %d",
1188 policy, previous, current);
1190 if (policy == CAMERA_POLICY_SOUND)
1191 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND is deprecated and will be removed from next release.");
1192 else if (policy == CAMERA_POLICY_SOUND_BY_CALL)
1193 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_CALL is deprecated and will be removed from next release.");
1194 else if (policy == CAMERA_POLICY_SOUND_BY_ALARM)
1195 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_ALARM is deprecated and will be removed from next release.");
1197 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1198 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1201 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1204 camera_detected_face_s *faces = NULL;
1206 muse_camera_msg_get(count, recv_msg);
1207 muse_camera_msg_get(tbm_key, recv_msg);
1209 if (count > 0 && tbm_key > 0) {
1210 LOGD("FACE_DETECTION - count %d, tbm_key %d", count, tbm_key);
1212 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle))
1216 faces = bo_handle.ptr;
1218 ((camera_face_detected_cb)cb_info->user_cb[event])(faces, count, cb_info->user_data[event]);
1224 for (i = 0 ; i < count ; i++) {
1225 LOGD("id[%2d] - score %d, position (%d,%d,%dx%d)",
1226 i, faces[i].score, faces[i].x, faces[i].y, faces[i].width, faces[i].height);
1232 _camera_release_imported_bo(&bo);
1235 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1236 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1238 /*LOGD("return buffer done");*/
1240 LOGE("invalid message - count %d, key %d", count, tbm_key);
1244 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1247 int current_state = 0;
1249 muse_camera_msg_get(error, recv_msg);
1250 muse_camera_msg_get(current_state, recv_msg);
1252 LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
1254 if (error == CAMERA_ERROR_SOUND_POLICY)
1255 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
1256 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_CALL)
1257 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
1258 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_ALARM)
1259 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
1261 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1262 (camera_state_e)current_state, cb_info->user_data[event]);
1265 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1267 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1268 muse_camera_msg_get(param1, recv_msg);
1269 muse_camera_msg_get(param2, recv_msg);
1271 /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/
1273 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1274 cb_info->user_cb[event] = NULL;
1275 cb_info->user_data[event] = NULL;
1276 LOGW("stop foreach callback for event %d", event);
1279 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1281 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1283 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1285 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1287 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1289 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1291 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1293 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1295 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1297 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1299 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1301 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1303 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1305 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1307 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1308 muse_camera_msg_get(param1, recv_msg);
1310 /*LOGD("event %d SUPPORTED %d ", event, param1);*/
1312 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1313 cb_info->user_cb[event] = NULL;
1314 cb_info->user_data[event] = NULL;
1315 LOGW("stop foreach callback for event %d", event);
1318 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1320 camera_image_data_s *rImage = NULL;
1321 camera_image_data_s *rPostview = NULL;
1322 camera_image_data_s *rThumbnail = NULL;
1323 unsigned char *buf_pos = NULL;
1324 int tbm_key_main = 0;
1325 int tbm_key_post = 0;
1326 int tbm_key_thumb = 0;
1327 tbm_bo bo_main = NULL;
1328 tbm_bo bo_post = NULL;
1329 tbm_bo bo_thumb = NULL;
1330 tbm_bo_handle bo_main_handle = {NULL, };
1331 tbm_bo_handle bo_post_handle = {NULL, };
1332 tbm_bo_handle bo_thumb_handle = {NULL, };
1334 muse_camera_msg_get(tbm_key_main, recv_msg);
1335 muse_camera_msg_get(tbm_key_post, recv_msg);
1336 muse_camera_msg_get(tbm_key_thumb, recv_msg);
1339 LOGD("camera capture callback came in. tbm_key_main %d, tbm_key_post %d, tbm_key_thumb %d",
1340 tbm_key_main, tbm_key_post, tbm_key_thumb);
1343 if (tbm_key_main <= 0) {
1344 LOGE("invalid key %d", tbm_key_main);
1348 /* import tbm bo and get virtual address */
1349 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_main, &bo_main, &bo_main_handle))
1352 buf_pos = (unsigned char *)bo_main_handle.ptr;
1353 rImage = (camera_image_data_s *)buf_pos;
1354 rImage->data = buf_pos + sizeof(camera_image_data_s);
1356 LOGD("image info %dx%d, size : %d", rImage->width, rImage->height, rImage->size);
1358 if (tbm_key_post > 0) {
1359 /* import tbm bo and get virtual address */
1360 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_post, &bo_post, &bo_post_handle))
1363 buf_pos = (unsigned char *)bo_post_handle.ptr;
1364 rPostview = (camera_image_data_s *)buf_pos;
1365 LOGD("rPostview->size : %d", rPostview->size);
1366 rPostview->data = buf_pos + sizeof(camera_image_data_s);
1369 if (tbm_key_thumb > 0) {
1370 /* import tbm bo and get virtual address */
1371 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_thumb, &bo_thumb, &bo_thumb_handle))
1374 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
1376 rThumbnail = (camera_image_data_s *)buf_pos;
1377 LOGD("rThumbnail->size : %d", rThumbnail->size);
1378 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
1381 ((camera_capturing_cb)cb_info->user_cb[event])(rImage, rPostview, rThumbnail, cb_info->user_data[event]);
1383 /* unmap and unref tbm bo */
1384 _camera_release_imported_bo(&bo_main);
1387 tbm_key = tbm_key_main;
1389 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1391 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1393 if (tbm_key_post > 0) {
1394 /* unmap and unref tbm bo */
1395 _camera_release_imported_bo(&bo_post);
1398 param.value.value_INT = tbm_key_post;
1399 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1402 if (tbm_key_thumb > 0) {
1403 /* unmap and unref tbm bo */
1404 _camera_release_imported_bo(&bo_thumb);
1407 param.value.value_INT = tbm_key_thumb;
1408 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1411 LOGD("return buffer done");
1414 case MUSE_CAMERA_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR:
1417 LOGW("Unknown event : %d", event);
1424 static bool _camera_idle_event_callback(void *data)
1426 camera_cb_info_s *cb_info = NULL;
1427 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1429 if (cam_idle_event == NULL) {
1430 LOGE("cam_idle_event is NULL");
1435 g_mutex_lock(&cam_idle_event->event_mutex);
1437 cb_info = cam_idle_event->cb_info;
1438 if (cb_info == NULL) {
1439 LOGW("camera cb_info is NULL. event %d", cam_idle_event->event);
1440 goto IDLE_EVENT_CALLBACK_DONE;
1443 /* remove event from list */
1444 g_mutex_lock(&cb_info->idle_event_mutex);
1446 if (cb_info->idle_event_list)
1447 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1449 /*LOGD("remove camera idle event %p, %p", cam_idle_event, cb_info->idle_event_list);*/
1450 g_mutex_unlock(&cb_info->idle_event_mutex);
1453 _camera_client_user_callback(cam_idle_event->cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
1455 /* send signal for waiting thread */
1456 g_cond_signal(&cb_info->idle_event_cond);
1458 IDLE_EVENT_CALLBACK_DONE:
1459 /* unlock and release event */
1460 g_mutex_unlock(&cam_idle_event->event_mutex);
1461 g_mutex_clear(&cam_idle_event->event_mutex);
1463 g_free(cam_idle_event);
1464 cam_idle_event = NULL;
1469 static void *_camera_msg_handler_func(gpointer data)
1473 camera_message_s *cam_msg = NULL;
1474 camera_idle_event_s *cam_idle_event = NULL;
1475 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1476 camera_cb_info_s *cb_info = NULL;
1478 if (!handler_info || !handler_info->cb_info) {
1479 LOGE("t:%d NULL handler %p", type, handler_info);
1483 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1484 type = handler_info->type;
1486 LOGD("t:%d start", type);
1488 g_mutex_lock(&handler_info->mutex);
1490 while (g_atomic_int_get(&handler_info->running)) {
1491 if (g_queue_is_empty(handler_info->queue)) {
1492 /*LOGD("t:%d signal wait...", type);*/
1493 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1494 /*LOGD("t:%d signal received", type);*/
1496 if (g_atomic_int_get(&handler_info->running) == 0) {
1497 LOGD("t:%d stop event thread", type);
1502 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1504 g_mutex_unlock(&handler_info->mutex);
1506 if (cam_msg == NULL) {
1507 LOGE("t:%d NULL message", type);
1508 g_mutex_lock(&handler_info->mutex);
1514 if (api < MUSE_CAMERA_API_MAX) {
1517 g_mutex_lock(&cb_info->api_mutex[api]);
1519 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1520 cb_info->api_ret[api] = ret;
1521 cb_info->api_activating[api] = 1;
1523 /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
1525 g_cond_signal(&cb_info->api_cond[api]);
1527 LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1530 g_mutex_unlock(&cb_info->api_mutex[api]);
1531 } else if (api == MUSE_CAMERA_CB_EVENT) {
1532 switch (cam_msg->event_class) {
1533 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1534 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event);
1536 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1537 cam_idle_event = g_new0(camera_idle_event_s, 1);
1538 if (cam_idle_event == NULL) {
1539 LOGE("t:%d cam_idle_event alloc failed", type);
1543 cam_idle_event->event = cam_msg->event;
1544 cam_idle_event->cb_info = cb_info;
1545 g_mutex_init(&cam_idle_event->event_mutex);
1546 memcpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg));
1548 /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, event, cam_idle_event);*/
1550 g_mutex_lock(&cb_info->idle_event_mutex);
1551 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1552 g_mutex_unlock(&cb_info->idle_event_mutex);
1554 g_idle_add_full(G_PRIORITY_DEFAULT,
1555 (GSourceFunc)_camera_idle_event_callback,
1556 (gpointer)cam_idle_event,
1560 LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
1564 LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1570 g_mutex_lock(&handler_info->mutex);
1573 /* remove remained event */
1574 while (!g_queue_is_empty(handler_info->queue)) {
1575 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1577 LOGD("t:%d remove camera message %p", type, cam_msg);
1581 LOGW("t:%d NULL camera message", type);
1585 g_mutex_unlock(&handler_info->mutex);
1587 LOGD("t:%d return", type);
1593 static void _camera_remove_idle_event_all(camera_cb_info_s *cb_info)
1595 camera_idle_event_s *cam_idle_event = NULL;
1596 gboolean ret = TRUE;
1598 gint64 end_time = 0;
1600 if (cb_info == NULL) {
1601 LOGE("cb_info is NULL");
1605 g_mutex_lock(&cb_info->idle_event_mutex);
1607 if (cb_info->idle_event_list == NULL) {
1608 LOGD("No remained idle event");
1609 g_mutex_unlock(&cb_info->idle_event_mutex);
1613 list = cb_info->idle_event_list;
1616 cam_idle_event = list->data;
1617 list = g_list_next(list);
1619 if (!cam_idle_event) {
1620 LOGW("Fail to remove idle event. The event is NULL");
1624 if (g_mutex_trylock(&cam_idle_event->event_mutex)) {
1625 ret = g_idle_remove_by_data(cam_idle_event);
1627 LOGD("remove idle event [%p], ret[%d]", cam_idle_event, ret);
1630 cam_idle_event->cb_info = NULL;
1631 LOGW("idle event %p will be called later", cam_idle_event);
1634 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1636 g_mutex_unlock(&cam_idle_event->event_mutex);
1639 g_mutex_clear(&cam_idle_event->event_mutex);
1641 g_free(cam_idle_event);
1642 cam_idle_event = NULL;
1644 LOGD("remove idle event done");
1650 LOGW("event lock failed. it's being called...");
1652 end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
1654 if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
1655 LOGW("signal received");
1660 g_list_free(cb_info->idle_event_list);
1661 cb_info->idle_event_list = NULL;
1663 g_mutex_unlock(&cb_info->idle_event_mutex);
1669 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg)
1671 camera_message_s *cam_msg = NULL;
1673 if (!cb_info || !msg) {
1674 LOGE("NULL pointer %p %p", cb_info, msg);
1678 cam_msg = g_new0(camera_message_s, 1);
1680 LOGE("failed to alloc cam_msg for [%s]", msg);
1685 cam_msg->event = event;
1686 cam_msg->event_class = event_class;
1688 memcpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg));
1690 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1692 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1693 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1694 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1695 g_cond_signal(&cb_info->preview_cb_info.cond);
1696 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1697 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1698 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1699 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1700 g_cond_signal(&cb_info->capture_cb_info.cond);
1701 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1703 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1704 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1705 g_cond_signal(&cb_info->msg_handler_info.cond);
1706 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1715 static void *_camera_msg_recv_func(gpointer data)
1722 int event_class = 0;
1726 char *error_msg = NULL;
1727 char *recv_msg = NULL;
1728 char **parse_str = NULL;
1729 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
1732 LOGE("cb_info NULL");
1738 parse_str = (char **)malloc(sizeof(char *) * CAMERA_PARSE_STRING_SIZE);
1739 if (parse_str == NULL) {
1740 LOGE("parse_str malloc failed");
1744 for (i = 0 ; i < CAMERA_PARSE_STRING_SIZE ; i++) {
1745 parse_str[i] = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
1746 if (parse_str[i] == NULL) {
1747 LOGE("parse_str[%d] malloc failed", i);
1748 goto CB_HANDLER_EXIT;
1752 recv_msg = cb_info->recv_msg;
1754 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
1755 ret = muse_core_ipc_recv_msg(cb_info->fd, recv_msg);
1757 cb_info->is_server_connected = FALSE;
1758 LOGE("receive msg failed - server disconnected");
1762 recv_msg[ret] = '\0';
1768 /*LOGD("recvMSg : %s, length : %d", recv_msg, ret);*/
1770 /* Need to split the combined entering msgs.
1771 This module supports up to 200 combined msgs. */
1772 for (str_pos = 0; str_pos < ret; str_pos++) {
1773 if (recv_msg[str_pos] == '}') {
1774 strncpy(parse_str[num_token], recv_msg + prev_pos, str_pos - prev_pos + 1);
1775 /*LOGD("splitted msg : [%s], Index : %d", parse_str[num_token], num_token);*/
1776 prev_pos = str_pos + 1;
1781 /*LOGD("num_token : %d", num_token);*/
1783 /* Re-construct to the useful single msg. */
1784 for (i = 0; i < num_token; i++) {
1785 if (i >= CAMERA_PARSE_STRING_SIZE) {
1786 LOGE("invalid token index %d", i);
1795 if (!muse_camera_msg_get(api, parse_str[i])) {
1796 LOGE("failed to get camera api");
1800 if (api == MUSE_CAMERA_CB_EVENT) {
1801 if (!muse_camera_msg_get(event, parse_str[i]) ||
1802 !muse_camera_msg_get(event_class, parse_str[i])) {
1803 LOGE("failed to get camera event or event_class [%s]", parse_str[i]);
1807 if (!muse_camera_msg_get(api_class, parse_str[i])) {
1808 LOGE("failed to get camera api_class [%s]", parse_str[i]);
1813 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1814 if (api >= MUSE_CAMERA_API_MAX) {
1815 LOGE("invalid api %d", api);
1819 g_mutex_lock(&cb_info->api_mutex[api]);
1821 if (!muse_camera_msg_get(ret, parse_str[i])) {
1822 LOGE("failed to get camera ret");
1823 g_mutex_unlock(&cb_info->api_mutex[api]);
1827 cb_info->api_ret[api] = ret;
1828 cb_info->api_activating[api] = 1;
1830 if (api == MUSE_CAMERA_API_CREATE) {
1831 if (ret != CAMERA_ERROR_NONE) {
1832 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1833 LOGE("camera create error 0x%x. close client cb handler", ret);
1835 } else if (api == MUSE_CAMERA_API_DESTROY) {
1836 if (ret == CAMERA_ERROR_NONE) {
1837 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1838 LOGD("camera destroy done. close client cb handler");
1840 } else if (api == MUSE_CAMERA_API_GET_FLASH_STATE) {
1841 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1842 LOGD("get flash state done. close client cb handler");
1845 g_cond_signal(&cb_info->api_cond[api]);
1846 g_mutex_unlock(&cb_info->api_mutex[api]);
1847 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
1848 __camera_add_msg_to_queue(cb_info, api, event, event_class, parse_str[i]);
1850 LOGW("unknown camera api %d, class %d", api, api_class);
1856 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
1858 if (!cb_info->is_server_connected) {
1859 /* send error msg for server disconnection */
1860 error_msg = muse_core_msg_json_factory_new(MUSE_CAMERA_CB_EVENT,
1861 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
1862 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
1865 LOGE("error_msg failed");
1866 goto CB_HANDLER_EXIT;
1869 __camera_add_msg_to_queue(cb_info,
1870 MUSE_CAMERA_CB_EVENT,
1871 MUSE_CAMERA_EVENT_TYPE_ERROR,
1872 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
1875 muse_core_msg_json_factory_free(error_msg);
1878 LOGE("add error msg for service disconnection done");
1883 for (i = 0 ; i < CAMERA_PARSE_STRING_SIZE ; i++) {
1886 parse_str[i] = NULL;
1898 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
1899 int type, const char *thread_name, camera_cb_info_s *cb_info)
1901 if (!handler_info || !thread_name || !cb_info) {
1902 LOGE("t:%d NULL %p %p %p",
1903 type, handler_info, thread_name, cb_info);
1909 handler_info->type = type;
1910 handler_info->queue = g_queue_new();
1911 if (handler_info->queue == NULL) {
1912 LOGE("t:%d queue failed", type);
1916 g_mutex_init(&handler_info->mutex);
1917 g_cond_init(&handler_info->cond);
1919 handler_info->cb_info = (void *)cb_info;
1920 g_atomic_int_set(&handler_info->running, 1);
1922 handler_info->thread = g_thread_try_new(thread_name,
1923 _camera_msg_handler_func, (gpointer)handler_info, NULL);
1924 if (handler_info->thread == NULL) {
1925 LOGE("t:%d thread failed", type);
1927 g_mutex_clear(&handler_info->mutex);
1928 g_cond_clear(&handler_info->cond);
1929 g_queue_free(handler_info->queue);
1930 handler_info->queue = NULL;
1935 LOGD("t:%d done", type);
1941 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
1945 if (!handler_info) {
1946 LOGE("NULL handler");
1950 if (!handler_info->thread) {
1951 LOGW("thread is not created");
1955 type = handler_info->type;
1957 LOGD("t:%d thread %p", type, handler_info->thread);
1959 g_mutex_lock(&handler_info->mutex);
1960 g_atomic_int_set(&handler_info->running, 0);
1961 g_cond_signal(&handler_info->cond);
1962 g_mutex_unlock(&handler_info->mutex);
1964 g_thread_join(handler_info->thread);
1965 g_thread_unref(handler_info->thread);
1966 handler_info->thread = NULL;
1968 g_mutex_clear(&handler_info->mutex);
1969 g_cond_clear(&handler_info->cond);
1970 g_queue_free(handler_info->queue);
1971 handler_info->queue = NULL;
1973 LOGD("t:%d done", type);
1979 static camera_cb_info_s *_camera_client_callback_new(gint sockfd, bool need_msg_handler_thread)
1981 camera_cb_info_s *cb_info = NULL;
1984 g_return_val_if_fail(sockfd > 0, NULL);
1986 cb_info = g_new0(camera_cb_info_s, 1);
1987 if (cb_info == NULL) {
1988 LOGE("cb_info failed");
1992 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
1993 g_mutex_init(&cb_info->api_mutex[i]);
1994 g_cond_init(&cb_info->api_cond[i]);
1997 g_mutex_init(&cb_info->idle_event_mutex);
1998 g_cond_init(&cb_info->idle_event_cond);
1999 g_mutex_init(&cb_info->mp_data_mutex);
2000 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2001 g_mutex_init(&cb_info->evas_mutex);
2002 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2004 if (need_msg_handler_thread) {
2005 /* message handler thread */
2006 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2007 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2008 LOGE("msg_handler_info failed");
2012 /* message handler thread for preview callback */
2013 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2014 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2015 LOGE("preview_cb_info failed");
2019 /* message handler thread for capture callback */
2020 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2021 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2022 LOGE("capture_cb_info failed");
2027 cb_info->fd = sockfd;
2028 cb_info->preview_cb_flag = 0;
2029 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2030 cb_info->evas_info = NULL;
2031 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2033 /* message receive thread */
2034 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2035 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2036 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2037 if (cb_info->msg_recv_thread == NULL) {
2038 LOGE("message receive thread creation failed");
2042 cb_info->is_server_connected = TRUE;
2048 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2049 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2050 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2052 g_mutex_clear(&cb_info->idle_event_mutex);
2053 g_cond_clear(&cb_info->idle_event_cond);
2054 g_mutex_clear(&cb_info->mp_data_mutex);
2055 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2056 g_mutex_clear(&cb_info->evas_mutex);
2057 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2059 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2060 g_mutex_clear(&cb_info->api_mutex[i]);
2061 g_cond_clear(&cb_info->api_cond[i]);
2071 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2075 g_return_if_fail(cb_info != NULL);
2077 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2079 g_thread_join(cb_info->msg_recv_thread);
2080 g_thread_unref(cb_info->msg_recv_thread);
2081 cb_info->msg_recv_thread = NULL;
2083 LOGD("msg_recv thread removed");
2085 /* destroy msg handler threads */
2086 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2087 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2088 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2090 g_mutex_clear(&cb_info->idle_event_mutex);
2091 g_cond_clear(&cb_info->idle_event_cond);
2092 g_mutex_clear(&cb_info->mp_data_mutex);
2093 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2094 g_mutex_clear(&cb_info->evas_mutex);
2095 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2097 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2098 g_mutex_clear(&cb_info->api_mutex[i]);
2099 g_cond_clear(&cb_info->api_cond[i]);
2102 if (cb_info->fd > -1) {
2103 muse_core_connection_close(cb_info->fd);
2107 if (cb_info->bufmgr) {
2108 tbm_bufmgr_deinit(cb_info->bufmgr);
2109 cb_info->bufmgr = NULL;
2111 if (cb_info->pkt_fmt) {
2112 media_format_unref(cb_info->pkt_fmt);
2113 cb_info->pkt_fmt = NULL;
2116 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2117 if (cb_info->evas_info)
2118 mm_evas_renderer_destroy(&cb_info->evas_info);
2119 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2121 cb_info->preview_cb_flag = 0;
2130 int _camera_start_evas_rendering(camera_h camera)
2132 int ret = CAMERA_ERROR_NONE;
2133 camera_cli_s *pc = (camera_cli_s *)camera;
2135 if (!pc || !pc->cb_info) {
2136 LOGE("NULL handle");
2137 return CAMERA_ERROR_INVALID_PARAMETER;
2142 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2143 LOGE("EVAS surface is not set");
2144 return CAMERA_ERROR_NONE;
2147 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2148 g_mutex_lock(&pc->cb_info->evas_mutex);
2150 /* set evas render flag as RUN */
2151 pc->cb_info->run_evas_render = true;
2152 ret = CAMERA_ERROR_NONE;
2154 g_mutex_unlock(&pc->cb_info->evas_mutex);
2155 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2156 LOGW("evas renderer is not supported");
2157 ret = CAMERA_ERROR_NOT_SUPPORTED;
2158 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2164 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2166 int ret = CAMERA_ERROR_NONE;
2167 camera_cli_s *pc = (camera_cli_s *)camera;
2169 if (!pc || !pc->cb_info) {
2170 LOGE("NULL handle");
2171 return CAMERA_ERROR_INVALID_PARAMETER;
2174 LOGD("stop - keep screen %d", keep_screen);
2176 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2177 LOGE("EVAS surface is not set");
2178 return CAMERA_ERROR_NONE;
2181 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2182 g_mutex_lock(&pc->cb_info->evas_mutex);
2184 /* set evas render flag as STOP and release buffers */
2185 pc->cb_info->run_evas_render = false;
2187 ret = mm_evas_renderer_retrieve_all_packets(pc->cb_info->evas_info, keep_screen);
2188 if (ret != MM_ERROR_NONE) {
2189 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2190 ret = CAMERA_ERROR_INVALID_OPERATION;
2193 g_mutex_unlock(&pc->cb_info->evas_mutex);
2194 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2195 LOGW("evas renderer is not supported");
2196 ret = CAMERA_ERROR_NOT_SUPPORTED;
2197 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2203 int camera_create(camera_device_e device, camera_h *camera)
2206 char *send_msg = NULL;
2208 int ret = CAMERA_ERROR_NONE;
2210 camera_cli_s *pc = NULL;
2211 tbm_bufmgr bufmgr = NULL;
2213 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2214 muse_core_api_module_e muse_module = MUSE_CAMERA;
2215 int device_type = (int)device;
2218 LOGE("NULL pointer");
2219 return CAMERA_ERROR_INVALID_PARAMETER;
2222 sock_fd = muse_core_client_new();
2224 LOGE("muse_core_client_new failed - returned fd %d", sock_fd);
2225 ret = CAMERA_ERROR_INVALID_OPERATION;
2231 send_msg = muse_core_msg_json_factory_new(api,
2232 MUSE_TYPE_INT, "module", muse_module,
2233 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2234 MUSE_TYPE_INT, "pid", pid,
2239 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2243 send_ret = muse_core_ipc_send_msg(sock_fd, send_msg);
2245 muse_core_msg_json_factory_free(send_msg);
2249 LOGE("send msg failed %d", errno);
2250 ret = CAMERA_ERROR_INVALID_OPERATION;
2254 pc = g_new0(camera_cli_s, 1);
2256 LOGE("camera_cli_s alloc failed");
2257 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2261 bufmgr = tbm_bufmgr_init(-1);
2262 if (bufmgr == NULL) {
2263 LOGE("get tbm bufmgr failed");
2264 ret = CAMERA_ERROR_INVALID_OPERATION;
2268 pc->cb_info = _camera_client_callback_new(sock_fd, true);
2269 if (pc->cb_info == NULL) {
2270 LOGE("cb_info alloc failed");
2271 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2277 LOGD("cb info : %d", pc->cb_info->fd);
2279 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2280 if (ret == CAMERA_ERROR_NONE) {
2281 intptr_t handle = 0;
2282 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2284 LOGE("Receiving Handle Failed!!");
2285 ret = CAMERA_ERROR_INVALID_OPERATION;
2289 pc->remote_handle = handle;
2290 pc->cb_info->bufmgr = bufmgr;
2292 ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL);
2293 if (ret != CAMERA_ERROR_NONE) {
2294 LOGE("init display failed 0x%x", ret);
2298 LOGD("camera create 0x%x", pc->remote_handle);
2299 *camera = (camera_h)pc;
2308 tbm_bufmgr_deinit(bufmgr);
2313 muse_core_connection_close(sock_fd);
2319 _camera_client_callback_destroy(pc->cb_info);
2326 LOGE("camera create error : 0x%x", ret);
2332 int camera_change_device(camera_h camera, camera_device_e device)
2334 int ret = CAMERA_ERROR_NONE;
2335 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2336 camera_cli_s *pc = (camera_cli_s *)camera;
2337 camera_msg_param param;
2339 if (!pc || !pc->cb_info) {
2340 LOGE("NULL handle");
2341 return CAMERA_ERROR_INVALID_PARAMETER;
2344 CAMERA_MSG_PARAM_SET(param, INT, device);
2346 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2352 int camera_destroy(camera_h camera)
2354 int ret = CAMERA_ERROR_NONE;
2355 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2356 camera_cli_s *pc = (camera_cli_s *)camera;
2358 if (!pc || !pc->cb_info) {
2359 LOGE("NULL handle");
2360 return CAMERA_ERROR_INVALID_PARAMETER;
2365 if (pc->cb_info->is_server_connected)
2366 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2368 LOGW("server disconnected. release resource without send message.");
2370 if (ret == CAMERA_ERROR_NONE) {
2371 _camera_remove_idle_event_all(pc->cb_info);
2372 _camera_client_callback_destroy(pc->cb_info);
2382 int camera_start_preview(camera_h camera)
2384 int ret = CAMERA_ERROR_NONE;
2385 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2386 camera_cli_s *pc = (camera_cli_s *)camera;
2388 if (!pc || !pc->cb_info) {
2389 LOGE("NULL handle");
2390 return CAMERA_ERROR_INVALID_PARAMETER;
2395 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT_LONG);
2396 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2397 ret = _camera_start_evas_rendering(camera);
2398 if (ret != CAMERA_ERROR_NONE) {
2399 LOGE("stop preview because of error");
2400 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, pc->cb_info, NULL, 0);
2404 LOGD("ret : 0x%x", ret);
2410 int camera_stop_preview(camera_h camera)
2412 int ret = CAMERA_ERROR_NONE;
2413 camera_cli_s *pc = (camera_cli_s *)camera;
2414 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2415 camera_state_e current_state = CAMERA_STATE_NONE;
2417 if (!pc || !pc->cb_info) {
2418 LOGE("NULL handle");
2419 return CAMERA_ERROR_INVALID_PARAMETER;
2424 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2425 ret = camera_get_state(camera, ¤t_state);
2426 if (ret != CAMERA_ERROR_NONE) {
2427 LOGE("failed to get current state 0x%x", ret);
2431 if (current_state == CAMERA_STATE_PREVIEW) {
2432 ret = _camera_stop_evas_rendering(camera, false);
2433 if (ret != CAMERA_ERROR_NONE)
2438 /* send stop preview message */
2439 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2441 if (ret != CAMERA_ERROR_NONE &&
2442 current_state == CAMERA_STATE_PREVIEW) {
2443 LOGW("restart evas rendering");
2444 _camera_start_evas_rendering(camera);
2447 LOGD("ret : 0x%x", ret);
2453 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2455 int ret = CAMERA_ERROR_NONE;
2456 camera_cli_s *pc = (camera_cli_s *)camera;
2457 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2459 if (!pc || !pc->cb_info) {
2460 LOGE("NULL handle");
2461 return CAMERA_ERROR_INVALID_PARAMETER;
2466 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2467 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2469 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2470 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2472 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2474 LOGD("ret : 0x%x", ret);
2480 bool camera_is_supported_continuous_capture(camera_h camera)
2482 int ret = CAMERA_ERROR_NONE;
2483 camera_cli_s *pc = (camera_cli_s *)camera;
2484 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2486 if (!pc || !pc->cb_info) {
2487 LOGE("NULL handle");
2488 return CAMERA_ERROR_INVALID_PARAMETER;
2493 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2495 if (ret == CAMERA_ERROR_SERVICE_DISCONNECTED)
2498 LOGD("ret : %d", ret);
2504 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)
2506 int ret = CAMERA_ERROR_NONE;
2507 camera_cli_s *pc = (camera_cli_s *)camera;
2508 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2509 camera_msg_param param;
2512 if (!pc || !pc->cb_info) {
2513 LOGE("NULL handle");
2514 return CAMERA_ERROR_INVALID_PARAMETER;
2519 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2520 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2521 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2523 value = (count << 16) | interval;
2524 CAMERA_MSG_PARAM_SET(param, INT, value);
2526 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2528 LOGD("ret : 0x%x", ret);
2534 int camera_stop_continuous_capture(camera_h camera)
2536 int ret = CAMERA_ERROR_NONE;
2537 camera_cli_s *pc = (camera_cli_s *)camera;
2538 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2540 if (!pc || !pc->cb_info) {
2541 LOGE("NULL handle");
2542 return CAMERA_ERROR_INVALID_PARAMETER;
2547 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2549 LOGD("ret : 0x%x", ret);
2555 bool camera_is_supported_face_detection(camera_h camera)
2557 int ret = CAMERA_ERROR_NONE;
2558 camera_cli_s *pc = (camera_cli_s *)camera;
2559 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2561 if (!pc || !pc->cb_info) {
2562 LOGE("NULL handle");
2563 return CAMERA_ERROR_INVALID_PARAMETER;
2568 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2570 if (ret == CAMERA_ERROR_SERVICE_DISCONNECTED)
2573 LOGD("ret : %d", ret);
2579 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2581 int ret = CAMERA_ERROR_NONE;
2582 camera_cli_s *pc = (camera_cli_s *)camera;
2583 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2585 if (!pc || !pc->cb_info) {
2586 LOGE("NULL handle");
2587 return CAMERA_ERROR_INVALID_PARAMETER;
2592 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2594 if (ret == CAMERA_ERROR_SERVICE_DISCONNECTED)
2597 LOGD("ret : %d", ret);
2603 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2605 int ret = CAMERA_ERROR_NONE;
2606 camera_cli_s *pc = (camera_cli_s *)camera;
2607 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2609 if (!pc || !pc->cb_info) {
2610 LOGE("NULL handle");
2611 return CAMERA_ERROR_INVALID_PARAMETER;
2616 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2618 if (ret == CAMERA_ERROR_SERVICE_DISCONNECTED)
2621 LOGD("ret : %d", ret);
2626 int camera_get_device_count(camera_h camera, int *device_count)
2628 int ret = CAMERA_ERROR_NONE;
2629 camera_cli_s *pc = (camera_cli_s *)camera;
2630 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2631 int get_device_count = 0;
2633 if (!pc || !pc->cb_info) {
2634 LOGE("NULL handle");
2635 return CAMERA_ERROR_INVALID_PARAMETER;
2640 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2642 if (ret == CAMERA_ERROR_NONE) {
2643 muse_camera_msg_get(get_device_count, pc->cb_info->recv_msg);
2644 *device_count = get_device_count;
2647 LOGD("ret : 0x%x", ret);
2652 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2654 int ret = CAMERA_ERROR_NONE;
2655 camera_cli_s *pc = (camera_cli_s *)camera;
2656 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2658 if (!pc || !pc->cb_info) {
2659 LOGE("NULL handle");
2660 return CAMERA_ERROR_INVALID_PARAMETER;
2665 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2666 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2668 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2670 LOGD("ret : 0x%x", ret);
2675 int camera_stop_face_detection(camera_h camera)
2677 int ret = CAMERA_ERROR_NONE;
2678 camera_cli_s *pc = (camera_cli_s *)camera;
2679 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
2681 if (!pc || !pc->cb_info) {
2682 LOGE("NULL handle");
2683 return CAMERA_ERROR_INVALID_PARAMETER;
2688 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2690 LOGD("ret : 0x%x", ret);
2695 int camera_get_state(camera_h camera, camera_state_e *state)
2697 int ret = CAMERA_ERROR_NONE;
2698 camera_cli_s *pc = (camera_cli_s *)camera;
2699 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
2700 int get_state = CAMERA_STATE_NONE;
2702 if (!pc || !pc->cb_info || !state) {
2703 LOGE("NULL pointer %p %p", pc, state);
2704 return CAMERA_ERROR_INVALID_PARAMETER;
2709 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2711 if (ret == CAMERA_ERROR_NONE) {
2712 muse_camera_msg_get(get_state, pc->cb_info->recv_msg);
2713 *state = (camera_state_e)get_state;
2716 LOGD("ret : 0x%x", ret);
2721 int camera_start_focusing(camera_h camera, bool continuous)
2723 int ret = CAMERA_ERROR_NONE;
2724 camera_cli_s *pc = (camera_cli_s *)camera;
2725 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
2726 camera_msg_param param;
2727 int is_continuous = (int)continuous;
2729 if (!pc || !pc->cb_info) {
2730 LOGE("NULL handle");
2731 return CAMERA_ERROR_INVALID_PARAMETER;
2736 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
2738 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2740 LOGD("ret : 0x%x", ret);
2745 int camera_cancel_focusing(camera_h camera)
2747 int ret = CAMERA_ERROR_NONE;
2748 camera_cli_s *pc = (camera_cli_s *)camera;
2749 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
2751 if (!pc || !pc->cb_info) {
2752 LOGE("NULL handle");
2753 return CAMERA_ERROR_INVALID_PARAMETER;
2756 LOGD("Enter, remote_handle : %x", pc->remote_handle);
2758 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2760 LOGD("ret : 0x%x", ret);
2765 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
2767 int ret = CAMERA_ERROR_NONE;
2768 void *set_display_handle = NULL;
2769 Evas_Object *obj = NULL;
2770 const char *object_type = NULL;
2771 camera_cli_s *pc = (camera_cli_s *)camera;
2772 camera_cb_info_s *cb_info = NULL;
2773 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
2774 camera_state_e current_state = CAMERA_STATE_NONE;
2775 camera_msg_param param;
2779 if (!pc || !pc->cb_info) {
2780 LOGE("NULL handle");
2781 return CAMERA_ERROR_INVALID_PARAMETER;
2784 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
2785 LOGE("invalid type %d", type);
2786 return CAMERA_ERROR_INVALID_PARAMETER;
2789 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
2790 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
2791 return CAMERA_ERROR_INVALID_PARAMETER;
2794 cb_info = (camera_cb_info_s *)pc->cb_info;
2796 ret = camera_get_state(camera, ¤t_state);
2797 if (ret != CAMERA_ERROR_NONE) {
2798 LOGE("failed to get current state 0x%x", ret);
2802 if (current_state != CAMERA_STATE_CREATED) {
2803 LOGE("INVALID_STATE : current %d", current_state);
2804 return CAMERA_ERROR_INVALID_STATE;
2807 LOGD("Enter - display : %p", display);
2809 if (type == CAMERA_DISPLAY_TYPE_NONE) {
2810 set_display_handle = 0;
2811 LOGD("display type NONE");
2813 obj = (Evas_Object *)display;
2814 object_type = evas_object_type_get(obj);
2816 if (type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
2817 /* get wayland parent id */
2818 if (_camera_get_wl_info(obj, &pc->wl_info) != CAMERA_ERROR_NONE) {
2819 LOGE("failed to get wayland info");
2820 return CAMERA_ERROR_INVALID_OPERATION;
2823 set_display_handle = (void *)&pc->wl_info;
2824 LOGD("display type OVERLAY : handle %p", set_display_handle);
2825 } else if (type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
2826 /* evas object surface */
2827 set_display_handle = (void *)display;
2828 LOGD("display type EVAS : handle %p", set_display_handle);
2830 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2831 g_mutex_lock(&cb_info->evas_mutex);
2833 if (cb_info->evas_info) {
2834 LOGW("destroy existed evas renderer %p", cb_info->evas_info);
2835 ret = mm_evas_renderer_destroy(&cb_info->evas_info);
2836 if (ret != MM_ERROR_NONE) {
2837 LOGE("failed to destroy evas renderer %p", cb_info->evas_info);
2838 g_mutex_unlock(&cb_info->evas_mutex);
2839 return CAMERA_ERROR_INVALID_OPERATION;
2843 /* create evas renderer */
2844 ret = mm_evas_renderer_create(&cb_info->evas_info, (Evas_Object *)set_display_handle);
2845 if (ret == MM_ERROR_NONE) {
2846 camera_flip_e flip = CAMERA_FLIP_NONE;
2847 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
2848 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
2855 camera_get_display_flip(camera, &flip);
2856 camera_get_display_mode(camera, &mode);
2857 camera_get_display_rotation(camera, &rotation);
2858 camera_is_display_visible(camera, &visible);
2859 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
2861 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
2862 flip, mode, rotation, visible, x, y, width, height);
2864 ret = mm_evas_renderer_set_flip(cb_info->evas_info, flip);
2865 ret |= mm_evas_renderer_set_geometry(cb_info->evas_info, mode);
2866 ret |= mm_evas_renderer_set_rotation(cb_info->evas_info, rotation);
2867 ret |= mm_evas_renderer_set_visible(cb_info->evas_info, visible);
2869 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
2870 ret |= mm_evas_renderer_set_roi_area(cb_info->evas_info, x, y, width, height);
2873 g_mutex_unlock(&cb_info->evas_mutex);
2875 if (ret != MM_ERROR_NONE) {
2876 LOGE("mm_evas_renderer error 0x%x", ret);
2877 return CAMERA_ERROR_INVALID_OPERATION;
2879 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2880 LOGE("EVAS surface is not supported");
2881 return CAMERA_ERROR_NOT_SUPPORTED;
2882 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2884 LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type);
2885 return CAMERA_ERROR_INVALID_PARAMETER;
2888 LOGE("failed to get evas object type from %p", obj);
2889 return CAMERA_ERROR_INVALID_PARAMETER;
2893 pc->display_handle = (intptr_t)set_display_handle;
2895 if (type == CAMERA_DISPLAY_TYPE_OVERLAY) {
2898 length = sizeof(camera_wl_info_s) / sizeof(int) + \
2899 (sizeof(camera_wl_info_s) % sizeof(int) ? 1 : 0);
2901 msg = muse_core_msg_json_factory_new(api,
2902 MUSE_TYPE_INT, "type", type,
2903 MUSE_TYPE_ARRAY, "wl_info", length, (int *)&pc->wl_info,
2906 LOGE("msg creation failed: api %d", api);
2907 return CAMERA_ERROR_OUT_OF_MEMORY;
2910 if (pc->cb_info->is_server_connected)
2911 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
2914 LOGE("message send failed");
2915 ret = CAMERA_ERROR_INVALID_OPERATION;
2917 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2920 muse_core_msg_json_factory_free(msg);
2922 LOGD("wayland parent id : %d, window %d,%d,%dx%d",
2923 pc->wl_info.parent_id, pc->wl_info.window_x, pc->wl_info.window_y,
2924 pc->wl_info.window_width, pc->wl_info.window_height);
2926 CAMERA_MSG_PARAM_SET(param, INT, type);
2928 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2931 if (ret != CAMERA_ERROR_NONE)
2932 LOGE("set display error 0x%x", ret);
2933 else if (type == CAMERA_DISPLAY_TYPE_EVAS)
2934 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
2940 int camera_set_preview_resolution(camera_h camera, int width, int height)
2942 int ret = CAMERA_ERROR_NONE;
2943 camera_cli_s *pc = (camera_cli_s *)camera;
2944 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
2945 camera_msg_param param;
2948 if (!pc || !pc->cb_info) {
2949 LOGE("NULL handle");
2950 return CAMERA_ERROR_INVALID_PARAMETER;
2953 value = (width << 16) | height;
2954 CAMERA_MSG_PARAM_SET(param, INT, value);
2956 LOGD("%dx%d -> 0x%x", width, height, value);
2958 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2960 LOGD("ret : 0x%x", ret);
2966 int camera_set_capture_resolution(camera_h camera, int width, int height)
2968 int ret = CAMERA_ERROR_NONE;
2969 camera_cli_s *pc = (camera_cli_s *)camera;
2970 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
2971 camera_msg_param param;
2974 if (!pc || !pc->cb_info) {
2975 LOGE("NULL handle");
2976 return CAMERA_ERROR_INVALID_PARAMETER;
2981 value = (width << 16) | height;
2982 CAMERA_MSG_PARAM_SET(param, INT, value);
2984 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2986 LOGD("ret : 0x%x", ret);
2992 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
2994 int ret = CAMERA_ERROR_NONE;
2995 int set_format = (int)format;
2996 camera_cli_s *pc = (camera_cli_s *)camera;
2997 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
2998 camera_msg_param param;
3000 if (!pc || !pc->cb_info) {
3001 LOGE("NULL handle");
3002 return CAMERA_ERROR_INVALID_PARAMETER;
3005 LOGD("Enter - format %d", set_format);
3007 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3009 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3011 LOGD("ret : 0x%x", ret);
3017 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3019 int ret = CAMERA_ERROR_NONE;
3020 int set_format = (int)format;
3021 camera_msg_param param;
3022 camera_cli_s *pc = (camera_cli_s *)camera;
3023 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3025 if (!pc || !pc->cb_info) {
3026 LOGE("NULL handle");
3027 return CAMERA_ERROR_INVALID_PARAMETER;
3030 LOGD("Enter - capture_format %d", set_format);
3032 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3034 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3036 LOGD("ret : 0x%x", ret);
3042 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3044 int ret = CAMERA_ERROR_NONE;
3045 camera_cli_s *pc = (camera_cli_s *)camera;
3046 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3050 if (!pc || !pc->cb_info || !width || !height) {
3051 LOGE("NULL pointer %p %p %p", pc, width, height);
3052 return CAMERA_ERROR_INVALID_PARAMETER;
3057 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3059 if (ret == CAMERA_ERROR_NONE) {
3060 muse_camera_msg_get(get_width, pc->cb_info->recv_msg);
3061 muse_camera_msg_get(get_height, pc->cb_info->recv_msg);
3063 *height = get_height;
3066 LOGD("ret : 0x%x", ret);
3072 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3074 int ret = CAMERA_ERROR_NONE;
3075 int set_rotation = (int)rotation;
3076 camera_cli_s *pc = (camera_cli_s *)camera;
3077 camera_msg_param param;
3079 if (!pc || !pc->cb_info) {
3080 LOGE("NULL handle");
3081 return CAMERA_ERROR_INVALID_PARAMETER;
3084 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3085 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3086 g_mutex_lock(&pc->cb_info->evas_mutex);
3088 ret = mm_evas_renderer_set_rotation(pc->cb_info->evas_info, rotation);
3090 g_mutex_unlock(&pc->cb_info->evas_mutex);
3092 if (ret != MM_ERROR_NONE) {
3093 LOGE("failed to set rotation for evas surface 0x%x", ret);
3094 return CAMERA_ERROR_INVALID_OPERATION;
3097 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3099 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3101 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3107 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3109 int ret = CAMERA_ERROR_NONE;
3110 int get_rotation = CAMERA_ROTATION_NONE;
3111 camera_cli_s *pc = (camera_cli_s *)camera;
3113 if (!pc || !pc->cb_info || !rotation) {
3114 LOGE("NULL pointer %p %p", pc, rotation);
3115 return CAMERA_ERROR_INVALID_PARAMETER;
3118 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3120 if (ret == CAMERA_ERROR_NONE) {
3121 muse_camera_msg_get(get_rotation, pc->cb_info->recv_msg);
3122 *rotation = (camera_rotation_e)get_rotation;
3129 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3131 int ret = CAMERA_ERROR_NONE;
3132 int set_flip = (int)flip;
3133 camera_cli_s *pc = (camera_cli_s *)camera;
3134 camera_msg_param param;
3136 if (!pc || !pc->cb_info) {
3137 LOGE("NULL handle");
3138 return CAMERA_ERROR_INVALID_PARAMETER;
3141 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3142 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3143 g_mutex_lock(&pc->cb_info->evas_mutex);
3145 ret = mm_evas_renderer_set_flip(pc->cb_info->evas_info, flip);
3147 g_mutex_unlock(&pc->cb_info->evas_mutex);
3149 if (ret != MM_ERROR_NONE) {
3150 LOGE("failed to set flip for evas surface 0x%x", ret);
3151 return CAMERA_ERROR_INVALID_OPERATION;
3154 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3156 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3158 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3164 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3166 int ret = CAMERA_ERROR_NONE;
3167 int get_flip = CAMERA_FLIP_NONE;
3168 camera_cli_s *pc = (camera_cli_s *)camera;
3170 if (!pc || !pc->cb_info || !flip) {
3171 LOGE("NULL pointer %p %p", pc, flip);
3172 return CAMERA_ERROR_INVALID_PARAMETER;
3175 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3177 if (ret == CAMERA_ERROR_NONE) {
3178 muse_camera_msg_get(get_flip, pc->cb_info->recv_msg);
3179 *flip = (camera_flip_e)get_flip;
3186 int camera_set_display_visible(camera_h camera, bool visible)
3188 int ret = CAMERA_ERROR_NONE;
3189 int set_visible = (int)visible;
3190 camera_cli_s *pc = (camera_cli_s *)camera;
3191 camera_msg_param param;
3193 if (!pc || !pc->cb_info) {
3194 LOGE("NULL handle");
3195 return CAMERA_ERROR_INVALID_PARAMETER;
3198 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3199 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3200 g_mutex_lock(&pc->cb_info->evas_mutex);
3202 ret = mm_evas_renderer_set_visible(pc->cb_info->evas_info, visible);
3204 g_mutex_unlock(&pc->cb_info->evas_mutex);
3206 if (ret != MM_ERROR_NONE) {
3207 LOGE("failed to set visible for evas surface 0x%x", ret);
3208 return CAMERA_ERROR_INVALID_OPERATION;
3211 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3213 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3215 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3221 int camera_is_display_visible(camera_h camera, bool *visible)
3223 int ret = CAMERA_ERROR_NONE;
3224 int get_visible = true;
3225 camera_cli_s *pc = (camera_cli_s *)camera;
3227 if (!pc || !pc->cb_info || !visible) {
3228 LOGE("NULL pointer %p %p", pc, visible);
3229 return CAMERA_ERROR_INVALID_PARAMETER;
3232 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3234 if (ret == CAMERA_ERROR_NONE) {
3235 muse_camera_msg_get(get_visible, pc->cb_info->recv_msg);
3236 *visible = (bool)get_visible;
3243 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3245 int ret = CAMERA_ERROR_NONE;
3246 int set_mode = (int)mode;
3247 camera_cli_s *pc = (camera_cli_s *)camera;
3248 camera_msg_param param;
3250 if (!pc || !pc->cb_info) {
3251 LOGE("NULL handle");
3252 return CAMERA_ERROR_INVALID_PARAMETER;
3255 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3256 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3257 g_mutex_lock(&pc->cb_info->evas_mutex);
3259 ret = mm_evas_renderer_set_geometry(pc->cb_info->evas_info, mode);
3261 g_mutex_unlock(&pc->cb_info->evas_mutex);
3263 if (ret != MM_ERROR_NONE) {
3264 LOGE("failed to set geometry for evas surface 0x%x", ret);
3265 return CAMERA_ERROR_INVALID_OPERATION;
3268 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3270 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3272 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3278 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3280 int ret = CAMERA_ERROR_NONE;
3281 int get_mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3282 camera_cli_s *pc = (camera_cli_s *)camera;
3284 if (!pc || !pc->cb_info || !mode) {
3285 LOGE("NULL pointer %p %p", pc, mode);
3286 return CAMERA_ERROR_INVALID_PARAMETER;
3289 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3291 if (ret == CAMERA_ERROR_NONE) {
3292 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
3293 *mode = (camera_display_mode_e)get_mode;
3300 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3302 int ret = CAMERA_ERROR_NONE;
3303 int set_hint = (int)hint;
3304 camera_cli_s *pc = (camera_cli_s *)camera;
3305 camera_msg_param param;
3307 if (!pc || !pc->cb_info) {
3308 LOGE("NULL handle");
3309 return CAMERA_ERROR_INVALID_PARAMETER;
3312 LOGD("Enter - hint %d", set_hint);
3314 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3316 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3322 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3324 int ret = CAMERA_ERROR_NONE;
3326 camera_cli_s *pc = (camera_cli_s *)camera;
3327 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3329 if (!pc || !pc->cb_info || !hint) {
3330 LOGE("NULL pointer %p %p", pc, hint);
3331 return CAMERA_ERROR_INVALID_PARAMETER;
3334 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3336 if (ret == CAMERA_ERROR_NONE) {
3337 muse_camera_msg_get(get_hint, pc->cb_info->recv_msg);
3338 *hint = (bool)get_hint;
3340 LOGD("display reuse hint %d", *hint);
3347 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3349 int ret = CAMERA_ERROR_NONE;
3350 camera_cli_s *pc = (camera_cli_s *)camera;
3351 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3355 if (!pc || !pc->cb_info || !width || !height) {
3356 LOGE("NULL pointer %p %p %p", pc, width, height);
3357 return CAMERA_ERROR_INVALID_PARAMETER;
3362 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3364 if (ret == CAMERA_ERROR_NONE) {
3365 muse_camera_msg_get(get_width, pc->cb_info->recv_msg);
3366 muse_camera_msg_get(get_height, pc->cb_info->recv_msg);
3368 *height = get_height;
3371 LOGD("ret : 0x%x", ret);
3377 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3379 int ret = CAMERA_ERROR_NONE;
3380 camera_cli_s *pc = (camera_cli_s *)camera;
3381 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3384 if (!pc || !pc->cb_info || !format) {
3385 LOGE("NULL pointer %p %p", pc, format);
3386 return CAMERA_ERROR_INVALID_PARAMETER;
3391 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3393 if (ret == CAMERA_ERROR_NONE) {
3394 muse_camera_msg_get(get_format, pc->cb_info->recv_msg);
3395 *format = (camera_pixel_format_e)get_format;
3398 LOGD("ret : 0x%x", ret);
3404 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3406 int ret = CAMERA_ERROR_NONE;
3407 camera_cli_s *pc = (camera_cli_s *)camera;
3408 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3411 if (!pc || !pc->cb_info || !format) {
3412 LOGE("NULL pointer %p %p", pc, format);
3413 return CAMERA_ERROR_INVALID_PARAMETER;
3418 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3420 if (ret == CAMERA_ERROR_NONE) {
3421 muse_camera_msg_get(get_format, pc->cb_info->recv_msg);
3422 *format = (camera_pixel_format_e)get_format;
3425 LOGD("ret : 0x%x", ret);
3431 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3433 int ret = CAMERA_ERROR_NONE;
3434 camera_cli_s *pc = (camera_cli_s *)camera;
3435 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3436 int get_facing_direction = 0;
3438 if (!pc || !pc->cb_info || !facing_direction) {
3439 LOGE("NULL pointer %p %p", pc, facing_direction);
3440 return CAMERA_ERROR_INVALID_PARAMETER;
3445 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3447 if (ret == CAMERA_ERROR_NONE) {
3448 muse_camera_msg_get(get_facing_direction, pc->cb_info->recv_msg);
3449 *facing_direction = (camera_facing_direction_e)get_facing_direction;
3452 LOGD("ret : 0x%x", ret);
3458 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3460 int ret = CAMERA_ERROR_NONE;
3461 camera_cli_s *pc = (camera_cli_s *)camera;
3462 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3464 if (!pc || !pc->cb_info || !callback) {
3465 LOGE("NULL pointer %p %p", pc, callback);
3466 return CAMERA_ERROR_INVALID_PARAMETER;
3471 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3472 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3474 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3476 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3478 LOGD("ret : 0x%x", ret);
3484 int camera_unset_preview_cb(camera_h camera)
3486 int ret = CAMERA_ERROR_NONE;
3487 camera_cli_s *pc = (camera_cli_s *)camera;
3488 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3490 if (!pc || !pc->cb_info) {
3491 LOGE("NULL handle");
3492 return CAMERA_ERROR_INVALID_PARAMETER;
3497 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3498 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3500 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3502 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3504 LOGD("ret : 0x%x", ret);
3510 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3512 int ret = CAMERA_ERROR_NONE;
3513 camera_cli_s *pc = (camera_cli_s *)camera;
3514 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3516 if (!pc || !pc->cb_info) {
3517 LOGE("NULL handle");
3518 return CAMERA_ERROR_INVALID_PARAMETER;
3521 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3522 LOGE("NOT SUPPORTED");
3523 return CAMERA_ERROR_NOT_SUPPORTED;
3526 if (callback == NULL) {
3527 LOGE("NULL callback");
3528 return CAMERA_ERROR_INVALID_PARAMETER;
3533 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3534 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3536 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3538 LOGD("ret : 0x%x", ret);
3544 int camera_unset_media_packet_preview_cb(camera_h camera)
3546 int ret = CAMERA_ERROR_NONE;
3547 camera_cli_s *pc = (camera_cli_s *)camera;
3548 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3550 if (!pc || !pc->cb_info) {
3551 LOGE("NULL handle");
3552 return CAMERA_ERROR_INVALID_PARAMETER;
3557 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3558 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3560 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3562 LOGD("ret : 0x%x", ret);
3568 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3570 int ret = CAMERA_ERROR_NONE;
3571 camera_cli_s *pc = (camera_cli_s *)camera;
3572 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3574 if (!pc || !pc->cb_info || !callback) {
3575 LOGE("NULL pointer %p %p", pc, callback);
3576 return CAMERA_ERROR_INVALID_PARAMETER;
3581 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3582 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3584 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3586 LOGD("ret : 0x%x", ret);
3592 int camera_unset_state_changed_cb(camera_h camera)
3594 int ret = CAMERA_ERROR_NONE;
3595 camera_cli_s *pc = (camera_cli_s *)camera;
3596 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3598 if (!pc || !pc->cb_info) {
3599 LOGE("NULL handle");
3600 return CAMERA_ERROR_INVALID_PARAMETER;
3605 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3606 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3608 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3610 LOGD("ret : 0x%x", ret);
3616 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3618 int ret = CAMERA_ERROR_NONE;
3619 camera_cli_s *pc = (camera_cli_s *)camera;
3620 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3622 if (!pc || !pc->cb_info || !callback) {
3623 LOGE("NULL pointer %p %p", pc, callback);
3624 return CAMERA_ERROR_INVALID_PARAMETER;
3629 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3630 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3632 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3634 LOGD("ret : 0x%x", ret);
3640 int camera_unset_interrupted_cb(camera_h camera)
3642 int ret = CAMERA_ERROR_NONE;
3643 camera_cli_s *pc = (camera_cli_s *)camera;
3644 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3646 if (!pc || !pc->cb_info) {
3647 LOGE("NULL handle");
3648 return CAMERA_ERROR_INVALID_PARAMETER;
3653 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3654 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3656 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3658 LOGD("ret : 0x%x", ret);
3664 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
3666 int ret = CAMERA_ERROR_NONE;
3667 camera_cli_s *pc = (camera_cli_s *)camera;
3668 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3670 if (!pc || !pc->cb_info || !callback) {
3671 LOGE("NULL pointer %p %p", pc, callback);
3672 return CAMERA_ERROR_INVALID_PARAMETER;
3677 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3678 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3680 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3682 LOGD("ret : 0x%x", ret);
3688 int camera_unset_focus_changed_cb(camera_h camera)
3690 int ret = CAMERA_ERROR_NONE;
3691 camera_cli_s *pc = (camera_cli_s *)camera;
3692 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
3694 if (!pc || !pc->cb_info) {
3695 LOGE("NULL handle");
3696 return CAMERA_ERROR_INVALID_PARAMETER;
3701 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3702 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3704 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3706 LOGD("ret : 0x%x", ret);
3712 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
3714 int ret = CAMERA_ERROR_NONE;
3715 camera_cli_s *pc = (camera_cli_s *)camera;
3716 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
3718 if (!pc || !pc->cb_info || !callback) {
3719 LOGE("NULL pointer %p %p", pc, callback);
3720 return CAMERA_ERROR_INVALID_PARAMETER;
3725 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
3726 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
3728 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3730 LOGD("ret : 0x%x", ret);
3736 int camera_unset_error_cb(camera_h camera)
3738 int ret = CAMERA_ERROR_NONE;
3739 camera_cli_s *pc = (camera_cli_s *)camera;
3740 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
3742 if (!pc || !pc->cb_info) {
3743 LOGE("NULL handle");
3744 return CAMERA_ERROR_INVALID_PARAMETER;
3749 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
3750 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
3752 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3754 LOGD("ret : 0x%x", ret);
3760 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
3762 int ret = CAMERA_ERROR_NONE;
3763 camera_cli_s *pc = (camera_cli_s *)camera;
3764 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
3766 if (!pc || !pc->cb_info || !foreach_cb) {
3767 LOGE("NULL pointer %p %p", pc, foreach_cb);
3768 return CAMERA_ERROR_INVALID_PARAMETER;
3773 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
3774 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
3776 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3778 LOGD("ret : 0x%x", ret);
3784 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
3786 int ret = CAMERA_ERROR_NONE;
3787 camera_cli_s *pc = (camera_cli_s *)camera;
3788 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
3790 if (!pc || !pc->cb_info || !foreach_cb) {
3791 LOGE("NULL pointer %p %p", pc, foreach_cb);
3792 return CAMERA_ERROR_INVALID_PARAMETER;
3797 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
3798 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
3800 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3802 LOGD("ret : 0x%x", ret);
3808 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
3810 int ret = CAMERA_ERROR_NONE;
3811 camera_cli_s *pc = (camera_cli_s *)camera;
3812 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
3814 if (!pc || !pc->cb_info || !foreach_cb) {
3815 LOGE("NULL pointer %p %p", pc, foreach_cb);
3816 return CAMERA_ERROR_INVALID_PARAMETER;
3821 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
3822 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
3824 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3826 LOGD("ret : 0x%x", ret);
3832 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
3834 int ret = CAMERA_ERROR_NONE;
3835 camera_cli_s *pc = (camera_cli_s *)camera;
3836 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
3838 if (!pc || !pc->cb_info || !foreach_cb) {
3839 LOGE("NULL pointer %p %p", pc, foreach_cb);
3840 return CAMERA_ERROR_INVALID_PARAMETER;
3845 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
3846 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
3848 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3850 LOGD("ret : 0x%x", ret);
3856 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
3858 int ret = CAMERA_ERROR_NONE;
3859 camera_cli_s *pc = (camera_cli_s *)camera;
3860 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
3864 if (!pc || !pc->cb_info || !width || !height) {
3865 LOGE("NULL pointer %p %p %p", pc, width, height);
3866 return CAMERA_ERROR_INVALID_PARAMETER;
3870 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3872 if (ret == CAMERA_ERROR_NONE) {
3873 muse_camera_msg_get(get_width, pc->cb_info->recv_msg);
3874 muse_camera_msg_get(get_height, pc->cb_info->recv_msg);
3876 *height = get_height;
3879 LOGD("ret : 0x%x", ret);
3885 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
3887 int ret = CAMERA_ERROR_NONE;
3888 camera_cli_s *pc = (camera_cli_s *)camera;
3889 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
3892 if (!pc || !pc->cb_info || !angle) {
3893 LOGE("NULL pointer %p %p", pc, angle);
3894 return CAMERA_ERROR_INVALID_PARAMETER;
3899 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3901 if (ret == CAMERA_ERROR_NONE) {
3902 muse_camera_msg_get(get_angle, pc->cb_info->recv_msg);
3906 LOGD("ret : 0x%x", ret);
3912 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
3914 int ret = CAMERA_ERROR_NONE;
3915 camera_cli_s *pc = (camera_cli_s *)camera;
3916 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
3917 camera_msg_param param;
3918 int set_mode = (int)mode;
3920 if (!pc || !pc->cb_info) {
3921 LOGE("NULL handle");
3922 return CAMERA_ERROR_INVALID_PARAMETER;
3927 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3929 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3931 LOGD("ret : 0x%x", ret);
3937 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
3939 int ret = CAMERA_ERROR_NONE;
3940 camera_cli_s *pc = (camera_cli_s *)camera;
3941 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
3944 if (!pc || !pc->cb_info || !mode) {
3945 LOGE("NULL pointer %p %p", pc, mode);
3946 return CAMERA_ERROR_INVALID_PARAMETER;
3951 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3953 if (ret == CAMERA_ERROR_NONE) {
3954 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
3955 *mode = (camera_attr_theater_mode_e)get_mode;
3958 LOGD("ret : 0x%x", ret);
3964 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
3966 int ret = CAMERA_ERROR_NONE;
3967 camera_cli_s *pc = (camera_cli_s *)camera;
3968 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
3970 if (!pc || !pc->cb_info || !foreach_cb) {
3971 LOGE("NULL pointer %p %p", pc, foreach_cb);
3972 return CAMERA_ERROR_INVALID_PARAMETER;
3977 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
3978 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
3980 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3982 LOGD("Finish, return :%x", ret);
3988 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
3990 int ret = CAMERA_ERROR_NONE;
3991 camera_cli_s *pc = (camera_cli_s *)camera;
3992 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
3993 camera_msg_param param;
3994 int set_fps = (int)fps;
3996 if (!pc || !pc->cb_info) {
3997 LOGE("NULL handle");
3998 return CAMERA_ERROR_INVALID_PARAMETER;
4003 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4005 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4007 LOGD("ret : 0x%x", ret);
4013 int camera_attr_set_image_quality(camera_h camera, int quality)
4015 int ret = CAMERA_ERROR_NONE;
4016 camera_cli_s *pc = (camera_cli_s *)camera;
4017 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4018 camera_msg_param param;
4020 if (!pc || !pc->cb_info) {
4021 LOGE("NULL handle");
4022 return CAMERA_ERROR_INVALID_PARAMETER;
4027 CAMERA_MSG_PARAM_SET(param, INT, quality);
4029 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4031 LOGD("ret : 0x%x", ret);
4037 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4039 int ret = CAMERA_ERROR_NONE;
4040 camera_cli_s *pc = (camera_cli_s *)camera;
4041 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4044 if (!pc || !pc->cb_info || !fps) {
4045 LOGE("NULL pointer %p %p", pc, fps);
4046 return CAMERA_ERROR_INVALID_PARAMETER;
4051 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4053 if (ret == CAMERA_ERROR_NONE) {
4054 muse_camera_msg_get(get_fps, pc->cb_info->recv_msg);
4055 *fps = (camera_attr_fps_e)get_fps;
4058 LOGD("ret : 0x%x", ret);
4064 int camera_attr_get_image_quality(camera_h camera, int *quality)
4066 int ret = CAMERA_ERROR_NONE;
4067 camera_cli_s *pc = (camera_cli_s *)camera;
4068 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4069 int get_quality = 0;
4071 if (!pc || !pc->cb_info || !quality) {
4072 LOGE("NULL pointer %p %p", pc, quality);
4073 return CAMERA_ERROR_INVALID_PARAMETER;
4078 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4080 if (ret == CAMERA_ERROR_NONE) {
4081 muse_camera_msg_get(get_quality, pc->cb_info->recv_msg);
4082 *quality = get_quality;
4085 LOGD("ret : 0x%x", ret);
4091 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4093 int ret = CAMERA_ERROR_NONE;
4094 camera_cli_s *pc = (camera_cli_s *)camera;
4095 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4096 int get_bitrate = 0;
4098 if (!pc || !pc->cb_info || !bitrate) {
4099 LOGE("NULL pointer %p %p", pc, bitrate);
4100 return CAMERA_ERROR_INVALID_PARAMETER;
4105 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4107 if (ret == CAMERA_ERROR_NONE) {
4108 muse_camera_msg_get(get_bitrate, pc->cb_info->recv_msg);
4109 *bitrate = get_bitrate;
4112 LOGD("ret : 0x%x", ret);
4118 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4120 int ret = CAMERA_ERROR_NONE;
4121 camera_cli_s *pc = (camera_cli_s *)camera;
4122 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4123 camera_msg_param param;
4124 int set_bitrate = bitrate;
4126 if (!pc || !pc->cb_info) {
4127 LOGE("NULL handle");
4128 return CAMERA_ERROR_INVALID_PARAMETER;
4133 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4135 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4137 LOGD("ret : 0x%x", ret);
4143 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4145 int ret = CAMERA_ERROR_NONE;
4146 camera_cli_s *pc = (camera_cli_s *)camera;
4147 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4148 int get_gop_interval = 0;
4150 if (!pc || !pc->cb_info || !interval) {
4151 LOGE("NULL pointer %p %p", pc, interval);
4152 return CAMERA_ERROR_INVALID_PARAMETER;
4157 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4159 if (ret == CAMERA_ERROR_NONE) {
4160 muse_camera_msg_get(get_gop_interval, pc->cb_info->recv_msg);
4161 *interval = get_gop_interval;
4164 LOGD("ret : 0x%x", ret);
4170 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4172 int ret = CAMERA_ERROR_NONE;
4173 camera_cli_s *pc = (camera_cli_s *)camera;
4174 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4175 camera_msg_param param;
4176 int set_gop_interval = interval;
4178 if (!pc || !pc->cb_info) {
4179 LOGE("NULL handle");
4180 return CAMERA_ERROR_INVALID_PARAMETER;
4185 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4187 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4189 LOGD("ret : 0x%x", ret);
4195 int camera_attr_set_zoom(camera_h camera, int zoom)
4197 int ret = CAMERA_ERROR_NONE;
4198 camera_cli_s *pc = (camera_cli_s *)camera;
4199 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4200 camera_msg_param param;
4202 if (!pc || !pc->cb_info) {
4203 LOGE("NULL handle");
4204 return CAMERA_ERROR_INVALID_PARAMETER;
4207 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4209 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4211 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4213 LOGD("ret : 0x%x", ret);
4219 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4221 int ret = CAMERA_ERROR_NONE;
4222 camera_cli_s *pc = (camera_cli_s *)camera;
4223 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4224 camera_msg_param param;
4225 int set_mode = (int)mode;
4227 if (!pc || !pc->cb_info) {
4228 LOGE("NULL handle");
4229 return CAMERA_ERROR_INVALID_PARAMETER;
4232 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4234 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4236 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4242 int camera_attr_set_af_area(camera_h camera, int x, int y)
4244 int ret = CAMERA_ERROR_NONE;
4245 camera_cli_s *pc = (camera_cli_s *)camera;
4246 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4247 camera_msg_param param;
4250 if (!pc || !pc->cb_info) {
4251 LOGE("NULL handle");
4252 return CAMERA_ERROR_INVALID_PARAMETER;
4255 LOGD("Enter - %d,%d", x, y);
4257 value = (x << 16) | y;
4258 CAMERA_MSG_PARAM_SET(param, INT, value);
4260 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4262 LOGD("ret : 0x%x", ret);
4268 int camera_attr_clear_af_area(camera_h camera)
4270 int ret = CAMERA_ERROR_NONE;
4271 camera_cli_s *pc = (camera_cli_s *)camera;
4272 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4274 if (!pc || !pc->cb_info) {
4275 LOGE("NULL handle");
4276 return CAMERA_ERROR_INVALID_PARAMETER;
4281 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4283 LOGD("ret : 0x%x", ret);
4289 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4291 int ret = CAMERA_ERROR_NONE;
4292 camera_cli_s *pc = (camera_cli_s *)camera;
4293 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4294 camera_msg_param param;
4295 int set_mode = (int)mode;
4297 if (!pc || !pc->cb_info) {
4298 LOGE("NULL handle");
4299 return CAMERA_ERROR_INVALID_PARAMETER;
4304 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4306 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4308 LOGD("ret : 0x%x", ret);
4314 int camera_attr_set_exposure(camera_h camera, int value)
4316 int ret = CAMERA_ERROR_NONE;
4317 camera_cli_s *pc = (camera_cli_s *)camera;
4318 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4319 camera_msg_param param;
4321 if (!pc || !pc->cb_info) {
4322 LOGE("NULL handle");
4323 return CAMERA_ERROR_INVALID_PARAMETER;
4328 CAMERA_MSG_PARAM_SET(param, INT, value);
4330 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4332 LOGD("ret : 0x%x", ret);
4338 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4340 int ret = CAMERA_ERROR_NONE;
4341 camera_cli_s *pc = (camera_cli_s *)camera;
4342 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4343 camera_msg_param param;
4344 int set_iso = (int)iso;
4346 if (!pc || !pc->cb_info) {
4347 LOGE("NULL handle");
4348 return CAMERA_ERROR_INVALID_PARAMETER;
4353 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4355 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4357 LOGD("ret : 0x%x", ret);
4363 int camera_attr_set_brightness(camera_h camera, int level)
4365 int ret = CAMERA_ERROR_NONE;
4366 camera_cli_s *pc = (camera_cli_s *)camera;
4367 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4368 camera_msg_param param;
4370 if (!pc || !pc->cb_info) {
4371 LOGE("NULL handle");
4372 return CAMERA_ERROR_INVALID_PARAMETER;
4377 CAMERA_MSG_PARAM_SET(param, INT, level);
4379 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4381 LOGD("ret : 0x%x", ret);
4387 int camera_attr_set_contrast(camera_h camera, int level)
4389 int ret = CAMERA_ERROR_NONE;
4390 camera_cli_s *pc = (camera_cli_s *)camera;
4391 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4392 camera_msg_param param;
4394 if (!pc || !pc->cb_info) {
4395 LOGE("NULL handle");
4396 return CAMERA_ERROR_INVALID_PARAMETER;
4401 CAMERA_MSG_PARAM_SET(param, INT, level);
4403 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4405 LOGD("ret : 0x%x", ret);
4411 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4413 int ret = CAMERA_ERROR_NONE;
4414 camera_cli_s *pc = (camera_cli_s *)camera;
4415 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4416 camera_msg_param param;
4417 int set_whitebalance = (int)wb;
4419 if (!pc || !pc->cb_info) {
4420 LOGE("NULL handle");
4421 return CAMERA_ERROR_INVALID_PARAMETER;
4426 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4428 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4430 LOGD("ret : 0x%x", ret);
4436 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4438 int ret = CAMERA_ERROR_NONE;
4439 camera_cli_s *pc = (camera_cli_s *)camera;
4440 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4441 camera_msg_param param;
4442 int set_effect = (int)effect;
4444 if (!pc || !pc->cb_info) {
4445 LOGE("NULL handle");
4446 return CAMERA_ERROR_INVALID_PARAMETER;
4451 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4453 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4455 LOGD("ret : 0x%x", ret);
4461 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4463 int ret = CAMERA_ERROR_NONE;
4464 camera_cli_s *pc = (camera_cli_s *)camera;
4465 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4466 camera_msg_param param;
4467 int set_mode = (int)mode;
4469 if (!pc || !pc->cb_info) {
4470 LOGE("NULL handle");
4471 return CAMERA_ERROR_INVALID_PARAMETER;
4476 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4478 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4480 LOGD("ret : 0x%x", ret);
4486 int camera_attr_enable_tag(camera_h camera, bool enable)
4488 int ret = CAMERA_ERROR_NONE;
4489 camera_cli_s *pc = (camera_cli_s *)camera;
4490 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4491 camera_msg_param param;
4492 int set_enable = (int)enable;
4494 if (!pc || !pc->cb_info) {
4495 LOGE("NULL handle");
4496 return CAMERA_ERROR_INVALID_PARAMETER;
4501 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4503 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4505 LOGD("ret : 0x%x", ret);
4511 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4513 int ret = CAMERA_ERROR_NONE;
4514 camera_cli_s *pc = (camera_cli_s *)camera;
4515 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4516 camera_msg_param param;
4518 if (!pc || !pc->cb_info || !description) {
4519 LOGE("NULL pointer %p %p", pc, description);
4520 return CAMERA_ERROR_INVALID_PARAMETER;
4525 CAMERA_MSG_PARAM_SET(param, STRING, description);
4527 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4529 LOGD("ret : 0x%x", ret);
4535 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4537 int ret = CAMERA_ERROR_NONE;
4538 camera_cli_s *pc = (camera_cli_s *)camera;
4539 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4540 camera_msg_param param;
4541 int set_orientation = (int)orientation;
4543 if (!pc || !pc->cb_info) {
4544 LOGE("NULL handle");
4545 return CAMERA_ERROR_INVALID_PARAMETER;
4550 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4552 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4554 LOGD("ret : 0x%x", ret);
4560 int camera_attr_set_tag_software(camera_h camera, const char *software)
4562 int ret = CAMERA_ERROR_NONE;
4563 camera_cli_s *pc = (camera_cli_s *)camera;
4564 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4565 camera_msg_param param;
4567 if (!pc || !pc->cb_info || !software) {
4568 LOGE("NULL pointer %p %p", pc, software);
4569 return CAMERA_ERROR_INVALID_PARAMETER;
4572 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4574 CAMERA_MSG_PARAM_SET(param, STRING, software);
4576 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4578 LOGD("ret : 0x%x", ret);
4584 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4586 int ret = CAMERA_ERROR_NONE;
4587 camera_cli_s *pc = (camera_cli_s *)camera;
4588 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4589 double set_geotag[3] = {latitude, longitude, altitude};
4594 if (!pc || !pc->cb_info) {
4595 LOGE("NULL handle");
4596 return CAMERA_ERROR_INVALID_PARAMETER;
4601 length = sizeof(set_geotag) / sizeof(int) + \
4602 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4604 msg = muse_core_msg_json_factory_new(api,
4605 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4608 LOGE("msg creation failed: api %d", api);
4609 return CAMERA_ERROR_OUT_OF_MEMORY;
4612 if (pc->cb_info->is_server_connected)
4613 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
4616 LOGE("message send failed");
4617 ret = CAMERA_ERROR_INVALID_OPERATION;
4619 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
4622 muse_core_msg_json_factory_free(msg);
4624 LOGD("ret : 0x%x", ret);
4630 int camera_attr_remove_geotag(camera_h camera)
4632 int ret = CAMERA_ERROR_NONE;
4633 camera_cli_s *pc = (camera_cli_s *)camera;
4634 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4636 if (!pc || !pc->cb_info) {
4637 LOGE("NULL handle");
4638 return CAMERA_ERROR_INVALID_PARAMETER;
4643 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4645 LOGD("ret : 0x%x", ret);
4651 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4653 int ret = CAMERA_ERROR_NONE;
4654 camera_cli_s *pc = (camera_cli_s *)camera;
4655 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
4656 camera_msg_param param;
4657 int set_mode = (int)mode;
4659 if (!pc || !pc->cb_info) {
4660 LOGE("NULL handle");
4661 return CAMERA_ERROR_INVALID_PARAMETER;
4666 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4668 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4670 LOGD("ret : 0x%x", ret);
4676 int camera_attr_get_zoom(camera_h camera, int *zoom)
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_ZOOM;
4683 if (!pc || !pc->cb_info || !zoom) {
4684 LOGE("NULL pointer %p %p", pc, zoom);
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_zoom, pc->cb_info->recv_msg);
4697 LOGD("ret : 0x%x", ret);
4703 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
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_ZOOM_RANGE;
4711 if (!pc || !pc->cb_info || !min || !max) {
4712 LOGE("NULL pointer %p %p %p", pc, min, max);
4713 return CAMERA_ERROR_INVALID_PARAMETER;
4718 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4720 if (ret == CAMERA_ERROR_NONE) {
4721 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
4722 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
4727 LOGD("ret : 0x%x", ret);
4733 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
4735 int ret = CAMERA_ERROR_NONE;
4736 camera_cli_s *pc = (camera_cli_s *)camera;
4737 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
4740 if (!pc || !pc->cb_info || !mode) {
4741 LOGE("NULL pointer %p %p", pc, mode);
4742 return CAMERA_ERROR_INVALID_PARAMETER;
4747 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4749 if (ret == CAMERA_ERROR_NONE) {
4750 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
4751 *mode = (camera_attr_af_mode_e)get_mode;
4754 LOGD("ret : 0x%x", ret);
4760 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
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_EXPOSURE_MODE;
4767 if (!pc || !pc->cb_info || !mode) {
4768 LOGE("NULL pointer %p %p", pc, mode);
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_mode, pc->cb_info->recv_msg);
4778 *mode = (camera_attr_exposure_mode_e)get_mode;
4781 LOGD("ret : 0x%x", ret);
4787 int camera_attr_get_exposure(camera_h camera, int *value)
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_EXPOSURE;
4794 if (!pc || !pc->cb_info || !value) {
4795 LOGE("NULL pointer %p %p", pc, value);
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_value, pc->cb_info->recv_msg);
4808 LOGD("ret : 0x%x", ret);
4814 int camera_attr_get_exposure_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_EXPOSURE_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_iso(camera_h camera, camera_attr_iso_e *iso)
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_ISO;
4851 if (!pc || !pc->cb_info || !iso) {
4852 LOGE("NULL pointer %p %p", pc, iso);
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_iso, pc->cb_info->recv_msg);
4862 *iso = (camera_attr_iso_e)get_iso;
4865 LOGD("ret : 0x%x", ret);
4871 int camera_attr_get_brightness(camera_h camera, int *level)
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_BRIGHTNESS;
4878 if (!pc || !pc->cb_info || !level) {
4879 LOGE("NULL pointer %p %p", pc, level);
4880 return CAMERA_ERROR_INVALID_PARAMETER;
4885 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4887 if (ret == CAMERA_ERROR_NONE) {
4888 muse_camera_msg_get(get_level, pc->cb_info->recv_msg);
4892 LOGD("ret : 0x%x", ret);
4898 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
4900 int ret = CAMERA_ERROR_NONE;
4901 camera_cli_s *pc = (camera_cli_s *)camera;
4902 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
4906 if (!pc || !pc->cb_info || !min || !max) {
4907 LOGE("NULL pointer %p %p %p", pc, min, max);
4908 return CAMERA_ERROR_INVALID_PARAMETER;
4913 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4915 if (ret == CAMERA_ERROR_NONE) {
4916 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
4917 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
4922 LOGD("ret : 0x%x", ret);
4928 int camera_attr_get_contrast(camera_h camera, int *level)
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_CONTRAST;
4935 if (!pc || !pc->cb_info || !level) {
4936 LOGE("NULL pointer %p %p", pc, level);
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_level, pc->cb_info->recv_msg);
4949 LOGD("ret : 0x%x", ret);
4955 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
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_CONTRAST_RANGE;
4963 if (!pc || !pc->cb_info || !min || !max) {
4964 LOGE("NULL pointer %p %p %p", pc, min, max);
4965 return CAMERA_ERROR_INVALID_PARAMETER;
4970 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4972 if (ret == CAMERA_ERROR_NONE) {
4973 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
4974 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
4979 LOGD("ret : 0x%x", ret);
4985 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
4987 int ret = CAMERA_ERROR_NONE;
4988 camera_cli_s *pc = (camera_cli_s *)camera;
4989 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
4992 if (!pc || !pc->cb_info || !wb) {
4993 LOGE("NULL pointer %p %p", pc, wb);
4994 return CAMERA_ERROR_INVALID_PARAMETER;
4999 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5001 if (ret == CAMERA_ERROR_NONE) {
5002 muse_camera_msg_get(get_wb, pc->cb_info->recv_msg);
5003 *wb = (camera_attr_whitebalance_e)get_wb;
5006 LOGD("ret : 0x%x", ret);
5012 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5014 int ret = CAMERA_ERROR_NONE;
5015 camera_cli_s *pc = (camera_cli_s *)camera;
5016 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5019 if (!pc || !pc->cb_info || !effect) {
5020 LOGE("NULL pointer %p %p", pc, effect);
5021 return CAMERA_ERROR_INVALID_PARAMETER;
5026 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5028 if (ret == CAMERA_ERROR_NONE) {
5029 muse_camera_msg_get(get_effect, pc->cb_info->recv_msg);
5030 *effect = (camera_attr_effect_mode_e)get_effect;
5033 LOGD("ret : 0x%x", ret);
5039 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5041 int ret = CAMERA_ERROR_NONE;
5042 camera_cli_s *pc = (camera_cli_s *)camera;
5043 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5046 if (!pc || !pc->cb_info || !mode) {
5047 LOGE("NULL pointer %p %p", pc, mode);
5048 return CAMERA_ERROR_INVALID_PARAMETER;
5053 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5055 if (ret == CAMERA_ERROR_NONE) {
5056 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
5057 *mode = (camera_attr_scene_mode_e)get_mode;
5060 LOGD("ret : 0x%x", ret);
5066 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5068 int ret = CAMERA_ERROR_NONE;
5069 camera_cli_s *pc = (camera_cli_s *)camera;
5070 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5071 int get_enabled = 0;
5073 if (!pc || !pc->cb_info || !enable) {
5074 LOGE("NULL pointer %p %p", pc, enable);
5075 return CAMERA_ERROR_INVALID_PARAMETER;
5080 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5082 if (ret == CAMERA_ERROR_NONE) {
5083 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
5084 *enable = (bool)get_enabled;
5087 LOGD("ret : 0x%x", ret);
5093 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5095 int ret = CAMERA_ERROR_NONE;
5096 camera_cli_s *pc = (camera_cli_s *)camera;
5097 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5098 char get_description[MUSE_CAMERA_MSG_MAX_LENGTH] = {0, };
5100 if (!pc || !pc->cb_info || !description) {
5101 LOGE("NULL pointer %p %p", pc, description);
5102 return CAMERA_ERROR_INVALID_PARAMETER;
5107 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5109 if (ret == CAMERA_ERROR_NONE) {
5110 muse_camera_msg_get_string(get_description, pc->cb_info->recv_msg);
5111 *description = strdup(get_description);
5114 LOGD("ret : 0x%x", ret);
5120 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5122 int ret = CAMERA_ERROR_NONE;
5123 camera_cli_s *pc = (camera_cli_s *)camera;
5124 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5125 int get_orientation = 0;
5127 if (!pc || !pc->cb_info || !orientation) {
5128 LOGE("NULL pointer %p %p", pc, orientation);
5129 return CAMERA_ERROR_INVALID_PARAMETER;
5134 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5136 if (ret == CAMERA_ERROR_NONE) {
5137 muse_camera_msg_get(get_orientation, pc->cb_info->recv_msg);
5138 *orientation = (camera_attr_tag_orientation_e)get_orientation;
5141 LOGD("ret : 0x%x", ret);
5147 int camera_attr_get_tag_software(camera_h camera, char **software)
5149 int ret = CAMERA_ERROR_NONE;
5150 camera_cli_s *pc = (camera_cli_s *)camera;
5151 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5152 char get_software[MUSE_CAMERA_MSG_MAX_LENGTH] = {0, };
5154 if (!pc || !pc->cb_info || !software) {
5155 LOGE("NULL pointer %p %p", pc, software);
5156 return CAMERA_ERROR_INVALID_PARAMETER;
5161 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5163 if (ret == CAMERA_ERROR_NONE) {
5164 muse_camera_msg_get_string(get_software, pc->cb_info->recv_msg);
5165 *software = strdup(get_software);
5168 LOGD("ret : 0x%x", ret);
5174 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5176 int ret = CAMERA_ERROR_NONE;
5177 camera_cli_s *pc = (camera_cli_s *)camera;
5178 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5179 double get_geotag[3] = {0.0, };
5181 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5182 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5183 return CAMERA_ERROR_INVALID_PARAMETER;
5188 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5190 if (ret == CAMERA_ERROR_NONE) {
5191 muse_camera_msg_get_array(get_geotag, pc->cb_info->recv_msg);
5192 *latitude = get_geotag[0];
5193 *longitude = get_geotag[1];
5194 *altitude = get_geotag[2];
5197 LOGD("ret : 0x%x", ret);
5203 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5205 int ret = CAMERA_ERROR_NONE;
5206 camera_cli_s *pc = (camera_cli_s *)camera;
5207 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5210 if (!pc || !pc->cb_info || !mode) {
5211 LOGE("NULL pointer %p %p", pc, mode);
5212 return CAMERA_ERROR_INVALID_PARAMETER;
5217 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5219 if (ret == CAMERA_ERROR_NONE) {
5220 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
5221 *mode = (camera_attr_flash_mode_e)get_mode;
5224 LOGD("ret : 0x%x", ret);
5230 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5234 int ret = CAMERA_ERROR_NONE;
5236 camera_cli_s *pc = NULL;
5237 int get_flash_state = 0;
5239 /* create muse connection */
5240 muse_camera_api_e api = MUSE_CAMERA_API_GET_FLASH_STATE;
5241 muse_core_api_module_e muse_module = MUSE_CAMERA;
5242 int device_type = (int)device;
5245 LOGE("NULL pointer");
5246 return CAMERA_ERROR_INVALID_PARAMETER;
5249 sock_fd = muse_core_client_new();
5251 LOGE("muse_core_client_new failed");
5252 return CAMERA_ERROR_INVALID_OPERATION;
5255 msg = muse_core_msg_json_factory_new(api,
5256 MUSE_TYPE_INT, "module", muse_module,
5257 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
5261 ret = CAMERA_ERROR_OUT_OF_MEMORY;
5265 send_ret = muse_core_ipc_send_msg(sock_fd, msg);
5267 muse_core_msg_json_factory_free(msg);
5271 LOGE("send msg failed");
5272 ret = CAMERA_ERROR_INVALID_OPERATION;
5276 pc = g_new0(camera_cli_s, 1);
5278 LOGE("handle alloc failed");
5279 ret = CAMERA_ERROR_OUT_OF_MEMORY;
5283 pc->cb_info = _camera_client_callback_new(sock_fd, false);
5285 LOGE("cb_info alloc failed");
5286 ret = CAMERA_ERROR_OUT_OF_MEMORY;
5292 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
5294 if (ret == CAMERA_ERROR_NONE) {
5295 muse_camera_msg_get(get_flash_state, pc->cb_info->recv_msg);
5296 *state = (camera_flash_state_e)get_flash_state;
5299 LOGD("Flash state : %d", *state);
5302 /* release resources */
5305 _camera_client_callback_destroy(pc->cb_info);
5314 muse_core_connection_close(sock_fd);
5322 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5324 int ret = CAMERA_ERROR_NONE;
5325 camera_cli_s *pc = (camera_cli_s *)camera;
5326 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5328 if (!pc || !pc->cb_info || !foreach_cb) {
5329 LOGE("NULL pointer %p %p", pc, foreach_cb);
5330 return CAMERA_ERROR_INVALID_PARAMETER;
5335 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5336 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5338 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5340 LOGD("ret : 0x%x", ret);
5346 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5348 int ret = CAMERA_ERROR_NONE;
5349 camera_cli_s *pc = (camera_cli_s *)camera;
5350 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5352 if (!pc || !pc->cb_info || !foreach_cb) {
5353 LOGE("NULL pointer %p %p", pc, foreach_cb);
5354 return CAMERA_ERROR_INVALID_PARAMETER;
5359 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5360 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5362 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5364 LOGD("ret : 0x%x", ret);
5370 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5372 int ret = CAMERA_ERROR_NONE;
5373 camera_cli_s *pc = (camera_cli_s *)camera;
5374 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5376 if (!pc || !pc->cb_info || !foreach_cb) {
5377 LOGE("NULL pointer %p %p", pc, foreach_cb);
5378 return CAMERA_ERROR_INVALID_PARAMETER;
5383 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5384 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5386 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5388 LOGD("ret : 0x%x", ret);
5394 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5396 int ret = CAMERA_ERROR_NONE;
5397 camera_cli_s *pc = (camera_cli_s *)camera;
5398 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5400 if (!pc || !pc->cb_info || !foreach_cb) {
5401 LOGE("NULL pointer %p %p", pc, foreach_cb);
5402 return CAMERA_ERROR_INVALID_PARAMETER;
5407 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5408 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5410 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5412 LOGD("ret : 0x%x", ret);
5418 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5420 int ret = CAMERA_ERROR_NONE;
5421 camera_cli_s *pc = (camera_cli_s *)camera;
5422 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5424 if (!pc || !pc->cb_info || !foreach_cb) {
5425 LOGE("NULL pointer %p %p", pc, foreach_cb);
5426 return CAMERA_ERROR_INVALID_PARAMETER;
5431 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5432 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5434 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5436 LOGD("ret : 0x%x", ret);
5442 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5444 int ret = CAMERA_ERROR_NONE;
5445 camera_cli_s *pc = (camera_cli_s *)camera;
5446 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5448 if (!pc || !pc->cb_info || !foreach_cb) {
5449 LOGE("NULL pointer %p %p", pc, foreach_cb);
5450 return CAMERA_ERROR_INVALID_PARAMETER;
5455 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5456 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5458 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5460 LOGD("ret : 0x%x", ret);
5466 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5468 int ret = CAMERA_ERROR_NONE;
5469 camera_cli_s *pc = (camera_cli_s *)camera;
5470 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5472 if (!pc || !pc->cb_info || !foreach_cb) {
5473 LOGE("NULL pointer %p %p", pc, foreach_cb);
5474 return CAMERA_ERROR_INVALID_PARAMETER;
5479 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5480 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5482 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5484 LOGD("ret : 0x%x", ret);
5490 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5492 int ret = CAMERA_ERROR_NONE;
5493 camera_cli_s *pc = (camera_cli_s *)camera;
5494 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5496 if (!pc || !pc->cb_info || !foreach_cb) {
5497 LOGE("NULL pointer %p %p", pc, foreach_cb);
5498 return CAMERA_ERROR_INVALID_PARAMETER;
5503 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5504 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5506 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5508 LOGD("Enter, handle :%x", pc->remote_handle);
5514 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)
5516 int ret = CAMERA_ERROR_NONE;
5517 camera_cli_s *pc = (camera_cli_s *)camera;
5518 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5519 camera_msg_param param;
5522 if (!pc || !pc->cb_info || !foreach_cb) {
5523 LOGE("NULL pointer %p %p", pc, foreach_cb);
5524 return CAMERA_ERROR_INVALID_PARAMETER;
5529 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5530 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5532 value = (width << 16) | height;
5533 CAMERA_MSG_PARAM_SET(param, INT, value);
5535 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5537 LOGD("ret : 0x%x", ret);
5543 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5545 int ret = CAMERA_ERROR_NONE;
5546 camera_cli_s *pc = (camera_cli_s *)camera;
5547 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5549 if (!pc || !pc->cb_info || !foreach_cb) {
5550 LOGE("NULL pointer %p %p", pc, foreach_cb);
5551 return CAMERA_ERROR_INVALID_PARAMETER;
5556 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5557 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5559 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5561 LOGD("ret : 0x%x", ret);
5567 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5569 int ret = CAMERA_ERROR_NONE;
5570 camera_cli_s *pc = (camera_cli_s *)camera;
5571 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5573 if (!pc || !pc->cb_info || !foreach_cb) {
5574 LOGE("NULL pointer %p %p", pc, foreach_cb);
5575 return CAMERA_ERROR_INVALID_PARAMETER;
5580 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5581 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5583 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5585 LOGD("ret : 0x%x", ret);
5591 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5593 int ret = CAMERA_ERROR_NONE;
5594 camera_cli_s *pc = (camera_cli_s *)camera;
5595 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5596 camera_msg_param param;
5597 int set_rotation = (int)rotation;
5599 if (!pc || !pc->cb_info) {
5600 LOGE("NULL handle");
5601 return CAMERA_ERROR_INVALID_PARAMETER;
5606 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5608 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5610 LOGD("ret : 0x%x", ret);
5616 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5618 int ret = CAMERA_ERROR_NONE;
5619 camera_cli_s *pc = (camera_cli_s *)camera;
5620 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5621 int get_rotation = 0;
5623 if (!pc || !pc->cb_info || !rotation) {
5624 LOGE("NULL pointer %p %p", pc, rotation);
5625 return CAMERA_ERROR_INVALID_PARAMETER;
5630 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5632 if (ret == CAMERA_ERROR_NONE) {
5633 muse_camera_msg_get(get_rotation, pc->cb_info->recv_msg);
5634 *rotation = (camera_rotation_e)get_rotation;
5637 LOGD("ret : 0x%x", ret);
5643 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5645 int ret = CAMERA_ERROR_NONE;
5646 camera_cli_s *pc = (camera_cli_s *)camera;
5647 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5648 camera_msg_param param;
5649 int set_flip = (int)flip;
5651 if (!pc || !pc->cb_info) {
5652 LOGE("NULL handle");
5653 return CAMERA_ERROR_INVALID_PARAMETER;
5658 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5660 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5662 LOGD("ret : 0x%x", ret);
5668 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5670 int ret = CAMERA_ERROR_NONE;
5671 camera_cli_s *pc = (camera_cli_s *)camera;
5672 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5675 if (!pc || !pc->cb_info || !flip) {
5676 LOGE("NULL pointer %p %p", pc, flip);
5677 return CAMERA_ERROR_INVALID_PARAMETER;
5682 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5684 if (ret == CAMERA_ERROR_NONE) {
5685 muse_camera_msg_get(get_flip, pc->cb_info->recv_msg);
5686 *flip = (camera_flip_e)get_flip;
5689 LOGD("ret : 0x%x", ret);
5694 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5696 int ret = CAMERA_ERROR_NONE;
5697 camera_cli_s *pc = (camera_cli_s *)camera;
5698 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5699 camera_msg_param param;
5700 int set_mode = (int)mode;
5702 if (!pc || !pc->cb_info) {
5703 LOGE("NULL handle");
5704 return CAMERA_ERROR_INVALID_PARAMETER;
5709 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5711 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5713 LOGD("ret : 0x%x", ret);
5719 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5721 int ret = CAMERA_ERROR_NONE;
5722 camera_cli_s *pc = (camera_cli_s *)camera;
5723 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5726 if (!pc || !pc->cb_info || !mode) {
5727 LOGE("NULL pointer %p %p", pc, mode);
5728 return CAMERA_ERROR_INVALID_PARAMETER;
5733 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5735 if (ret == CAMERA_ERROR_NONE) {
5736 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
5737 *mode = (camera_attr_hdr_mode_e)get_mode;
5740 LOGD("ret : 0x%x", ret);
5746 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5748 int ret = CAMERA_ERROR_NONE;
5749 camera_cli_s *pc = (camera_cli_s *)camera;
5750 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
5752 if (!pc || !pc->cb_info) {
5753 LOGE("NULL handle");
5754 return CAMERA_ERROR_INVALID_PARAMETER;
5759 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5761 if (ret == CAMERA_ERROR_SERVICE_DISCONNECTED)
5764 LOGD("ret : %d", ret);
5770 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5772 int ret = CAMERA_ERROR_NONE;
5773 camera_cli_s *pc = (camera_cli_s *)camera;
5774 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5776 if (!pc || !pc->cb_info) {
5777 LOGE("NULL handle");
5778 return CAMERA_ERROR_INVALID_PARAMETER;
5783 if (!camera_attr_is_supported_hdr_capture(camera)) {
5784 LOGE("HDR not supported");
5785 return CAMERA_ERROR_NOT_SUPPORTED;
5789 LOGE("NULL callback");
5790 return CAMERA_ERROR_INVALID_PARAMETER;
5793 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5794 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5796 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5798 LOGD("ret : 0x%x", ret);
5804 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5806 int ret = CAMERA_ERROR_NONE;
5807 camera_cli_s *pc = (camera_cli_s *)camera;
5808 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5810 if (!pc || !pc->cb_info) {
5811 LOGE("NULL handle");
5812 return CAMERA_ERROR_INVALID_PARAMETER;
5817 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5818 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5820 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5822 LOGD("ret : 0x%x", ret);
5828 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
5830 int ret = CAMERA_ERROR_NONE;
5831 camera_cli_s *pc = (camera_cli_s *)camera;
5832 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
5833 camera_msg_param param;
5834 int set_enable = (int)enable;
5836 if (!pc || !pc->cb_info) {
5837 LOGE("NULL handle");
5838 return CAMERA_ERROR_INVALID_PARAMETER;
5843 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
5845 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5847 LOGD("ret : 0x%x", ret);
5853 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
5855 int ret = CAMERA_ERROR_NONE;
5856 camera_cli_s *pc = (camera_cli_s *)camera;
5857 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
5858 int get_enabled = 0;
5860 if (!pc || !pc->cb_info || !enabled) {
5861 LOGE("NULL pointer %p %p", pc, enabled);
5862 return CAMERA_ERROR_INVALID_PARAMETER;
5867 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5869 if (ret == CAMERA_ERROR_NONE) {
5870 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
5871 *enabled = (bool)get_enabled;
5874 LOGD("ret : 0x%x", ret);
5880 bool camera_attr_is_supported_anti_shake(camera_h camera)
5882 int ret = CAMERA_ERROR_NONE;
5883 camera_cli_s *pc = (camera_cli_s *)camera;
5884 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
5886 if (!pc || !pc->cb_info) {
5887 LOGE("NULL handle");
5888 return CAMERA_ERROR_INVALID_PARAMETER;
5893 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5895 if (ret == CAMERA_ERROR_SERVICE_DISCONNECTED)
5898 LOGD("ret : %d", ret);
5904 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
5906 int ret = CAMERA_ERROR_NONE;
5907 camera_cli_s *pc = (camera_cli_s *)camera;
5908 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
5909 camera_msg_param param;
5910 int set_enable = (int)enable;
5912 if (!pc || !pc->cb_info) {
5913 LOGE("NULL handle");
5914 return CAMERA_ERROR_INVALID_PARAMETER;
5919 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
5921 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5923 LOGD("ret : 0x%x", ret);
5929 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
5931 int ret = CAMERA_ERROR_NONE;
5932 camera_cli_s *pc = (camera_cli_s *)camera;
5933 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
5934 int get_enabled = 0;
5936 if (!pc || !pc->cb_info || !enabled) {
5937 LOGE("NULL pointer %p %p", pc, enabled);
5938 return CAMERA_ERROR_INVALID_PARAMETER;
5943 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5945 if (ret == CAMERA_ERROR_NONE) {
5946 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
5947 *enabled = (bool)get_enabled;
5950 LOGD("ret : 0x%x", ret);
5956 bool camera_attr_is_supported_video_stabilization(camera_h camera)
5958 int ret = CAMERA_ERROR_NONE;
5959 camera_cli_s *pc = (camera_cli_s *)camera;
5960 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
5962 if (!pc || !pc->cb_info) {
5963 LOGE("NULL handle");
5964 return CAMERA_ERROR_INVALID_PARAMETER;
5969 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5971 if (ret == CAMERA_ERROR_SERVICE_DISCONNECTED)
5974 LOGD("ret : %d", ret);
5980 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
5982 int ret = CAMERA_ERROR_NONE;
5983 camera_cli_s *pc = (camera_cli_s *)camera;
5984 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
5985 camera_msg_param param;
5986 int set_enable = (int)enable;
5988 if (!pc || !pc->cb_info) {
5989 LOGE("NULL handle");
5990 return CAMERA_ERROR_INVALID_PARAMETER;
5995 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
5997 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5999 LOGD("ret : 0x%x", ret);
6005 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6007 int ret = CAMERA_ERROR_NONE;
6008 camera_cli_s *pc = (camera_cli_s *)camera;
6009 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6010 int get_enabled = 0;
6012 if (!pc || !pc->cb_info || !enabled) {
6013 LOGE("NULL pointer %p %p", pc, enabled);
6014 return CAMERA_ERROR_INVALID_PARAMETER;
6019 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6021 if (ret == CAMERA_ERROR_NONE) {
6022 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
6023 *enabled = (bool)get_enabled;
6026 LOGD("ret : 0x%x", ret);
6032 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6034 int ret = CAMERA_ERROR_NONE;
6035 camera_cli_s *pc = (camera_cli_s *)camera;
6036 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6038 if (!pc || !pc->cb_info) {
6039 LOGE("NULL handle");
6040 return CAMERA_ERROR_INVALID_PARAMETER;
6045 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6047 if (ret == CAMERA_ERROR_SERVICE_DISCONNECTED)
6050 LOGD("ret : %d", ret);
6056 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6058 int ret = CAMERA_ERROR_NONE;
6059 camera_cli_s *pc = (camera_cli_s *)camera;
6060 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6061 camera_msg_param param;
6062 int set_disable = (int)disable;
6064 if (!pc || !pc->cb_info) {
6065 LOGE("NULL handle");
6066 return CAMERA_ERROR_INVALID_PARAMETER;
6071 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6073 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6075 LOGD("ret : 0x%x", ret);
6081 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6083 int ret = CAMERA_ERROR_NONE;
6084 camera_cli_s *pc = (camera_cli_s *)camera;
6085 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6086 camera_msg_param param;
6087 int set_move_type = (int)move_type;
6090 if (!pc || !pc->cb_info) {
6091 LOGE("NULL handle");
6092 return CAMERA_ERROR_INVALID_PARAMETER;
6097 value = (set_move_type << 16) | pan_step;
6098 CAMERA_MSG_PARAM_SET(param, INT, value);
6100 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6102 LOGD("ret : 0x%x", ret);
6108 int camera_attr_get_pan(camera_h camera, int *pan_step)
6110 int ret = CAMERA_ERROR_NONE;
6111 camera_cli_s *pc = (camera_cli_s *)camera;
6112 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6113 int get_pan_step = 0;
6115 if (!pc || !pc->cb_info || !pan_step) {
6116 LOGE("NULL pointer %p %p", pc, pan_step);
6117 return CAMERA_ERROR_INVALID_PARAMETER;
6122 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6124 if (ret == CAMERA_ERROR_NONE) {
6125 muse_camera_msg_get(get_pan_step, pc->cb_info->recv_msg);
6126 *pan_step = get_pan_step;
6129 LOGD("ret : 0x%x", ret);
6135 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6137 int ret = CAMERA_ERROR_NONE;
6138 camera_cli_s *pc = (camera_cli_s *)camera;
6139 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6143 if (!pc || !pc->cb_info || !min || !max) {
6144 LOGE("NULL pointer %p %p", pc, min, max);
6145 return CAMERA_ERROR_INVALID_PARAMETER;
6150 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6152 if (ret == CAMERA_ERROR_NONE) {
6153 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
6154 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
6159 LOGD("ret : 0x%x", ret);
6165 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6167 int ret = CAMERA_ERROR_NONE;
6168 camera_cli_s *pc = (camera_cli_s *)camera;
6169 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6170 camera_msg_param param;
6171 int set_move_type = (int)move_type;
6174 if (!pc || !pc->cb_info) {
6175 LOGE("NULL handle");
6176 return CAMERA_ERROR_INVALID_PARAMETER;
6181 value = (set_move_type << 16) | tilt_step;
6182 CAMERA_MSG_PARAM_SET(param, INT, value);
6184 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6186 LOGD("ret : 0x%x", ret);
6192 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6194 int ret = CAMERA_ERROR_NONE;
6195 camera_cli_s *pc = (camera_cli_s *)camera;
6196 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6197 int get_tilt_step = 0;
6199 if (!pc || !pc->cb_info || !tilt_step) {
6200 LOGE("NULL pointer %p %p", pc, tilt_step);
6201 return CAMERA_ERROR_INVALID_PARAMETER;
6206 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6208 if (ret == CAMERA_ERROR_NONE) {
6209 muse_camera_msg_get(get_tilt_step, pc->cb_info->recv_msg);
6210 *tilt_step = get_tilt_step;
6213 LOGD("ret : 0x%x", ret);
6219 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6221 int ret = CAMERA_ERROR_NONE;
6222 camera_cli_s *pc = (camera_cli_s *)camera;
6223 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6227 if (!pc || !pc->cb_info || !min || !max) {
6228 LOGE("NULL pointer %p %p %p", pc, min, max);
6229 return CAMERA_ERROR_INVALID_PARAMETER;
6234 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6236 if (ret == CAMERA_ERROR_NONE) {
6237 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
6238 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
6243 LOGD("ret : 0x%x", ret);
6249 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6251 int ret = CAMERA_ERROR_NONE;
6252 camera_cli_s *pc = (camera_cli_s *)camera;
6253 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6254 camera_msg_param param;
6255 int set_ptz_type = (int)ptz_type;
6257 if (!pc || !pc->cb_info) {
6258 LOGE("NULL handle");
6259 return CAMERA_ERROR_INVALID_PARAMETER;
6264 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6266 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6268 LOGD("ret : 0x%x", ret);
6274 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6276 int ret = CAMERA_ERROR_NONE;
6277 camera_cli_s *pc = (camera_cli_s *)camera;
6278 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6280 if (!pc || !pc->cb_info || !foreach_cb) {
6281 LOGE("NULL pointer %p %p", pc, foreach_cb);
6282 return CAMERA_ERROR_INVALID_PARAMETER;
6287 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6288 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6290 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6292 LOGD("ret : 0x%x", ret);
6298 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6300 int ret = CAMERA_ERROR_NONE;
6301 camera_cli_s *pc = (camera_cli_s *)camera;
6302 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6303 int set_display_roi_area[4] = {x, y, width, height};
6308 if (!pc || !pc->cb_info) {
6309 LOGE("NULL handle");
6310 return CAMERA_ERROR_INVALID_PARAMETER;
6315 #ifdef TIZEN_FEATURE_EVAS_RENDERER
6316 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6317 g_mutex_lock(&pc->cb_info->evas_mutex);
6319 ret = mm_evas_renderer_set_roi_area(pc->cb_info->evas_info, x, y, width, height);
6321 g_mutex_unlock(&pc->cb_info->evas_mutex);
6323 if (ret != MM_ERROR_NONE) {
6324 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6325 return CAMERA_ERROR_INVALID_OPERATION;
6328 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
6330 length = sizeof(set_display_roi_area) / sizeof(int) + \
6331 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6333 msg = muse_core_msg_json_factory_new(api,
6334 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6337 LOGE("msg creation failed: api %d", api);
6338 return CAMERA_ERROR_OUT_OF_MEMORY;
6341 if (pc->cb_info->is_server_connected)
6342 send_ret = muse_core_ipc_send_msg(pc->cb_info->fd, msg);
6345 LOGE("message send failed");
6346 ret = CAMERA_ERROR_INVALID_OPERATION;
6348 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6351 muse_core_msg_json_factory_free(msg);
6353 LOGD("ret : 0x%x", ret);
6359 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6361 camera_cli_s *pc = (camera_cli_s *)camera;
6362 int ret = CAMERA_ERROR_NONE;
6363 int get_display_roi_area[4] = {0,};
6364 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6366 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6367 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6368 return CAMERA_ERROR_INVALID_PARAMETER;
6373 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6375 if (ret == CAMERA_ERROR_NONE) {
6376 muse_camera_msg_get_array(get_display_roi_area, pc->cb_info->recv_msg);
6377 *x = get_display_roi_area[0];
6378 *y = get_display_roi_area[1];
6379 *width = get_display_roi_area[2];
6380 *height = get_display_roi_area[3];
6383 LOGD("ret : 0x%x", ret);