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 _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);
229 static int _import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle)
231 tbm_bo tmp_bo = NULL;
232 tbm_bo_handle tmp_bo_handle = {NULL, };
234 if (bufmgr == NULL || bo == NULL || bo_handle == NULL || tbm_key == 0) {
235 LOGE("invalid parameter - bufmgr %p, bo %p, bo_handle %p, key %d",
236 bufmgr, bo, bo_handle, tbm_key);
240 tmp_bo = tbm_bo_import(bufmgr, tbm_key);
241 if (tmp_bo == NULL) {
242 LOGE("bo import failed - bufmgr %p, key %d", bufmgr, tbm_key);
246 tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
247 if (tmp_bo_handle.ptr == NULL) {
248 LOGE("bo map failed %p", tmp_bo);
249 tbm_bo_unref(tmp_bo);
254 tbm_bo_unmap(tmp_bo);
256 /* set bo and bo_handle */
258 *bo_handle = tmp_bo_handle;
263 static void _release_imported_bo(tbm_bo *bo)
265 if (bo == NULL || *bo == NULL) {
276 static int _client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
278 int ret = CAMERA_ERROR_NONE;
281 /*LOGD("Enter api : %d", api);*/
283 g_mutex_lock(&(cb_info->api_mutex[api]));
285 if (cb_info->api_activating[api] == 0) {
286 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
287 if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
288 ret = cb_info->api_ret[api];
289 cb_info->api_activating[api] = 0;
291 /*LOGD("return value : 0x%x", ret);*/
293 ret = CAMERA_ERROR_INVALID_OPERATION;
295 LOGE("api %d was TIMED OUT!", api);
298 ret = cb_info->api_ret[api];
299 cb_info->api_activating[api] = 0;
301 /*LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);*/
304 g_mutex_unlock(&(cb_info->api_mutex[api]));
309 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
311 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
312 in_format >= MM_PIXEL_FORMAT_NUM ||
313 out_format == NULL) {
314 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
315 return CAMERA_ERROR_INVALID_PARAMETER;
319 case MM_PIXEL_FORMAT_NV12:
320 case MM_PIXEL_FORMAT_NV12T:
321 *out_format = TBM_FORMAT_NV12;
323 case MM_PIXEL_FORMAT_NV16:
324 *out_format = TBM_FORMAT_NV16;
326 case MM_PIXEL_FORMAT_NV21:
327 *out_format = TBM_FORMAT_NV21;
329 case MM_PIXEL_FORMAT_YUYV:
330 *out_format = TBM_FORMAT_YUYV;
332 case MM_PIXEL_FORMAT_UYVY:
333 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
334 *out_format = TBM_FORMAT_UYVY;
336 case MM_PIXEL_FORMAT_422P:
337 *out_format = TBM_FORMAT_YUV422;
339 case MM_PIXEL_FORMAT_I420:
340 *out_format = TBM_FORMAT_YUV420;
342 case MM_PIXEL_FORMAT_YV12:
343 *out_format = TBM_FORMAT_YVU420;
345 case MM_PIXEL_FORMAT_RGB565:
346 *out_format = TBM_FORMAT_RGB565;
348 case MM_PIXEL_FORMAT_RGB888:
349 *out_format = TBM_FORMAT_RGB888;
351 case MM_PIXEL_FORMAT_RGBA:
352 *out_format = TBM_FORMAT_RGBA8888;
354 case MM_PIXEL_FORMAT_ARGB:
355 *out_format = TBM_FORMAT_ARGB8888;
358 LOGE("invalid in_format %d", in_format);
359 return CAMERA_ERROR_INVALID_PARAMETER;
362 return CAMERA_ERROR_NONE;
366 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
368 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
369 in_format >= MM_PIXEL_FORMAT_NUM ||
371 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
372 return CAMERA_ERROR_INVALID_PARAMETER;
376 case MM_PIXEL_FORMAT_NV12:
377 case MM_PIXEL_FORMAT_NV12T:
378 *mimetype = MEDIA_FORMAT_NV12;
380 case MM_PIXEL_FORMAT_NV16:
381 *mimetype = MEDIA_FORMAT_NV16;
383 case MM_PIXEL_FORMAT_NV21:
384 *mimetype = MEDIA_FORMAT_NV21;
386 case MM_PIXEL_FORMAT_YUYV:
387 *mimetype = MEDIA_FORMAT_YUYV;
389 case MM_PIXEL_FORMAT_UYVY:
390 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
391 *mimetype = MEDIA_FORMAT_UYVY;
393 case MM_PIXEL_FORMAT_422P:
394 *mimetype = MEDIA_FORMAT_422P;
396 case MM_PIXEL_FORMAT_I420:
397 *mimetype = MEDIA_FORMAT_I420;
399 case MM_PIXEL_FORMAT_YV12:
400 *mimetype = MEDIA_FORMAT_YV12;
402 case MM_PIXEL_FORMAT_RGB565:
403 *mimetype = MEDIA_FORMAT_RGB565;
405 case MM_PIXEL_FORMAT_RGB888:
406 *mimetype = MEDIA_FORMAT_RGB888;
408 case MM_PIXEL_FORMAT_RGBA:
409 *mimetype = MEDIA_FORMAT_RGBA;
411 case MM_PIXEL_FORMAT_ARGB:
412 *mimetype = MEDIA_FORMAT_ARGB;
415 LOGE("invalid in_format %d", in_format);
416 return CAMERA_ERROR_INVALID_PARAMETER;
419 return CAMERA_ERROR_NONE;
422 void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_key,
423 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame)
426 unsigned char *buf_pos = NULL;
428 if (stream == NULL || buffer_bo_handle == NULL || frame == NULL) {
429 LOGE("invalid parameter - stream:%p, buffer_bo_handle:%p", stream, buffer_bo_handle);
434 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
435 frame->format = MM_PIXEL_FORMAT_UYVY;
437 frame->format = stream->format;
439 frame->width = stream->width;
440 frame->height = stream->height;
441 frame->timestamp = stream->timestamp;
442 frame->num_of_planes = stream->num_planes;
444 if (num_buffer_key == 0) {
446 if (data_bo_handle == NULL || data_bo_handle->ptr == NULL) {
447 LOGE("no data pointer");
451 buf_pos = data_bo_handle->ptr;
453 if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) {
454 frame->data.encoded_plane.data = buf_pos;
455 frame->data.encoded_plane.size = stream->data.encoded.length_data;
456 total_size = stream->data.encoded.length_data;
458 switch (stream->num_planes) {
460 frame->data.single_plane.yuv = buf_pos;
461 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
462 total_size = stream->data.yuv420.length_yuv;
465 frame->data.double_plane.y = buf_pos;
466 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
467 buf_pos += stream->data.yuv420sp.length_y;
468 frame->data.double_plane.uv = buf_pos;
469 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
470 total_size = stream->data.yuv420sp.length_y + \
471 stream->data.yuv420sp.length_uv;
474 frame->data.triple_plane.y = buf_pos;
475 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
476 buf_pos += stream->data.yuv420p.length_y;
477 frame->data.triple_plane.u = buf_pos;
478 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
479 buf_pos += stream->data.yuv420p.length_u;
480 frame->data.triple_plane.v = buf_pos;
481 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
482 total_size = stream->data.yuv420p.length_y + \
483 stream->data.yuv420p.length_u + \
484 stream->data.yuv420p.length_v;
492 switch (stream->num_planes) {
494 frame->data.single_plane.yuv = buffer_bo_handle[0].ptr;
495 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
496 total_size = stream->data.yuv420.length_yuv;
499 frame->data.double_plane.y = buffer_bo_handle[0].ptr;
500 if (stream->num_planes == (unsigned int)num_buffer_key)
501 frame->data.double_plane.uv = buffer_bo_handle[1].ptr;
503 frame->data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
504 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
505 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
506 total_size = stream->data.yuv420sp.length_y + \
507 stream->data.yuv420sp.length_uv;
510 frame->data.triple_plane.y = buffer_bo_handle[0].ptr;
511 if (stream->num_planes == (unsigned int)num_buffer_key) {
512 frame->data.triple_plane.u = buffer_bo_handle[1].ptr;
513 frame->data.triple_plane.v = buffer_bo_handle[2].ptr;
515 frame->data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y;
516 frame->data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u;
518 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
519 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
520 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
521 total_size = stream->data.yuv420p.length_y + \
522 stream->data.yuv420p.length_u + \
523 stream->data.yuv420p.length_v;
531 LOGD("format %d, %dx%d, size %d plane num %d",
532 frame.format, frame.width, frame.height, total_size, frame.num_of_planes);
538 int _camera_media_packet_data_create(int tbm_key, int num_buffer_key, tbm_bo bo,
539 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
542 int ret = CAMERA_ERROR_NONE;
543 camera_media_packet_data *tmp_mp_data = NULL;
545 if (*mp_data == NULL) {
546 tmp_mp_data = g_new0(camera_media_packet_data, 1);
548 tmp_mp_data->tbm_key = tbm_key;
549 tmp_mp_data->num_buffer_key = num_buffer_key;
550 tmp_mp_data->bo = bo;
551 tmp_mp_data->data_bo = data_bo;
552 tmp_mp_data->ref_cnt++;
554 for (i = 0 ; i < num_buffer_key ; i++)
555 tmp_mp_data->buffer_bo[i] = buffer_bo[i];
557 *mp_data = tmp_mp_data;
558 /*LOGD("mp_data %p", tmp_mp_data);*/
560 ret = CAMERA_ERROR_OUT_OF_MEMORY;
561 LOGE("failed to alloc media packet data");
564 ((camera_media_packet_data *)*mp_data)->ref_cnt++;
570 void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
575 if (mp_data == NULL || cb_info == NULL) {
576 LOGE("NULL data %p or cb_info %p", mp_data, cb_info);
580 if (mp_data->ref_cnt > 1) {
582 LOGD("mp_data is still referenced(current %d)", mp_data->ref_cnt);
584 /* release imported bo */
585 for (i = 0 ; i < mp_data->num_buffer_key ; i++) {
586 tbm_bo_unref(mp_data->buffer_bo[i]);
587 mp_data->buffer_bo[i] = NULL;
591 _release_imported_bo(&mp_data->bo);
592 _release_imported_bo(&mp_data->data_bo);
595 tbm_key = mp_data->tbm_key;
596 muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER,
597 cb_info->fd, cb_info, INT, tbm_key);
606 int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
607 camera_media_packet_data *mp_data, media_packet_h *packet)
609 media_packet_h pkt = NULL;
610 bool make_pkt_fmt = false;
611 tbm_surface_h tsurf = NULL;
612 tbm_surface_info_s tsurf_info;
613 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
614 uint32_t bo_format = 0;
617 int num_buffer_key = 0;
618 tbm_bo *buffer_bo = NULL;
620 if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) {
621 LOGE("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p",
622 cb_info, stream, mp_data, packet);
623 return CAMERA_ERROR_INVALID_PARAMETER;
626 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
627 buffer_bo = mp_data->buffer_bo;
628 num_buffer_key = mp_data->num_buffer_key;
630 /* create tbm surface */
631 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
632 tsurf_info.planes[i].stride = stream->stride[i];
634 /* get tbm surface format */
635 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
636 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
638 if (ret == CAMERA_ERROR_NONE) {
639 tsurf_info.width = stream->width;
640 tsurf_info.height = stream->height;
641 tsurf_info.format = bo_format;
642 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
643 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
645 if (num_buffer_key > 0) {
647 case TBM_FORMAT_NV12:
648 case TBM_FORMAT_NV21:
649 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
650 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
651 tsurf_info.planes[0].offset = 0;
652 if (num_buffer_key == 1)
653 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
654 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
656 case TBM_FORMAT_YUV420:
657 case TBM_FORMAT_YVU420:
658 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
659 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
660 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
661 tsurf_info.planes[0].offset = 0;
662 if (num_buffer_key == 1) {
663 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
664 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
666 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
668 case TBM_FORMAT_UYVY:
669 case TBM_FORMAT_YUYV:
670 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
671 tsurf_info.planes[0].offset = 0;
672 tsurf_info.size = tsurf_info.planes[0].size;
678 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_key);
679 } else if (mp_data->data_bo) {
681 case TBM_FORMAT_NV12:
682 case TBM_FORMAT_NV21:
683 tsurf_info.planes[0].size = stream->width * stream->height;
684 tsurf_info.planes[1].size = (tsurf_info.planes[0].size) >> 1;
685 tsurf_info.planes[0].offset = 0;
686 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
687 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
689 case TBM_FORMAT_YUV420:
690 case TBM_FORMAT_YVU420:
691 tsurf_info.planes[0].size = stream->width * stream->height;
692 tsurf_info.planes[1].size = (stream->width >> 1) * (stream->height >> 1);
693 tsurf_info.planes[2].size = tsurf_info.planes[1].size;
694 tsurf_info.planes[0].offset = 0;
695 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
696 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
697 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
699 case TBM_FORMAT_UYVY:
700 case TBM_FORMAT_YUYV:
701 tsurf_info.planes[0].size = (stream->width * stream->height) << 1;
702 tsurf_info.planes[0].offset = 0;
703 tsurf_info.size = tsurf_info.planes[0].size;
709 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1);
711 /*LOGD("tbm surface %p", tsurf);*/
715 /* check media packet format */
716 if (cb_info->pkt_fmt) {
717 int pkt_fmt_width = 0;
718 int pkt_fmt_height = 0;
719 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
721 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
722 if (pkt_fmt_mimetype != mimetype ||
723 pkt_fmt_width != stream->width ||
724 pkt_fmt_height != stream->height) {
725 LOGW("different format. current 0x%x, %dx%d, new 0x%x, %dx%d",
726 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height, mimetype, stream->width, stream->height);
727 media_format_unref(cb_info->pkt_fmt);
728 cb_info->pkt_fmt = NULL;
735 /* create packet format */
737 LOGW("make new pkt_fmt - mimetype 0x%x, %dx%d", mimetype, stream->width, stream->height);
738 ret = media_format_create(&cb_info->pkt_fmt);
739 if (ret == MEDIA_FORMAT_ERROR_NONE) {
740 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
741 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
742 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
743 LOGW("media_format_set_video_mime,width,height ret : 0x%x", ret);
745 LOGW("media_format_create failed");
749 /* create media packet */
750 ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt,
751 tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
752 (void *)cb_info, &pkt);
753 if (ret != MEDIA_PACKET_ERROR_NONE) {
754 LOGE("media_packet_create_from_tbm_surface failed");
756 tbm_surface_destroy(tsurf);
760 LOGE("failed to create tbm surface %dx%d, format %d, num_buffer_key %d, data_bo %p",
761 stream->width, stream->height, stream->format, num_buffer_key, mp_data->data_bo);
765 LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);
767 /* set media packet data */
768 ret = media_packet_set_extra(pkt, (void *)mp_data);
769 if (ret != MEDIA_PACKET_ERROR_NONE) {
770 LOGE("media_packet_set_extra failed");
772 _camera_media_packet_data_release(mp_data, cb_info);
775 media_packet_destroy(pkt);
778 /* set timestamp : msec -> nsec */
779 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
780 LOGW("media_packet_set_pts failed");
789 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
792 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
793 camera_media_packet_data *mp_data = NULL;
794 tbm_surface_h tsurf = NULL;
796 if (pkt == NULL || cb_info == NULL) {
797 LOGE("invalid parameter buffer %p, cb_info %p", pkt, cb_info);
798 return MEDIA_PACKET_FINALIZE;
801 ret = media_packet_get_extra(pkt, (void **)&mp_data);
802 if (ret != MEDIA_PACKET_ERROR_NONE) {
803 LOGE("media_packet_get_extra failed 0x%x", ret);
804 return MEDIA_PACKET_FINALIZE;
807 /*LOGD("mp_data %p", mp_data);*/
809 g_mutex_lock(&cb_info->mp_data_mutex);
811 _camera_media_packet_data_release(mp_data, cb_info);
814 g_mutex_unlock(&cb_info->mp_data_mutex);
816 ret = media_packet_get_tbm_surface(pkt, &tsurf);
817 if (ret != MEDIA_PACKET_ERROR_NONE) {
818 LOGE("media_packet_get_tbm_surface failed 0x%x", ret);
819 return MEDIA_PACKET_FINALIZE;
823 tbm_surface_destroy(tsurf);
827 return MEDIA_PACKET_FINALIZE;
830 static void _client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event)
836 tbm_bo_handle bo_handle = {NULL, };
838 if (recv_msg == NULL || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
839 LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event);
843 /*LOGD("get camera msg %s, event %d", recv_msg, event);*/
845 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
846 if (!(CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) &&
847 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] == NULL &&
848 cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] == NULL) {
849 LOGW("all preview callback from user are NULL");
852 } else if (cb_info->user_cb[event] == NULL) {
853 LOGW("user callback for event %d is not set", event);
858 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
864 muse_camera_msg_get(previous, recv_msg);
865 muse_camera_msg_get(current, recv_msg);
866 muse_camera_msg_get(by_policy, recv_msg);
868 LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
869 previous, current, by_policy);
871 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
872 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
875 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
879 muse_camera_msg_get(state, recv_msg);
881 LOGD("FOCUS state - %d", state);
883 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
886 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
887 LOGD("CAPTURE_COMPLETED");
888 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
890 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
891 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
893 int e_type = MUSE_CAMERA_EVENT_TYPE_PREVIEW;
896 int num_buffer_key = 0;
897 int buffer_key[BUFFER_MAX_PLANE_NUM] = {0, };
899 unsigned char *buf_pos = NULL;
901 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
902 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
903 tbm_bo data_bo = NULL;
904 tbm_bo_handle data_bo_handle = {.ptr = NULL};
906 camera_preview_data_s frame;
907 camera_stream_data_s *stream = NULL;
908 camera_media_packet_data *mp_data = NULL;
909 media_packet_h pkt = NULL;
911 muse_camera_msg_get(tbm_key, recv_msg);
912 muse_camera_msg_get(num_buffer_key, recv_msg);
913 muse_camera_msg_get_array(buffer_key, recv_msg);
914 muse_camera_msg_get(data_key, recv_msg);
916 memset(&frame, 0x0, sizeof(camera_preview_data_s));
919 LOGE("invalid key %d", tbm_key);
924 /* import tbm data_bo and get virtual address */
925 if (!_import_tbm_key(cb_info->bufmgr, data_key, &data_bo, &data_bo_handle)) {
926 LOGE("failed to import data key %d", data_key);
927 muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER,
928 cb_info->fd, cb_info, INT, tbm_key);
933 /* import tbm bo and get virtual address */
934 if (!_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
935 LOGE("failed to import key %d", tbm_key);
936 _release_imported_bo(&data_bo);
937 muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER,
938 cb_info->fd, cb_info, INT, tbm_key);
942 buf_pos = (unsigned char *)bo_handle.ptr;
944 /* get stream info */
945 stream = (camera_stream_data_s *)buf_pos;
947 for (i = 0 ; i < num_buffer_key ; i++) {
948 /* import buffer bo and get virtual address */
949 if (!_import_tbm_key(cb_info->bufmgr, buffer_key[i], &buffer_bo[i], &buffer_bo_handle[i])) {
950 LOGE("failed to import buffer key %d", buffer_key[i]);
952 /* release imported bo */
953 _release_imported_bo(&data_bo);
954 _release_imported_bo(&bo);
956 for (i -= 1 ; i >= 0 ; i--)
957 _release_imported_bo(&buffer_bo[i]);
959 /* send return buffer */
960 muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER,
961 cb_info->fd, cb_info, INT, tbm_key);
967 /* call preview callback */
968 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
969 _camera_preview_frame_create(stream, num_buffer_key, buffer_bo_handle, &data_bo_handle, &frame);
971 e_type = MUSE_CAMERA_EVENT_TYPE_PREVIEW;
972 ((camera_preview_cb)cb_info->user_cb[e_type])(&frame, cb_info->user_data[e_type]);
975 /* call media packet callback */
976 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
977 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
979 if (ret == CAMERA_ERROR_NONE) {
980 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt);
982 e_type = MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW;
983 if (ret == CAMERA_ERROR_NONE) {
984 ((camera_media_packet_preview_cb)cb_info->user_cb[e_type])(pkt, cb_info->user_data[e_type]);
986 _camera_media_packet_data_release(mp_data, cb_info);
992 /* call evas renderer */
993 if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
994 #ifdef TIZEN_FEATURE_EVAS_RENDERER
995 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
997 if (ret == CAMERA_ERROR_NONE) {
998 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt);
1000 if (ret == CAMERA_ERROR_NONE) {
1001 g_mutex_lock(&cb_info->evas_mutex);
1003 if (cb_info->run_evas_render)
1004 mm_evas_renderer_write(pkt, cb_info->evas_info);
1006 LOGW("evas renderer is stopped, skip this buffer...");
1007 media_packet_destroy(pkt);
1012 g_mutex_unlock(&cb_info->evas_mutex);
1014 _camera_media_packet_data_release(mp_data, cb_info);
1018 #else /* TIZEN_FEATURE_EVAS_RENDERER */
1019 LOGW("evas renderer is not supported");
1020 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1023 /* send message for preview callback return */
1024 if (!CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS))
1025 muse_camera_msg_send_no_return(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info->fd, cb_info);
1027 if (mp_data == NULL) {
1028 /* release imported bo */
1029 for (i = 0 ; i < num_buffer_key ; i++)
1030 _release_imported_bo(&buffer_bo[i]);
1032 /* unmap and unref tbm bo */
1033 _release_imported_bo(&data_bo);
1034 _release_imported_bo(&bo);
1037 muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER,
1038 cb_info->fd, cb_info, INT, tbm_key);
1040 /*LOGD("return buffer Done");*/
1044 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1048 muse_camera_msg_get(percent, recv_msg);
1050 LOGD("HDR progress - %d \%", percent);
1052 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1055 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1061 muse_camera_msg_get(policy, recv_msg);
1062 muse_camera_msg_get(previous, recv_msg);
1063 muse_camera_msg_get(current, recv_msg);
1065 LOGD("INTERRUPTED - policy %d, state previous %d, current %d",
1066 policy, previous, current);
1068 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1069 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1072 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1075 camera_detected_face_s *faces = NULL;
1077 muse_camera_msg_get(count, recv_msg);
1078 muse_camera_msg_get(tbm_key, recv_msg);
1080 if (count > 0 && tbm_key > 0) {
1081 LOGD("FACE_DETECTION - count %d, tbm_key %d", count, tbm_key);
1083 if (!_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle))
1087 faces = bo_handle.ptr;
1089 ((camera_face_detected_cb)cb_info->user_cb[event])(faces, count, cb_info->user_data[event]);
1095 for (i = 0 ; i < count ; i++) {
1096 LOGD("id[%2d] - score %d, position (%d,%d,%dx%d)",
1097 i, faces[i].score, faces[i].x, faces[i].y, faces[i].width, faces[i].height);
1103 _release_imported_bo(&bo);
1106 muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER,
1107 cb_info->fd, cb_info, INT, tbm_key);
1109 /*LOGD("return buffer done");*/
1111 LOGE("invalid message - count %d, key %d", count, tbm_key);
1115 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1118 int current_state = 0;
1120 muse_camera_msg_get(error, recv_msg);
1121 muse_camera_msg_get(current_state, recv_msg);
1123 LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
1125 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1126 (camera_state_e)current_state, cb_info->user_data[event]);
1129 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1130 muse_camera_msg_get(param1, recv_msg);
1131 muse_camera_msg_get(param2, recv_msg);
1133 /*LOGD("SUPPORTED_PREVIEW_RESOLUTION - %d x %d", param1, param2);*/
1135 if (((camera_supported_preview_resolution_cb)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1136 cb_info->user_cb[event] = NULL;
1137 cb_info->user_data[event] = NULL;
1138 LOGW("stop foreach callback for SUPPORTED_PREVIEW_RESOLUTION");
1141 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1142 muse_camera_msg_get(param1, recv_msg);
1143 muse_camera_msg_get(param2, recv_msg);
1145 /*LOGD("SUPPORTED_CAPTURE_RESOLUTION - %d x %d", param1, param2);*/
1147 if (((camera_supported_capture_resolution_cb)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1148 cb_info->user_cb[event] = NULL;
1149 cb_info->user_data[event] = NULL;
1150 LOGW("stop foreach callback for SUPPORTED_CAPTURE_RESOLUTION");
1153 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1154 muse_camera_msg_get(param1, recv_msg);
1156 /*LOGD("SUPPORTED_CAPTURE_FORMAT - %d ", param1);*/
1158 if (((camera_supported_capture_format_cb)cb_info->user_cb[event])((camera_pixel_format_e)param1, cb_info->user_data[event]) == false) {
1159 cb_info->user_cb[event] = NULL;
1160 cb_info->user_data[event] = NULL;
1161 LOGW("stop foreach callback for SUPPORTED_CAPTURE_FORMAT");
1164 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1165 muse_camera_msg_get(param1, recv_msg);
1167 /*LOGD("SUPPORTED_PREVIEW_FORMAT - %d ", param1);*/
1169 if (((camera_supported_preview_format_cb)cb_info->user_cb[event])((camera_pixel_format_e)param1, cb_info->user_data[event]) == false) {
1170 cb_info->user_cb[event] = NULL;
1171 cb_info->user_data[event] = NULL;
1172 LOGW("stop foreach callback for SUPPORTED_PREVIEW_FORMAT");
1175 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1176 muse_camera_msg_get(param1, recv_msg);
1178 /*LOGD("SUPPORTED_AF_MODE - %d ", param1);*/
1180 if (((camera_attr_supported_af_mode_cb)cb_info->user_cb[event])((camera_attr_af_mode_e)param1, cb_info->user_data[event]) == false) {
1181 cb_info->user_cb[event] = NULL;
1182 cb_info->user_data[event] = NULL;
1183 LOGW("stop foreach callback for SUPPORTED_AF_MODE");
1186 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1187 muse_camera_msg_get(param1, recv_msg);
1189 /*LOGD("SUPPORTED_EXPOSURE_MODE - %d ", param1);*/
1191 if (((camera_attr_supported_exposure_mode_cb)cb_info->user_cb[event])((camera_attr_exposure_mode_e)param1, cb_info->user_data[event]) == false) {
1192 cb_info->user_cb[event] = NULL;
1193 cb_info->user_data[event] = NULL;
1194 LOGW("stop foreach callback for SUPPORTED_EXPOSURE_MODE");
1197 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1198 muse_camera_msg_get(param1, recv_msg);
1200 /*LOGD("SUPPORTED_ISO - %d ", param1);*/
1202 if (((camera_attr_supported_iso_cb)cb_info->user_cb[event])((camera_attr_iso_e)param1, cb_info->user_data[event]) == false) {
1203 cb_info->user_cb[event] = NULL;
1204 cb_info->user_data[event] = NULL;
1205 LOGW("stop foreach callback for SUPPORTED_ISO");
1208 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1209 muse_camera_msg_get(param1, recv_msg);
1211 /*LOGD("SUPPORTED_WHITEBALANCE - %d ", param1);*/
1213 if (((camera_attr_supported_whitebalance_cb)cb_info->user_cb[event])((camera_attr_whitebalance_e)param1, cb_info->user_data[event]) == false) {
1214 cb_info->user_cb[event] = NULL;
1215 cb_info->user_data[event] = NULL;
1216 LOGW("stop foreach callback for SUPPORTED_WHITEBALANCE");
1219 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1220 muse_camera_msg_get(param1, recv_msg);
1222 /*LOGD("SUPPORTED_EFFECT - %d ", param1);*/
1224 if (((camera_attr_supported_effect_cb)cb_info->user_cb[event])((camera_attr_effect_mode_e)param1, cb_info->user_data[event]) == false) {
1225 cb_info->user_cb[event] = NULL;
1226 cb_info->user_data[event] = NULL;
1227 LOGW("stop foreach callback for SUPPORTED_EFFECT");
1230 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1231 muse_camera_msg_get(param1, recv_msg);
1233 /*LOGD("SUPPORTED_SCENE_MODE - %d ", param1);*/
1235 if (((camera_attr_supported_scene_mode_cb)cb_info->user_cb[event])((camera_attr_scene_mode_e)param1, cb_info->user_data[event]) == false) {
1236 cb_info->user_cb[event] = NULL;
1237 cb_info->user_data[event] = NULL;
1238 LOGW("stop foreach callback for SUPPORTED_SCENE_MODE");
1241 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1242 muse_camera_msg_get(param1, recv_msg);
1244 /*LOGD("SUPPORTED_FLASH_MODE - %d ", param1);*/
1246 if (((camera_attr_supported_flash_mode_cb)cb_info->user_cb[event])((camera_attr_flash_mode_e)param1, cb_info->user_data[event]) == false) {
1247 cb_info->user_cb[event] = NULL;
1248 cb_info->user_data[event] = NULL;
1249 LOGW("stop foreach callback for SUPPORTED_FLASH_MODE");
1252 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1253 muse_camera_msg_get(param1, recv_msg);
1255 /*LOGD("SUPPORTED_FPS - %d ", param1);*/
1257 if (((camera_attr_supported_fps_cb)cb_info->user_cb[event])((camera_attr_fps_e)param1, cb_info->user_data[event]) == false) {
1258 cb_info->user_cb[event] = NULL;
1259 cb_info->user_data[event] = NULL;
1260 LOGW("stop foreach callback for SUPPORTED_FPS");
1263 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1264 muse_camera_msg_get(param1, recv_msg);
1266 /*LOGD("SUPPORTED_FPS_BY_RESOLUTION - %d ", param1);*/
1268 if (((camera_attr_supported_fps_cb)cb_info->user_cb[event])((camera_attr_fps_e)param1, cb_info->user_data[event]) == false) {
1269 cb_info->user_cb[event] = NULL;
1270 cb_info->user_data[event] = NULL;
1271 LOGW("stop foreach callback for SUPPORTED_FPS_BY_RESOLUTION");
1274 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1275 muse_camera_msg_get(param1, recv_msg);
1277 /*LOGD("SUPPORTED_STREAM_FLIP - %d ", param1);*/
1279 if (((camera_attr_supported_stream_flip_cb)cb_info->user_cb[event])((camera_flip_e)param1, cb_info->user_data[event]) == false) {
1280 cb_info->user_cb[event] = NULL;
1281 cb_info->user_data[event] = NULL;
1282 LOGW("stop foreach callback for SUPPORTED_STREAM_FLIP");
1285 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1286 muse_camera_msg_get(param1, recv_msg);
1288 /*LOGD("SUPPORTED_STREAM_ROTATION - %d ", param1);*/
1290 if (((camera_attr_supported_stream_rotation_cb)cb_info->user_cb[event])((camera_rotation_e)param1, cb_info->user_data[event]) == false) {
1291 cb_info->user_cb[event] = NULL;
1292 cb_info->user_data[event] = NULL;
1293 LOGW("stop foreach callback for SUPPORTED_STREAM_ROTATION");
1296 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1297 muse_camera_msg_get(param1, recv_msg);
1299 /*LOGD("SUPPORTED_THEATER_MODE - %d ", param1);*/
1301 if (((camera_attr_supported_theater_mode_cb)cb_info->user_cb[event])((camera_attr_theater_mode_e)param1, cb_info->user_data[event]) == false) {
1302 cb_info->user_cb[event] = NULL;
1303 cb_info->user_data[event] = NULL;
1304 LOGW("stop foreach callback for SUPPORTED_THEATER_MODE");
1307 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1308 muse_camera_msg_get(param1, recv_msg);
1310 /*LOGD("SUPPORTED_PTZ_TYPE - %d ", param1);*/
1312 if (((camera_attr_supported_ptz_type_cb)cb_info->user_cb[event])((camera_attr_ptz_type_e)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 SUPPORTED_PTZ_TYPE");
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 tbm_key_main %d", tbm_key_main);
1348 /* import tbm bo and get virtual address */
1349 if (!_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 (!_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 (!_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 _release_imported_bo(&bo_main);
1387 tbm_key = tbm_key_main;
1388 muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER,
1389 cb_info->fd, cb_info, INT, tbm_key);
1391 if (tbm_key_post > 0) {
1392 /* unmap and unref tbm bo */
1393 _release_imported_bo(&bo_post);
1396 tbm_key = tbm_key_post;
1397 muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER,
1398 cb_info->fd, cb_info, INT, tbm_key);
1401 if (tbm_key_thumb > 0) {
1402 /* unmap and unref tbm bo */
1403 _release_imported_bo(&bo_thumb);
1406 tbm_key = tbm_key_thumb;
1407 muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER,
1408 cb_info->fd, cb_info, INT, tbm_key);
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);
1445 if (cb_info->idle_event_list)
1446 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1448 /*LOGD("remove camera idle event %p, %p", cam_idle_event, cb_info->idle_event_list);*/
1449 g_mutex_unlock(&cb_info->idle_event_mutex);
1452 _client_user_callback(cam_idle_event->cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
1454 /* send signal for waiting thread */
1455 g_cond_signal(&cb_info->idle_event_cond);
1457 IDLE_EVENT_CALLBACK_DONE:
1458 /* unlock and release event */
1459 g_mutex_unlock(&cam_idle_event->event_mutex);
1460 g_mutex_clear(&cam_idle_event->event_mutex);
1462 g_free(cam_idle_event);
1463 cam_idle_event = NULL;
1468 static void *_camera_msg_handler_func(gpointer data)
1473 int event_class = 0;
1474 camera_message_s *cam_msg = NULL;
1475 camera_idle_event_s *cam_idle_event = NULL;
1476 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
1478 if (cb_info == NULL) {
1479 LOGE("cb_info NULL");
1485 g_mutex_lock(&cb_info->msg_handler_mutex);
1487 while (g_atomic_int_get(&cb_info->msg_handler_running)) {
1488 if (g_queue_is_empty(cb_info->msg_queue)) {
1489 /*LOGD("signal wait...");*/
1490 g_cond_wait(&cb_info->msg_handler_cond, &cb_info->msg_handler_mutex);
1491 /*LOGD("signal received");*/
1493 if (g_atomic_int_get(&cb_info->msg_handler_running) == 0) {
1494 LOGD("stop event thread");
1499 cam_msg = (camera_message_s *)g_queue_pop_head(cb_info->msg_queue);
1501 g_mutex_unlock(&cb_info->msg_handler_mutex);
1503 if (cam_msg == NULL) {
1504 LOGE("NULL message");
1505 g_mutex_lock(&cb_info->msg_handler_mutex);
1511 if (api < MUSE_CAMERA_API_MAX) {
1512 g_mutex_lock(&cb_info->api_mutex[api]);
1514 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1515 cb_info->api_ret[api] = ret;
1516 cb_info->api_activating[api] = 1;
1518 /*LOGD("camera api %d - return 0x%x", ret);*/
1520 g_cond_signal(&cb_info->api_cond[api]);
1522 LOGE("failed to get camera ret for api %d, msg %s", api, cam_msg->recv_msg);
1525 g_mutex_unlock(&cb_info->api_mutex[api]);
1526 } else if (api == MUSE_CAMERA_CB_EVENT) {
1530 if (!muse_camera_msg_get(event, cam_msg->recv_msg) ||
1531 !muse_camera_msg_get(event_class, cam_msg->recv_msg)) {
1532 LOGE("failed to get camera event %d, class %d", event, event_class);
1537 g_mutex_lock(&cb_info->msg_handler_mutex);
1541 switch (event_class) {
1542 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1543 _client_user_callback(cb_info, cam_msg->recv_msg, event);
1545 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1546 cam_idle_event = g_new0(camera_idle_event_s, 1);
1547 if (cam_idle_event == NULL) {
1548 LOGE("cam_idle_event alloc failed");
1552 cam_idle_event->event = event;
1553 cam_idle_event->cb_info = cb_info;
1554 g_mutex_init(&cam_idle_event->event_mutex);
1555 memcpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg));
1557 /*LOGD("add camera event[%d, %p] to IDLE", event, cam_idle_event);*/
1559 g_mutex_lock(&cb_info->idle_event_mutex);
1560 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1561 g_mutex_unlock(&cb_info->idle_event_mutex);
1563 g_idle_add_full(G_PRIORITY_DEFAULT,
1564 (GSourceFunc)_camera_idle_event_callback,
1565 (gpointer)cam_idle_event,
1569 LOGE("unknown camera event class %d", event_class);
1573 LOGE("unknown camera api[%d] message[%s]", api, cam_msg->recv_msg);
1579 g_mutex_lock(&cb_info->msg_handler_mutex);
1582 /* remove remained event */
1583 while (!g_queue_is_empty(cb_info->msg_queue)) {
1584 cam_msg = (camera_message_s *)g_queue_pop_head(cb_info->msg_queue);
1586 LOGD("remove camera message %p", cam_msg);
1590 LOGW("NULL camera message");
1594 g_mutex_unlock(&cb_info->msg_handler_mutex);
1601 static void _camera_remove_idle_event_all(camera_cb_info_s *cb_info)
1603 camera_idle_event_s *cam_idle_event = NULL;
1604 gboolean ret = TRUE;
1606 gint64 end_time = 0;
1608 if (cb_info == NULL) {
1609 LOGE("cb_info is NULL");
1613 g_mutex_lock(&cb_info->idle_event_mutex);
1615 if (cb_info->idle_event_list == NULL) {
1616 LOGD("No idle event is remained.");
1618 list = cb_info->idle_event_list;
1621 cam_idle_event = list->data;
1622 list = g_list_next(list);
1624 if (!cam_idle_event) {
1625 LOGW("Fail to remove idle event. The event is NULL");
1627 if (g_mutex_trylock(&cam_idle_event->event_mutex)) {
1628 ret = g_idle_remove_by_data(cam_idle_event);
1630 LOGD("remove idle event [%p], ret[%d]", cam_idle_event, ret);
1633 cam_idle_event->cb_info = NULL;
1634 LOGW("idle callback for event %p will be called later", cam_idle_event);
1637 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1639 g_mutex_unlock(&cam_idle_event->event_mutex);
1642 g_mutex_clear(&cam_idle_event->event_mutex);
1644 g_free(cam_idle_event);
1645 cam_idle_event = NULL;
1647 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");
1662 g_list_free(cb_info->idle_event_list);
1663 cb_info->idle_event_list = NULL;
1666 g_mutex_unlock(&cb_info->idle_event_mutex);
1671 static void *_camera_msg_recv_func(gpointer data)
1680 char *recv_msg = NULL;
1681 char **parse_str = NULL;
1682 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
1684 if (cb_info == NULL) {
1685 LOGE("cb_info NULL");
1691 parse_str = (char **)malloc(sizeof(char *) * CAMERA_PARSE_STRING_SIZE);
1692 if (parse_str == NULL) {
1693 LOGE("parse_str malloc failed");
1697 for (i = 0 ; i < CAMERA_PARSE_STRING_SIZE ; i++) {
1698 parse_str[i] = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
1699 if (parse_str[i] == NULL) {
1700 LOGE("parse_str[%d] malloc failed", i);
1701 goto CB_HANDLER_EXIT;
1705 recv_msg = cb_info->recv_msg;
1707 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
1708 ret = muse_core_ipc_recv_msg(cb_info->fd, recv_msg);
1711 recv_msg[ret] = '\0';
1717 /*LOGD("recvMSg : %s, length : %d", recv_msg, ret);*/
1719 /* Need to split the combined entering msgs.
1720 This module supports up to 200 combined msgs. */
1721 for (str_pos = 0; str_pos < ret; str_pos++) {
1722 if (recv_msg[str_pos] == '}') {
1723 memset(parse_str[num_token], 0x0, sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
1724 strncpy(parse_str[num_token], recv_msg + prev_pos, str_pos - prev_pos + 1);
1725 /*LOGD("splitted msg : [%s], Index : %d", parse_str[num_token], num_token);*/
1726 prev_pos = str_pos+1;
1731 /*LOGD("num_token : %d", num_token);*/
1733 /* Re-construct to the useful single msg. */
1734 for (i = 0; i < num_token; i++) {
1735 if (i >= CAMERA_PARSE_STRING_SIZE) {
1736 LOGE("invalid token index %d", i);
1743 if (!muse_camera_msg_get(api, parse_str[i])) {
1744 LOGE("failed to get camera api");
1748 if (api != MUSE_CAMERA_CB_EVENT) {
1749 if (!muse_camera_msg_get(api_class, parse_str[i])) {
1750 LOGE("failed to get camera api_class");
1755 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1756 if (api >= MUSE_CAMERA_API_MAX) {
1757 LOGE("invalid api %d", api);
1761 g_mutex_lock(&cb_info->api_mutex[api]);
1763 if (!muse_camera_msg_get(ret, parse_str[i])) {
1764 LOGE("failed to get camera ret");
1765 g_mutex_unlock(&cb_info->api_mutex[api]);
1769 cb_info->api_ret[api] = ret;
1770 cb_info->api_activating[api] = 1;
1772 if (api == MUSE_CAMERA_API_CREATE) {
1773 if (ret != CAMERA_ERROR_NONE) {
1774 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1775 LOGE("camera create error 0x%x. close client cb handler", ret);
1777 } else if (api == MUSE_CAMERA_API_DESTROY) {
1778 if (ret == CAMERA_ERROR_NONE) {
1779 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1780 LOGD("camera destroy done. close client cb handler");
1784 g_cond_signal(&cb_info->api_cond[api]);
1785 g_mutex_unlock(&cb_info->api_mutex[api]);
1786 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
1787 camera_message_s *cam_msg = g_new0(camera_message_s, 1);
1788 if (cam_msg == NULL) {
1789 LOGE("failed to alloc cam_msg");
1794 memcpy(cam_msg->recv_msg, parse_str[i], sizeof(cam_msg->recv_msg));
1796 /*LOGD("add camera message to queue : api %d", api);*/
1798 g_mutex_lock(&cb_info->msg_handler_mutex);
1799 g_queue_push_tail(cb_info->msg_queue, (gpointer)cam_msg);
1800 g_cond_signal(&cb_info->msg_handler_cond);
1801 g_mutex_unlock(&cb_info->msg_handler_mutex);
1803 LOGW("unknown camera api %d and api_class %d", api, api_class);
1809 LOGD("client cb exit");
1813 for (i = 0 ; i < CAMERA_PARSE_STRING_SIZE ; i++) {
1816 parse_str[i] = NULL;
1827 static camera_cb_info_s *_client_callback_new(gint sockfd)
1829 camera_cb_info_s *cb_info = NULL;
1830 gint *tmp_activating = NULL;
1831 gint *tmp_ret = NULL;
1834 g_return_val_if_fail(sockfd > 0, NULL);
1836 cb_info = g_new0(camera_cb_info_s, 1);
1837 if (cb_info == NULL) {
1838 LOGE("cb_info failed");
1842 g_mutex_init(&cb_info->msg_handler_mutex);
1843 g_cond_init(&cb_info->msg_handler_cond);
1844 g_mutex_init(&cb_info->idle_event_mutex);
1845 g_cond_init(&cb_info->idle_event_cond);
1846 g_mutex_init(&cb_info->mp_data_mutex);
1847 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1848 g_mutex_init(&cb_info->evas_mutex);
1849 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1851 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
1852 g_mutex_init(&cb_info->api_mutex[i]);
1853 g_cond_init(&cb_info->api_cond[i]);
1856 tmp_activating = g_new0(gint, MUSE_CAMERA_API_MAX);
1857 if (tmp_activating == NULL) {
1858 LOGE("tmp_activating failed");
1862 tmp_ret = g_new0(gint, MUSE_CAMERA_API_MAX);
1863 if (tmp_ret == NULL) {
1864 LOGE("tmp_ret failed");
1868 cb_info->msg_queue = g_queue_new();
1869 if (cb_info->msg_queue == NULL) {
1870 LOGE("msg_queue new failed");
1874 g_atomic_int_set(&cb_info->msg_handler_running, 1);
1875 cb_info->msg_handler_thread = g_thread_try_new("camera_msg_handler",
1876 _camera_msg_handler_func, (gpointer)cb_info, NULL);
1877 if (cb_info->msg_handler_thread == NULL) {
1878 LOGE("message handler thread creation failed");
1882 cb_info->fd = sockfd;
1883 cb_info->api_activating = tmp_activating;
1884 cb_info->api_ret = tmp_ret;
1885 cb_info->preview_cb_flag = 0;
1886 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1887 cb_info->evas_info = NULL;
1888 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1890 g_atomic_int_set(&cb_info->msg_recv_running, 1);
1891 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
1892 _camera_msg_recv_func, (gpointer)cb_info, NULL);
1893 if (cb_info->msg_recv_thread == NULL) {
1894 LOGE("message receive thread creation failed");
1902 if (cb_info->msg_handler_thread) {
1903 g_mutex_lock(&cb_info->msg_handler_mutex);
1904 g_atomic_int_set(&cb_info->msg_handler_running, 0);
1905 g_cond_signal(&cb_info->msg_handler_cond);
1906 g_mutex_unlock(&cb_info->msg_handler_mutex);
1908 g_thread_join(cb_info->msg_handler_thread);
1909 g_thread_unref(cb_info->msg_handler_thread);
1910 cb_info->msg_handler_thread = NULL;
1913 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
1914 g_mutex_clear(&cb_info->api_mutex[i]);
1915 g_cond_clear(&cb_info->api_cond[i]);
1918 g_mutex_clear(&cb_info->msg_handler_mutex);
1919 g_cond_clear(&cb_info->msg_handler_cond);
1920 g_mutex_clear(&cb_info->idle_event_mutex);
1921 g_cond_clear(&cb_info->idle_event_cond);
1922 g_mutex_clear(&cb_info->mp_data_mutex);
1923 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1924 g_mutex_clear(&cb_info->evas_mutex);
1925 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1927 if (cb_info->msg_queue) {
1928 g_queue_free(cb_info->msg_queue);
1929 cb_info->msg_queue = NULL;
1936 if (tmp_activating) {
1937 g_free(tmp_activating);
1938 tmp_activating = NULL;
1948 static void _client_callback_destroy(camera_cb_info_s *cb_info)
1952 g_return_if_fail(cb_info != NULL);
1954 LOGD("MSG receive thread[%p] destroy", cb_info->msg_recv_thread);
1956 g_thread_join(cb_info->msg_recv_thread);
1957 g_thread_unref(cb_info->msg_recv_thread);
1958 cb_info->msg_recv_thread = NULL;
1960 LOGD("msg thread removed");
1962 g_mutex_lock(&cb_info->msg_handler_mutex);
1963 g_atomic_int_set(&cb_info->msg_handler_running, 0);
1964 g_cond_signal(&cb_info->msg_handler_cond);
1965 g_mutex_unlock(&cb_info->msg_handler_mutex);
1967 g_thread_join(cb_info->msg_handler_thread);
1968 g_thread_unref(cb_info->msg_handler_thread);
1969 cb_info->msg_handler_thread = NULL;
1971 g_queue_free(cb_info->msg_queue);
1972 cb_info->msg_queue = NULL;
1974 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
1975 g_mutex_clear(&cb_info->api_mutex[i]);
1976 g_cond_clear(&cb_info->api_cond[i]);
1979 g_mutex_clear(&cb_info->msg_handler_mutex);
1980 g_cond_clear(&cb_info->msg_handler_cond);
1981 g_mutex_clear(&cb_info->idle_event_mutex);
1982 g_cond_clear(&cb_info->idle_event_cond);
1983 g_mutex_clear(&cb_info->mp_data_mutex);
1984 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1985 g_mutex_clear(&cb_info->evas_mutex);
1986 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
1988 LOGD("event thread removed");
1990 if (cb_info->fd > -1) {
1991 muse_core_connection_close(cb_info->fd);
1995 if (cb_info->bufmgr) {
1996 tbm_bufmgr_deinit(cb_info->bufmgr);
1997 cb_info->bufmgr = NULL;
1999 if (cb_info->api_activating) {
2000 g_free(cb_info->api_activating);
2001 cb_info->api_activating = NULL;
2003 if (cb_info->api_ret) {
2004 g_free(cb_info->api_ret);
2005 cb_info->api_ret = NULL;
2007 if (cb_info->pkt_fmt) {
2008 media_format_unref(cb_info->pkt_fmt);
2009 cb_info->pkt_fmt = NULL;
2012 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2013 if (cb_info->evas_info)
2014 mm_evas_renderer_destroy(&cb_info->evas_info);
2015 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2017 cb_info->preview_cb_flag = 0;
2026 int _camera_start_evas_rendering(camera_h camera)
2028 int ret = CAMERA_ERROR_NONE;
2029 camera_cli_s *pc = (camera_cli_s *)camera;
2031 if (camera == NULL) {
2032 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2033 return CAMERA_ERROR_INVALID_PARAMETER;
2036 if (pc->cb_info == NULL) {
2037 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2038 return CAMERA_ERROR_INVALID_PARAMETER;
2043 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2044 LOGE("EVAS surface is not set");
2045 return CAMERA_ERROR_NONE;
2048 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2049 g_mutex_lock(&pc->cb_info->evas_mutex);
2051 /* set evas render flag as RUN */
2052 pc->cb_info->run_evas_render = true;
2053 ret = CAMERA_ERROR_NONE;
2055 g_mutex_unlock(&pc->cb_info->evas_mutex);
2056 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2057 LOGW("evas renderer is not supported");
2058 ret = CAMERA_ERROR_NOT_SUPPORTED;
2059 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2065 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2067 int ret = CAMERA_ERROR_NONE;
2068 camera_cli_s *pc = (camera_cli_s *)camera;
2070 if (camera == NULL) {
2071 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2072 return CAMERA_ERROR_INVALID_PARAMETER;
2075 if (pc->cb_info == NULL) {
2076 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2077 return CAMERA_ERROR_INVALID_PARAMETER;
2080 LOGD("stop - keep screen %d", keep_screen);
2082 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2083 LOGE("EVAS surface is not set");
2084 return CAMERA_ERROR_NONE;
2087 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2088 g_mutex_lock(&pc->cb_info->evas_mutex);
2090 /* set evas render flag as STOP and release buffers */
2091 pc->cb_info->run_evas_render = false;
2093 ret = mm_evas_renderer_retrieve_all_packets(pc->cb_info->evas_info, keep_screen);
2094 if (ret != MM_ERROR_NONE) {
2095 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2096 ret = CAMERA_ERROR_INVALID_OPERATION;
2099 g_mutex_unlock(&pc->cb_info->evas_mutex);
2100 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2101 LOGW("evas renderer is not supported");
2102 ret = CAMERA_ERROR_NOT_SUPPORTED;
2103 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2109 int camera_create(camera_device_e device, camera_h *camera)
2113 int ret = CAMERA_ERROR_NONE;
2115 camera_cli_s *pc = NULL;
2116 tbm_bufmgr bufmgr = NULL;
2118 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2119 muse_core_api_module_e muse_module = MUSE_CAMERA;
2120 int device_type = (int)device;
2122 if (camera == NULL) {
2123 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2124 return CAMERA_ERROR_INVALID_PARAMETER;
2127 bufmgr = tbm_bufmgr_init(-1);
2128 if (bufmgr == NULL) {
2129 LOGE("get tbm bufmgr failed");
2130 return CAMERA_ERROR_INVALID_OPERATION;
2133 sock_fd = muse_core_client_new();
2135 LOGE("muse_core_client_new failed - returned fd %d", sock_fd);
2136 ret = CAMERA_ERROR_INVALID_OPERATION;
2142 sndMsg = muse_core_msg_json_factory_new(api,
2143 MUSE_TYPE_INT, "module", muse_module,
2144 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2145 MUSE_TYPE_INT, "pid", pid,
2148 muse_core_ipc_send_msg(sock_fd, sndMsg);
2149 muse_core_msg_json_factory_free(sndMsg);
2151 pc = g_new0(camera_cli_s, 1);
2153 LOGE("camera_cli_s alloc failed");
2154 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2158 pc->cb_info = _client_callback_new(sock_fd);
2159 if (pc->cb_info == NULL) {
2160 LOGE("cb_info alloc failed");
2161 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2165 LOGD("cb info : %d", pc->cb_info->fd);
2167 ret = _client_wait_for_cb_return(api, pc->cb_info, CALLBACK_TIME_OUT);
2168 if (ret == CAMERA_ERROR_NONE) {
2169 intptr_t handle = 0;
2170 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2172 LOGE("Receiving Handle Failed!!");
2173 ret = CAMERA_ERROR_INVALID_OPERATION;
2177 pc->remote_handle = handle;
2178 pc->cb_info->bufmgr = bufmgr;
2180 ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL);
2181 if (ret != CAMERA_ERROR_NONE) {
2182 LOGE("init display failed 0x%x", ret);
2186 LOGD("camera create 0x%x", pc->remote_handle);
2187 *camera = (camera_h)pc;
2195 tbm_bufmgr_deinit(bufmgr);
2199 _client_callback_destroy(pc->cb_info);
2205 LOGE("camera create error : 0x%x", ret);
2211 int camera_change_device(camera_h camera, camera_device_e device)
2213 int ret = CAMERA_ERROR_NONE;
2214 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2215 camera_cli_s *pc = (camera_cli_s *)camera;
2217 if (camera == NULL || pc->cb_info == NULL) {
2218 LOGE("NULL handle, INVALID_PARAMETER");
2219 return CAMERA_ERROR_INVALID_PARAMETER;
2222 muse_camera_msg_send1(api, pc->cb_info->fd, pc->cb_info, ret, INT, device);
2228 int camera_destroy(camera_h camera)
2230 if (camera == NULL) {
2231 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2232 return CAMERA_ERROR_INVALID_PARAMETER;
2235 int ret = CAMERA_ERROR_NONE;
2236 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2237 camera_cli_s *pc = (camera_cli_s *)camera;
2242 if (pc->cb_info == NULL) {
2243 LOGE("cb_info NULL, INVALID_PARAMETER");
2244 return CAMERA_ERROR_INVALID_PARAMETER;
2247 sock_fd = pc->cb_info->fd;
2249 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2250 if (ret == CAMERA_ERROR_NONE) {
2251 _camera_remove_idle_event_all(pc->cb_info);
2252 _client_callback_destroy(pc->cb_info);
2258 LOGE("camera destroy error : 0x%x", ret);
2264 int camera_start_preview(camera_h camera)
2266 int ret = CAMERA_ERROR_NONE;
2267 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2268 camera_cli_s *pc = (camera_cli_s *)camera;
2271 if (camera == NULL) {
2272 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2273 return CAMERA_ERROR_INVALID_PARAMETER;
2276 if (pc->cb_info == NULL) {
2277 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2278 return CAMERA_ERROR_INVALID_PARAMETER;
2283 sock_fd = pc->cb_info->fd;
2285 muse_camera_msg_send_longtime(api, sock_fd, pc->cb_info, ret);
2287 if (ret != CAMERA_ERROR_NONE) {
2288 LOGE("start preview failed 0x%x", ret);
2289 } else if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2290 ret = _camera_start_evas_rendering(camera);
2293 LOGD("ret : 0x%x", ret);
2298 int camera_stop_preview(camera_h camera)
2300 int ret = CAMERA_ERROR_NONE;
2302 camera_cli_s *pc = NULL;
2303 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2305 if (camera == NULL) {
2306 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2307 return CAMERA_ERROR_INVALID_PARAMETER;
2310 pc = (camera_cli_s *)camera;
2312 if (pc->cb_info == NULL) {
2313 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2314 return CAMERA_ERROR_INVALID_PARAMETER;
2317 sock_fd = pc->cb_info->fd;
2321 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2322 camera_state_e current_state = CAMERA_STATE_NONE;
2324 ret = camera_get_state(camera, ¤t_state);
2325 if (ret != CAMERA_ERROR_NONE) {
2326 LOGE("failed to get current state 0x%x", ret);
2330 if (current_state == CAMERA_STATE_PREVIEW) {
2331 ret = _camera_stop_evas_rendering(camera, false);
2332 if (ret != CAMERA_ERROR_NONE)
2337 /* send stop preview message */
2338 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2340 LOGD("ret : 0x%x", ret);
2345 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2347 if (camera == NULL) {
2348 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2349 return CAMERA_ERROR_INVALID_PARAMETER;
2351 int ret = CAMERA_ERROR_NONE;
2353 camera_cli_s *pc = (camera_cli_s *)camera;
2354 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2356 int is_capturing_cb = 0;
2357 int is_completed_cb = 0;
2358 LOGD("Enter, handle :%x", pc->remote_handle);
2360 if (pc->cb_info == NULL) {
2361 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2362 return CAMERA_ERROR_INVALID_PARAMETER;
2365 sock_fd = pc->cb_info->fd;
2367 if (capturing_cb != NULL) {
2368 is_capturing_cb = 1;
2369 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2370 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2373 if (completed_cb != NULL) {
2374 is_completed_cb = 1;
2375 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2376 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2379 muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, is_capturing_cb, INT, is_completed_cb);
2380 LOGD("is_capturing_cb :%d, is_completed_cb : %d", is_capturing_cb, is_completed_cb);
2381 LOGD("ret : 0x%x", ret);
2385 bool camera_is_supported_continuous_capture(camera_h camera)
2387 if (camera == NULL) {
2388 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2392 int ret = CAMERA_ERROR_NONE;
2393 camera_cli_s *pc = (camera_cli_s *)camera;
2394 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2397 if (pc->cb_info == NULL) {
2398 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2399 return CAMERA_ERROR_INVALID_PARAMETER;
2402 sock_fd = pc->cb_info->fd;
2404 LOGD("Enter, remote_handle : %x", pc->remote_handle);
2405 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2406 LOGD("ret : 0x%x", ret);
2410 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)
2412 if (camera == NULL) {
2413 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2414 return CAMERA_ERROR_INVALID_PARAMETER;
2417 int ret = CAMERA_ERROR_NONE;
2419 camera_cli_s *pc = (camera_cli_s *)camera;
2420 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2422 LOGD("Enter, handle :%x", pc->remote_handle);
2425 if (pc->cb_info == NULL) {
2426 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2427 return CAMERA_ERROR_INVALID_PARAMETER;
2429 sock_fd = pc->cb_info->fd;
2431 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2432 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2433 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2435 muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, count, INT, interval);
2437 LOGD("ret : 0x%x", ret);
2442 int camera_stop_continuous_capture(camera_h camera)
2444 if (camera == NULL) {
2445 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2446 return CAMERA_ERROR_INVALID_PARAMETER;
2450 int ret = CAMERA_ERROR_NONE;
2452 camera_cli_s *pc = (camera_cli_s *)camera;
2453 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2454 LOGD("Enter, handle :%x", pc->remote_handle);
2456 if (pc->cb_info == NULL) {
2457 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2458 return CAMERA_ERROR_INVALID_PARAMETER;
2460 sock_fd = pc->cb_info->fd;
2461 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2462 LOGD("ret : 0x%x", ret);
2466 bool camera_is_supported_face_detection(camera_h camera)
2468 if (camera == NULL) {
2469 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2472 int ret = CAMERA_ERROR_NONE;
2474 camera_cli_s *pc = (camera_cli_s *)camera;
2475 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2477 if (pc->cb_info == NULL) {
2478 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2479 return CAMERA_ERROR_INVALID_PARAMETER;
2481 sock_fd = pc->cb_info->fd;
2483 LOGD("Enter, remote_handle : %x", pc->remote_handle);
2484 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2485 LOGD("ret : 0x%x", ret);
2489 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2491 if (camera == NULL) {
2492 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2495 int ret = CAMERA_ERROR_NONE;
2497 camera_cli_s *pc = (camera_cli_s *)camera;
2498 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2500 if (pc->cb_info == NULL) {
2501 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2502 return CAMERA_ERROR_INVALID_PARAMETER;
2504 sock_fd = pc->cb_info->fd;
2506 LOGD("Enter, remote_handle : %x", pc->remote_handle);
2507 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2508 LOGD("ret : 0x%x", ret);
2512 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2514 if (camera == NULL) {
2515 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2519 int ret = CAMERA_ERROR_NONE;
2521 camera_cli_s *pc = (camera_cli_s *)camera;
2522 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2524 if (pc->cb_info == NULL) {
2525 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2526 return CAMERA_ERROR_INVALID_PARAMETER;
2528 sock_fd = pc->cb_info->fd;
2530 LOGD("Enter, remote_handle : %x", pc->remote_handle);
2531 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2532 LOGD("ret : 0x%x", ret);
2536 int camera_get_device_count(camera_h camera, int *device_count)
2538 if (camera == NULL || device_count == NULL) {
2539 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2540 return CAMERA_ERROR_INVALID_PARAMETER;
2542 int ret = CAMERA_ERROR_NONE;
2544 camera_cli_s *pc = (camera_cli_s *)camera;
2545 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2547 if (pc->cb_info == NULL) {
2548 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2549 return CAMERA_ERROR_INVALID_PARAMETER;
2551 sock_fd = pc->cb_info->fd;
2552 int get_device_count;
2554 LOGD("Enter, remote_handle : %x", pc->remote_handle);
2555 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2557 if (ret == CAMERA_ERROR_NONE) {
2558 muse_camera_msg_get(get_device_count, pc->cb_info->recv_msg);
2559 *device_count = get_device_count;
2561 LOGD("ret : 0x%x", ret);
2565 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2567 if (camera == NULL) {
2568 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2569 return CAMERA_ERROR_INVALID_PARAMETER;
2572 int ret = CAMERA_ERROR_NONE;
2574 camera_cli_s *pc = (camera_cli_s *)camera;
2575 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2577 LOGD("Enter, handle :%x", pc->remote_handle);
2579 if (pc->cb_info == NULL) {
2580 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2581 return CAMERA_ERROR_INVALID_PARAMETER;
2583 sock_fd = pc->cb_info->fd;
2584 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2585 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2587 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2588 LOGD("ret : 0x%x", ret);
2592 int camera_stop_face_detection(camera_h camera)
2594 if (camera == NULL) {
2595 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2596 return CAMERA_ERROR_INVALID_PARAMETER;
2599 int ret = CAMERA_ERROR_NONE;
2601 camera_cli_s *pc = (camera_cli_s *)camera;
2602 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
2603 LOGD("Enter, handle :%x", pc->remote_handle);
2605 if (pc->cb_info == NULL) {
2606 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2607 return CAMERA_ERROR_INVALID_PARAMETER;
2609 sock_fd = pc->cb_info->fd;
2610 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2611 LOGD("ret : 0x%x", ret);
2615 int camera_get_state(camera_h camera, camera_state_e *state)
2617 if (camera == NULL || state == NULL) {
2618 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2619 return CAMERA_ERROR_INVALID_PARAMETER;
2621 int ret = CAMERA_ERROR_NONE;
2623 camera_cli_s *pc = (camera_cli_s *)camera;
2624 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
2626 if (pc->cb_info == NULL) {
2627 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2628 return CAMERA_ERROR_INVALID_PARAMETER;
2630 sock_fd = pc->cb_info->fd;
2633 LOGD("Enter, remote_handle : %x", pc->remote_handle);
2634 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2636 if (ret == CAMERA_ERROR_NONE) {
2637 muse_camera_msg_get(get_state, pc->cb_info->recv_msg);
2638 *state = (camera_state_e)get_state;
2640 LOGD("ret : 0x%x", ret);
2644 int camera_start_focusing(camera_h camera, bool continuous)
2646 if (camera == NULL) {
2647 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2648 return CAMERA_ERROR_INVALID_PARAMETER;
2651 int ret = CAMERA_ERROR_NONE;
2653 camera_cli_s *pc = (camera_cli_s *)camera;
2654 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
2656 if (pc->cb_info == NULL) {
2657 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2658 return CAMERA_ERROR_INVALID_PARAMETER;
2660 sock_fd = pc->cb_info->fd;
2661 int is_continuous = (int)continuous;
2663 LOGD("Enter, remote_handle : %x", pc->remote_handle);
2664 muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, is_continuous);
2665 LOGD("ret : 0x%x", ret);
2669 int camera_cancel_focusing(camera_h camera)
2671 if (camera == NULL) {
2672 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2673 return CAMERA_ERROR_INVALID_PARAMETER;
2676 int ret = CAMERA_ERROR_NONE;
2678 camera_cli_s *pc = (camera_cli_s *)camera;
2679 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
2681 if (pc->cb_info == NULL) {
2682 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2683 return CAMERA_ERROR_INVALID_PARAMETER;
2685 sock_fd = pc->cb_info->fd;
2687 LOGD("Enter, remote_handle : %x", pc->remote_handle);
2688 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2689 LOGD("ret : 0x%x", ret);
2693 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
2695 int ret = CAMERA_ERROR_NONE;
2696 void *set_display_handle = NULL;
2697 Evas_Object *obj = NULL;
2698 const char *object_type = NULL;
2699 camera_wl_info_s *wl_info = NULL;
2700 camera_cli_s *pc = (camera_cli_s *)camera;
2701 camera_cb_info_s *cb_info = NULL;
2702 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
2703 camera_state_e current_state = CAMERA_STATE_NONE;
2706 if (camera == NULL) {
2707 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2708 return CAMERA_ERROR_INVALID_PARAMETER;
2711 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
2712 LOGE("invalid type %d", type);
2713 return CAMERA_ERROR_INVALID_PARAMETER;
2716 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
2717 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
2718 return CAMERA_ERROR_INVALID_PARAMETER;
2721 if (pc->cb_info == NULL) {
2722 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2723 return CAMERA_ERROR_INVALID_PARAMETER;
2726 cb_info = (camera_cb_info_s *)pc->cb_info;
2727 sock_fd = cb_info->fd;
2729 ret = camera_get_state(camera, ¤t_state);
2730 if (ret != CAMERA_ERROR_NONE) {
2731 LOGE("failed to get current state 0x%x", ret);
2735 if (current_state != CAMERA_STATE_CREATED) {
2736 LOGE("INVALID_STATE : current %d", current_state);
2737 return CAMERA_ERROR_INVALID_STATE;
2740 LOGD("Enter, remote_handle : %x display : 0x%x", pc->remote_handle, display);
2742 if (type == CAMERA_DISPLAY_TYPE_NONE) {
2743 set_display_handle = 0;
2744 LOGD("display type NONE");
2746 obj = (Evas_Object *)display;
2747 object_type = evas_object_type_get(obj);
2749 if (type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
2750 /* get wayland parent id */
2751 if (_get_wl_info(obj, &pc->wl_info) != CAMERA_ERROR_NONE) {
2752 LOGE("failed to get wayland info");
2753 return CAMERA_ERROR_INVALID_OPERATION;
2756 set_display_handle = (void *)&pc->wl_info;
2757 LOGD("display type OVERLAY : handle %p", set_display_handle);
2758 } else if (type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
2759 /* evas object surface */
2760 set_display_handle = (void *)display;
2761 LOGD("display type EVAS : handle %p", set_display_handle);
2763 #ifdef TIZEN_FEATURE_EVAS_RENDERER
2764 g_mutex_lock(&cb_info->evas_mutex);
2766 if (cb_info->evas_info) {
2767 LOGW("destroy existed evas renderer %p", cb_info->evas_info);
2768 ret = mm_evas_renderer_destroy(&cb_info->evas_info);
2769 if (ret != MM_ERROR_NONE) {
2770 LOGE("failed to destroy evas renderer %p", cb_info->evas_info);
2771 g_mutex_unlock(&cb_info->evas_mutex);
2772 return CAMERA_ERROR_INVALID_OPERATION;
2776 /* create evas renderer */
2777 ret = mm_evas_renderer_create(&cb_info->evas_info, (Evas_Object *)set_display_handle);
2778 if (ret == MM_ERROR_NONE) {
2779 camera_flip_e flip = CAMERA_FLIP_NONE;
2780 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
2781 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
2788 camera_get_display_flip(camera, &flip);
2789 camera_get_display_mode(camera, &mode);
2790 camera_get_display_rotation(camera, &rotation);
2791 camera_is_display_visible(camera, &visible);
2792 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
2794 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
2795 flip, mode, rotation, visible, x, y, width, height);
2797 ret = mm_evas_renderer_set_flip(cb_info->evas_info, flip);
2798 ret |= mm_evas_renderer_set_geometry(cb_info->evas_info, mode);
2799 ret |= mm_evas_renderer_set_rotation(cb_info->evas_info, rotation);
2800 ret |= mm_evas_renderer_set_visible(cb_info->evas_info, visible);
2802 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
2803 ret |= mm_evas_renderer_set_roi_area(cb_info->evas_info, x, y, width, height);
2806 g_mutex_unlock(&cb_info->evas_mutex);
2808 if (ret != MM_ERROR_NONE) {
2809 LOGE("mm_evas_renderer error 0x%x", ret);
2810 return CAMERA_ERROR_INVALID_OPERATION;
2812 #else /* TIZEN_FEATURE_EVAS_RENDERER */
2813 LOGE("EVAS surface is not supported");
2814 return CAMERA_ERROR_NOT_SUPPORTED;
2815 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
2817 LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type);
2818 return CAMERA_ERROR_INVALID_PARAMETER;
2821 LOGE("failed to get evas object type from %p", obj);
2822 return CAMERA_ERROR_INVALID_PARAMETER;
2826 pc->display_handle = (intptr_t)set_display_handle;
2828 if (type == CAMERA_DISPLAY_TYPE_OVERLAY) {
2829 wl_info = &pc->wl_info;
2830 muse_camera_msg_send_array_and_value(api, sock_fd, cb_info, ret,
2831 wl_info, sizeof(camera_wl_info_s), sizeof(int), INT, type);
2833 LOGD("wayland parent id : %d, window %d,%d,%dx%d",
2834 wl_info->parent_id, wl_info->window_x, wl_info->window_y,
2835 wl_info->window_width, wl_info->window_height);
2837 muse_camera_msg_send1(api, sock_fd, cb_info, ret, INT, type);
2839 if (ret != CAMERA_ERROR_NONE)
2840 LOGE("set display error 0x%x", ret);
2841 else if (type == CAMERA_DISPLAY_TYPE_EVAS)
2842 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
2847 int camera_set_preview_resolution(camera_h camera, int width, int height)
2849 if (camera == NULL) {
2850 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2851 return CAMERA_ERROR_INVALID_PARAMETER;
2853 int ret = CAMERA_ERROR_NONE;
2855 camera_cli_s *pc = (camera_cli_s *)camera;
2856 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
2858 if (pc->cb_info == NULL) {
2859 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2860 return CAMERA_ERROR_INVALID_PARAMETER;
2862 sock_fd = pc->cb_info->fd;
2864 LOGD("Enter, remote_handle : %x", pc->remote_handle);
2865 muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, width, INT, height);
2866 LOGD("ret : 0x%x", ret);
2871 int camera_set_capture_resolution(camera_h camera, int width, int height)
2873 if (camera == NULL) {
2874 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2875 return CAMERA_ERROR_INVALID_PARAMETER;
2878 int ret = CAMERA_ERROR_NONE;
2880 camera_cli_s *pc = (camera_cli_s *)camera;
2881 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
2883 if (pc->cb_info == NULL) {
2884 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2885 return CAMERA_ERROR_INVALID_PARAMETER;
2887 sock_fd = pc->cb_info->fd;
2889 LOGD("Enter, remote_handle : %x", pc->remote_handle);
2890 muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, width, INT, height);
2891 LOGD("ret : 0x%x", ret);
2895 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
2897 if (camera == NULL) {
2898 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2899 return CAMERA_ERROR_INVALID_PARAMETER;
2902 int ret = CAMERA_ERROR_NONE;
2903 int set_format = (int)format;
2905 camera_cli_s *pc = (camera_cli_s *)camera;
2906 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
2908 if (pc->cb_info == NULL) {
2909 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2910 return CAMERA_ERROR_INVALID_PARAMETER;
2912 sock_fd = pc->cb_info->fd;
2914 LOGD("Enter, remote_handle : %x, capture_format: %d", pc->remote_handle, set_format);
2915 muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_format);
2916 LOGD("ret : 0x%x", ret);
2920 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
2922 if (camera == NULL) {
2923 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2924 return CAMERA_ERROR_INVALID_PARAMETER;
2927 int ret = CAMERA_ERROR_NONE;
2928 int set_format = (int)format;
2930 camera_cli_s *pc = (camera_cli_s *)camera;
2931 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
2933 if (pc->cb_info == NULL) {
2934 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2935 return CAMERA_ERROR_INVALID_PARAMETER;
2937 sock_fd = pc->cb_info->fd;
2939 LOGD("Enter, remote_handle : %x, capture_format: %d", pc->remote_handle, set_format);
2940 muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_format);
2941 LOGD("ret : 0x%x", ret);
2945 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
2947 if (camera == NULL || width == NULL || height == NULL) {
2948 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2949 return CAMERA_ERROR_INVALID_PARAMETER;
2953 int ret = CAMERA_ERROR_NONE;
2955 camera_cli_s *pc = (camera_cli_s *)camera;
2956 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
2958 if (pc->cb_info == NULL) {
2959 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2960 return CAMERA_ERROR_INVALID_PARAMETER;
2962 sock_fd = pc->cb_info->fd;
2966 LOGD("Enter, remote_handle : %x", pc->remote_handle);
2967 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2969 if (ret == CAMERA_ERROR_NONE) {
2970 muse_camera_msg_get(get_width, pc->cb_info->recv_msg);
2971 muse_camera_msg_get(get_height, pc->cb_info->recv_msg);
2973 *height = get_height;
2975 LOGD("ret : 0x%x", ret);
2979 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
2981 int ret = CAMERA_ERROR_NONE;
2982 int set_rotation = (int)rotation;
2983 camera_cli_s *pc = NULL;
2985 if (camera == NULL) {
2986 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2987 return CAMERA_ERROR_INVALID_PARAMETER;
2990 if (rotation < CAMERA_ROTATION_NONE || rotation > CAMERA_ROTATION_270) {
2991 LOGE("Invalid rotation %d", rotation);
2992 return CAMERA_ERROR_INVALID_PARAMETER;
2995 pc = (camera_cli_s *)camera;
2997 if (pc->cb_info == NULL) {
2998 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2999 return CAMERA_ERROR_INVALID_PARAMETER;
3002 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3003 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3004 g_mutex_lock(&pc->cb_info->evas_mutex);
3006 ret = mm_evas_renderer_set_rotation(pc->cb_info->evas_info, rotation);
3008 g_mutex_unlock(&pc->cb_info->evas_mutex);
3010 if (ret != MM_ERROR_NONE) {
3011 LOGE("failed to set rotation for evas surface 0x%x", ret);
3012 return CAMERA_ERROR_INVALID_OPERATION;
3015 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3017 muse_camera_msg_send1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION,
3018 pc->cb_info->fd, pc->cb_info, ret, INT, set_rotation);
3023 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3025 int ret = CAMERA_ERROR_NONE;
3026 int get_rotation = CAMERA_ROTATION_NONE;
3027 camera_cli_s *pc = NULL;
3029 if (camera == NULL || rotation == NULL) {
3030 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3031 return CAMERA_ERROR_INVALID_PARAMETER;
3034 pc = (camera_cli_s *)camera;
3036 if (pc->cb_info == NULL) {
3037 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3038 return CAMERA_ERROR_INVALID_PARAMETER;
3041 muse_camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION,
3042 pc->cb_info->fd, pc->cb_info, ret);
3044 if (ret == CAMERA_ERROR_NONE) {
3045 muse_camera_msg_get(get_rotation, pc->cb_info->recv_msg);
3046 *rotation = (camera_rotation_e)get_rotation;
3052 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3054 int ret = CAMERA_ERROR_NONE;
3055 int set_flip = (int)flip;
3056 camera_cli_s *pc = NULL;
3058 if (camera == NULL) {
3059 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3060 return CAMERA_ERROR_INVALID_PARAMETER;
3063 if (flip < CAMERA_FLIP_NONE || flip > CAMERA_FLIP_BOTH) {
3064 LOGE("Invalid flip %d", flip);
3065 return CAMERA_ERROR_INVALID_PARAMETER;
3068 pc = (camera_cli_s *)camera;
3070 if (pc->cb_info == NULL) {
3071 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3072 return CAMERA_ERROR_INVALID_PARAMETER;
3075 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3076 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3077 g_mutex_lock(&pc->cb_info->evas_mutex);
3079 ret = mm_evas_renderer_set_flip(pc->cb_info->evas_info, flip);
3081 g_mutex_unlock(&pc->cb_info->evas_mutex);
3083 if (ret != MM_ERROR_NONE) {
3084 LOGE("failed to set flip for evas surface 0x%x", ret);
3085 return CAMERA_ERROR_INVALID_OPERATION;
3088 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3090 muse_camera_msg_send1(MUSE_CAMERA_API_SET_DISPLAY_FLIP,
3091 pc->cb_info->fd, pc->cb_info, ret, INT, set_flip);
3096 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3098 int ret = CAMERA_ERROR_NONE;
3099 int get_flip = CAMERA_FLIP_NONE;
3100 camera_cli_s *pc = NULL;
3102 if (camera == NULL || flip == NULL) {
3103 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3104 return CAMERA_ERROR_INVALID_PARAMETER;
3107 pc = (camera_cli_s *)camera;
3109 if (pc->cb_info == NULL) {
3110 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3111 return CAMERA_ERROR_INVALID_PARAMETER;
3114 muse_camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP,
3115 pc->cb_info->fd, pc->cb_info, ret);
3117 if (ret == CAMERA_ERROR_NONE) {
3118 muse_camera_msg_get(get_flip, pc->cb_info->recv_msg);
3119 *flip = (camera_flip_e)get_flip;
3125 int camera_set_display_visible(camera_h camera, bool visible)
3127 int ret = CAMERA_ERROR_NONE;
3128 int set_visible = (int)visible;
3129 camera_cli_s *pc = NULL;
3131 if (camera == NULL) {
3132 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3133 return CAMERA_ERROR_INVALID_PARAMETER;
3136 pc = (camera_cli_s *)camera;
3138 if (pc->cb_info == NULL) {
3139 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3140 return CAMERA_ERROR_INVALID_PARAMETER;
3143 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3144 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3145 g_mutex_lock(&pc->cb_info->evas_mutex);
3147 ret = mm_evas_renderer_set_visible(pc->cb_info->evas_info, visible);
3149 g_mutex_unlock(&pc->cb_info->evas_mutex);
3151 if (ret != MM_ERROR_NONE) {
3152 LOGE("failed to set visible for evas surface 0x%x", ret);
3153 return CAMERA_ERROR_INVALID_OPERATION;
3156 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3158 muse_camera_msg_send1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE,
3159 pc->cb_info->fd, pc->cb_info, ret, INT, set_visible);
3164 int camera_is_display_visible(camera_h camera, bool *visible)
3166 int ret = CAMERA_ERROR_NONE;
3167 int get_visible = true;
3168 camera_cli_s *pc = NULL;
3170 if (camera == NULL || visible == NULL) {
3171 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3172 return CAMERA_ERROR_INVALID_PARAMETER;
3175 pc = (camera_cli_s *)camera;
3177 if (pc->cb_info == NULL) {
3178 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3179 return CAMERA_ERROR_INVALID_PARAMETER;
3182 muse_camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE,
3183 pc->cb_info->fd, pc->cb_info, ret);
3185 if (ret == CAMERA_ERROR_NONE) {
3186 muse_camera_msg_get(get_visible, pc->cb_info->recv_msg);
3187 *visible = (bool)get_visible;
3193 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3195 int ret = CAMERA_ERROR_NONE;
3196 int set_mode = (int)mode;
3197 camera_cli_s *pc = NULL;
3199 if (camera == NULL) {
3200 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3201 return CAMERA_ERROR_INVALID_PARAMETER;
3204 if (mode < CAMERA_DISPLAY_MODE_LETTER_BOX || mode > CAMERA_DISPLAY_MODE_CUSTOM_ROI) {
3205 LOGE("Invalid mode %d", mode);
3206 return CAMERA_ERROR_INVALID_PARAMETER;
3209 pc = (camera_cli_s *)camera;
3211 if (pc->cb_info == NULL) {
3212 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3213 return CAMERA_ERROR_INVALID_PARAMETER;
3216 #ifdef TIZEN_FEATURE_EVAS_RENDERER
3217 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3218 g_mutex_lock(&pc->cb_info->evas_mutex);
3220 ret = mm_evas_renderer_set_geometry(pc->cb_info->evas_info, mode);
3222 g_mutex_unlock(&pc->cb_info->evas_mutex);
3224 if (ret != MM_ERROR_NONE) {
3225 LOGE("failed to set geometry for evas surface 0x%x", ret);
3226 return CAMERA_ERROR_INVALID_OPERATION;
3229 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
3231 muse_camera_msg_send1(MUSE_CAMERA_API_SET_DISPLAY_MODE,
3232 pc->cb_info->fd, pc->cb_info, ret, INT, set_mode);
3237 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3239 int ret = CAMERA_ERROR_NONE;
3240 int get_mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3241 camera_cli_s *pc = NULL;
3243 if (camera == NULL || mode == NULL) {
3244 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3245 return CAMERA_ERROR_INVALID_PARAMETER;
3248 pc = (camera_cli_s *)camera;
3250 if (pc->cb_info == NULL) {
3251 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3252 return CAMERA_ERROR_INVALID_PARAMETER;
3255 muse_camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE,
3256 pc->cb_info->fd, pc->cb_info, ret);
3258 if (ret == CAMERA_ERROR_NONE) {
3259 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
3260 *mode = (camera_display_mode_e)get_mode;
3267 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3269 int ret = CAMERA_ERROR_NONE;
3270 int set_hint = (int)hint;
3271 camera_cli_s *pc = (camera_cli_s *)camera;
3273 if (camera == NULL) {
3274 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3275 return CAMERA_ERROR_INVALID_PARAMETER;
3278 if (pc->cb_info == NULL) {
3279 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3280 return CAMERA_ERROR_INVALID_PARAMETER;
3283 LOGD("set display reuse hint %d", set_hint);
3285 muse_camera_msg_send1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT,
3286 pc->cb_info->fd, pc->cb_info, ret, INT, set_hint);
3292 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3294 int ret = CAMERA_ERROR_NONE;
3296 camera_cli_s *pc = (camera_cli_s *)camera;
3297 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3299 if (camera == NULL || hint == NULL) {
3300 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3301 return CAMERA_ERROR_INVALID_PARAMETER;
3304 if (pc->cb_info == NULL) {
3305 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3306 return CAMERA_ERROR_INVALID_PARAMETER;
3309 muse_camera_msg_send(api, pc->cb_info->fd, pc->cb_info, ret);
3311 if (ret == CAMERA_ERROR_NONE) {
3312 muse_camera_msg_get(get_hint, pc->cb_info->recv_msg);
3313 *hint = (bool)get_hint;
3315 LOGD("display reuse hint %d", *hint);
3317 LOGE("failed 0x%x", ret);
3324 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3326 if (camera == NULL || width == NULL || height == NULL) {
3327 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3328 return CAMERA_ERROR_INVALID_PARAMETER;
3330 int ret = CAMERA_ERROR_NONE;
3332 camera_cli_s *pc = (camera_cli_s *)camera;
3333 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3335 if (pc->cb_info == NULL) {
3336 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3337 return CAMERA_ERROR_INVALID_PARAMETER;
3339 sock_fd = pc->cb_info->fd;
3343 LOGD("Enter, remote_handle : %x", pc->remote_handle);
3344 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3346 if (ret == CAMERA_ERROR_NONE) {
3347 muse_camera_msg_get(get_width, pc->cb_info->recv_msg);
3348 muse_camera_msg_get(get_height, pc->cb_info->recv_msg);
3350 *height = get_height;
3352 LOGD("ret : 0x%x", ret);
3356 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3358 if (camera == NULL || format == NULL) {
3359 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3360 return CAMERA_ERROR_INVALID_PARAMETER;
3362 int ret = CAMERA_ERROR_NONE;
3364 camera_cli_s *pc = (camera_cli_s *)camera;
3365 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3368 if (pc->cb_info == NULL) {
3369 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3370 return CAMERA_ERROR_INVALID_PARAMETER;
3372 sock_fd = pc->cb_info->fd;
3374 LOGD("Enter, remote_handle : %x", pc->remote_handle);
3375 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3377 if (ret == CAMERA_ERROR_NONE) {
3378 muse_camera_msg_get(get_format, pc->cb_info->recv_msg);
3379 *format = (camera_pixel_format_e)get_format;
3381 LOGD("ret : 0x%x", ret);
3385 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3387 if (camera == NULL || format == NULL) {
3388 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3389 return CAMERA_ERROR_INVALID_PARAMETER;
3392 int ret = CAMERA_ERROR_NONE;
3394 camera_cli_s *pc = (camera_cli_s *)camera;
3395 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3398 if (pc->cb_info == NULL) {
3399 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3400 return CAMERA_ERROR_INVALID_PARAMETER;
3402 sock_fd = pc->cb_info->fd;
3404 LOGD("Enter, remote_handle : %x", pc->remote_handle);
3405 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3407 if (ret == CAMERA_ERROR_NONE) {
3408 muse_camera_msg_get(get_format, pc->cb_info->recv_msg);
3409 *format = (camera_pixel_format_e)get_format;
3411 LOGD("ret : 0x%x", ret);
3415 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direciton)
3417 if (camera == NULL || facing_direciton == NULL) {
3418 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3419 return CAMERA_ERROR_INVALID_PARAMETER;
3422 int ret = CAMERA_ERROR_NONE;
3424 camera_cli_s *pc = (camera_cli_s *)camera;
3425 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3427 if (pc->cb_info == NULL) {
3428 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3429 return CAMERA_ERROR_INVALID_PARAMETER;
3431 sock_fd = pc->cb_info->fd;
3432 int get_facing_direction;
3434 LOGD("Enter, remote_handle : %x", pc->remote_handle);
3435 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3437 if (ret == CAMERA_ERROR_NONE) {
3438 muse_camera_msg_get(get_facing_direction, pc->cb_info->recv_msg);
3439 *facing_direciton = (camera_facing_direction_e)get_facing_direction;
3441 LOGD("ret : 0x%x", ret);
3445 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3447 if (camera == NULL || callback == NULL) {
3448 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3449 return CAMERA_ERROR_INVALID_PARAMETER;
3451 int ret = CAMERA_ERROR_NONE;
3453 camera_cli_s *pc = (camera_cli_s *)camera;
3454 camera_cb_info_s *cb_info = (camera_cb_info_s *)pc->cb_info;
3456 if (pc->cb_info == NULL) {
3457 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3458 return CAMERA_ERROR_INVALID_PARAMETER;
3460 sock_fd = pc->cb_info->fd;
3461 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3463 LOGD("Enter, handle :%x", pc->remote_handle);
3465 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3466 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3467 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_USER);
3469 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3470 LOGD("ret : 0x%x", ret);
3474 int camera_unset_preview_cb(camera_h camera)
3476 if (camera == NULL) {
3477 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3478 return CAMERA_ERROR_INVALID_PARAMETER;
3481 int ret = CAMERA_ERROR_NONE;
3483 camera_cli_s *pc = (camera_cli_s *)camera;
3484 camera_cb_info_s *cb_info = (camera_cb_info_s *)pc->cb_info;
3485 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3487 LOGD("Enter, handle :%x", pc->remote_handle);
3490 if (pc->cb_info == NULL) {
3491 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3492 return CAMERA_ERROR_INVALID_PARAMETER;
3494 sock_fd = pc->cb_info->fd;
3495 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = (void *)NULL;
3496 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = (void *)NULL;
3497 UNSET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_USER);
3499 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3500 LOGD("ret : 0x%x", ret);
3504 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3506 if (camera == NULL) {
3507 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
3508 return CAMERA_ERROR_INVALID_PARAMETER;
3511 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3512 LOGE("NOT SUPPORTED");
3513 return CAMERA_ERROR_NOT_SUPPORTED;
3516 if (callback == NULL) {
3517 LOGE("INVALID_PARAMETER(0x%08x) - callback", CAMERA_ERROR_INVALID_PARAMETER);
3518 return CAMERA_ERROR_INVALID_PARAMETER;
3521 int ret = CAMERA_ERROR_NONE;
3523 camera_cli_s *pc = (camera_cli_s *)camera;
3524 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3526 LOGD("Enter, handle :%x", pc->remote_handle);
3529 if (pc->cb_info == NULL) {
3530 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3531 return CAMERA_ERROR_INVALID_PARAMETER;
3533 sock_fd = pc->cb_info->fd;
3534 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3535 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3537 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3538 LOGD("ret : 0x%x", ret);
3542 int camera_unset_media_packet_preview_cb(camera_h camera)
3544 if (camera == NULL) {
3545 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3546 return CAMERA_ERROR_INVALID_PARAMETER;
3549 int ret = CAMERA_ERROR_NONE;
3551 camera_cli_s *pc = (camera_cli_s *)camera;
3552 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3554 LOGD("Enter, handle :%x", pc->remote_handle);
3557 if (pc->cb_info == NULL) {
3558 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3559 return CAMERA_ERROR_INVALID_PARAMETER;
3561 sock_fd = pc->cb_info->fd;
3562 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)NULL;
3563 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)NULL;
3565 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3566 LOGD("ret : 0x%x", ret);
3570 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3572 if (camera == NULL || callback == NULL) {
3573 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3574 return CAMERA_ERROR_INVALID_PARAMETER;
3576 int ret = CAMERA_ERROR_NONE;
3578 camera_cli_s *pc = (camera_cli_s *)camera;
3579 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3581 LOGD("Enter, handle :%x", pc->remote_handle);
3584 if (pc->cb_info == NULL) {
3585 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3586 return CAMERA_ERROR_INVALID_PARAMETER;
3588 sock_fd = pc->cb_info->fd;
3589 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3590 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3592 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3593 LOGD("ret : 0x%x", ret);
3596 int camera_unset_state_changed_cb(camera_h camera)
3598 if (camera == NULL) {
3599 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3600 return CAMERA_ERROR_INVALID_PARAMETER;
3602 int ret = CAMERA_ERROR_NONE;
3604 camera_cli_s *pc = (camera_cli_s *)camera;
3605 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3607 LOGD("Enter, handle :%x", pc->remote_handle);
3610 if (pc->cb_info == NULL) {
3611 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3612 return CAMERA_ERROR_INVALID_PARAMETER;
3614 sock_fd = pc->cb_info->fd;
3615 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void *)NULL;
3616 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void *)NULL;
3618 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3619 LOGD("ret : 0x%x", ret);
3623 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3625 if (camera == NULL || callback == NULL) {
3626 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3627 return CAMERA_ERROR_INVALID_PARAMETER;
3629 int ret = CAMERA_ERROR_NONE;
3631 camera_cli_s *pc = (camera_cli_s *)camera;
3632 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3634 LOGD("Enter, handle :%x", pc->remote_handle);
3637 if (pc->cb_info == NULL) {
3638 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3639 return CAMERA_ERROR_INVALID_PARAMETER;
3641 sock_fd = pc->cb_info->fd;
3642 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3643 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3645 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3646 LOGD("ret : 0x%x", ret);
3650 int camera_unset_interrupted_cb(camera_h camera)
3652 if (camera == NULL) {
3653 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3654 return CAMERA_ERROR_INVALID_PARAMETER;
3656 int ret = CAMERA_ERROR_NONE;
3658 camera_cli_s *pc = (camera_cli_s *)camera;
3659 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3661 LOGD("Enter, handle :%x", pc->remote_handle);
3664 if (pc->cb_info == NULL) {
3665 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3666 return CAMERA_ERROR_INVALID_PARAMETER;
3668 sock_fd = pc->cb_info->fd;
3669 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = (void *)NULL;
3670 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = (void *)NULL;
3672 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3673 LOGD("ret : 0x%x", ret);
3677 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
3679 if (camera == NULL || callback == NULL) {
3680 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3681 return CAMERA_ERROR_INVALID_PARAMETER;
3683 int ret = CAMERA_ERROR_NONE;
3685 camera_cli_s *pc = (camera_cli_s *)camera;
3686 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3688 LOGD("Enter, handle :%x", pc->remote_handle);
3691 if (pc->cb_info == NULL) {
3692 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3693 return CAMERA_ERROR_INVALID_PARAMETER;
3695 sock_fd = pc->cb_info->fd;
3696 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3697 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3699 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3700 LOGD("ret : 0x%x", ret);
3704 int camera_unset_focus_changed_cb(camera_h camera)
3706 if (camera == NULL) {
3707 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3708 return CAMERA_ERROR_INVALID_PARAMETER;
3710 int ret = CAMERA_ERROR_NONE;
3712 camera_cli_s *pc = (camera_cli_s *)camera;
3713 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
3715 LOGD("Enter, handle :%x", pc->remote_handle);
3718 if (pc->cb_info == NULL) {
3719 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3720 return CAMERA_ERROR_INVALID_PARAMETER;
3722 sock_fd = pc->cb_info->fd;
3723 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void *)NULL;
3724 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void *)NULL;
3726 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3727 LOGD("ret : 0x%x", ret);
3731 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
3733 if (camera == NULL || callback == NULL) {
3734 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3735 return CAMERA_ERROR_INVALID_PARAMETER;
3737 int ret = CAMERA_ERROR_NONE;
3739 camera_cli_s *pc = (camera_cli_s *)camera;
3740 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
3742 LOGD("Enter, handle :%x", pc->remote_handle);
3745 if (pc->cb_info == NULL) {
3746 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3747 return CAMERA_ERROR_INVALID_PARAMETER;
3749 sock_fd = pc->cb_info->fd;
3750 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
3751 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
3753 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3754 LOGD("ret : 0x%x", ret);
3758 int camera_unset_error_cb(camera_h camera)
3760 if (camera == NULL) {
3761 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3762 return CAMERA_ERROR_INVALID_PARAMETER;
3764 int ret = CAMERA_ERROR_NONE;
3766 camera_cli_s *pc = (camera_cli_s *)camera;
3767 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
3769 LOGD("Enter, handle :%x", pc->remote_handle);
3772 if (pc->cb_info == NULL) {
3773 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3774 return CAMERA_ERROR_INVALID_PARAMETER;
3776 sock_fd = pc->cb_info->fd;
3777 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = (void *)NULL;
3778 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = (void *)NULL;
3780 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3781 LOGD("ret : 0x%x", ret);
3785 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb , void *user_data)
3787 if (camera == NULL || foreach_cb == NULL) {
3788 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3789 return CAMERA_ERROR_INVALID_PARAMETER;
3791 int ret = CAMERA_ERROR_NONE;
3793 camera_cli_s *pc = (camera_cli_s *)camera;
3794 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
3796 LOGD("Enter, handle :%x", pc->remote_handle);
3799 if (pc->cb_info == NULL) {
3800 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3801 return CAMERA_ERROR_INVALID_PARAMETER;
3803 sock_fd = pc->cb_info->fd;
3804 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
3805 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
3807 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3808 LOGD("ret : 0x%x", ret);
3812 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb , void *user_data)
3814 if (camera == NULL || foreach_cb == NULL) {
3815 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3816 return CAMERA_ERROR_INVALID_PARAMETER;
3818 int ret = CAMERA_ERROR_NONE;
3820 camera_cli_s *pc = (camera_cli_s *)camera;
3821 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
3823 LOGD("Enter, handle :%x", pc->remote_handle);
3826 if (pc->cb_info == NULL) {
3827 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3828 return CAMERA_ERROR_INVALID_PARAMETER;
3830 sock_fd = pc->cb_info->fd;
3831 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
3832 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
3834 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3835 LOGD("ret : 0x%x", ret);
3839 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb , void *user_data)
3841 if (camera == NULL || foreach_cb == NULL) {
3842 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3843 return CAMERA_ERROR_INVALID_PARAMETER;
3845 int ret = CAMERA_ERROR_NONE;
3847 camera_cli_s *pc = (camera_cli_s *)camera;
3848 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
3850 LOGD("Enter, handle :%x", pc->remote_handle);
3853 if (pc->cb_info == NULL) {
3854 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3855 return CAMERA_ERROR_INVALID_PARAMETER;
3857 sock_fd = pc->cb_info->fd;
3858 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
3859 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
3861 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3862 LOGD("ret : 0x%x", ret);
3867 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb , void *user_data)
3869 if (camera == NULL || foreach_cb == NULL) {
3870 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3871 return CAMERA_ERROR_INVALID_PARAMETER;
3873 int ret = CAMERA_ERROR_NONE;
3875 camera_cli_s *pc = (camera_cli_s *)camera;
3876 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
3878 LOGD("Enter, handle :%x", pc->remote_handle);
3881 if (pc->cb_info == NULL) {
3882 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3883 return CAMERA_ERROR_INVALID_PARAMETER;
3885 sock_fd = pc->cb_info->fd;
3886 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
3887 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
3889 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3890 LOGD("ret : 0x%x", ret);
3895 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
3897 if (camera == NULL || width == NULL || height == NULL) {
3898 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3899 return CAMERA_ERROR_INVALID_PARAMETER;
3901 int ret = CAMERA_ERROR_NONE;
3903 camera_cli_s *pc = (camera_cli_s *)camera;
3904 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
3906 if (pc->cb_info == NULL) {
3907 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3908 return CAMERA_ERROR_INVALID_PARAMETER;
3910 sock_fd = pc->cb_info->fd;
3914 LOGD("Enter, remote_handle : %x", pc->remote_handle);
3915 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3917 if (ret == CAMERA_ERROR_NONE) {
3918 muse_camera_msg_get(get_width, pc->cb_info->recv_msg);
3919 muse_camera_msg_get(get_height, pc->cb_info->recv_msg);
3921 *height = get_height;
3923 LOGD("ret : 0x%x", ret);
3928 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
3930 if (camera == NULL || angle == NULL) {
3931 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3932 return CAMERA_ERROR_INVALID_PARAMETER;
3934 int ret = CAMERA_ERROR_NONE;
3936 camera_cli_s *pc = (camera_cli_s *)camera;
3937 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
3939 if (pc->cb_info == NULL) {
3940 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3941 return CAMERA_ERROR_INVALID_PARAMETER;
3943 sock_fd = pc->cb_info->fd;
3946 LOGD("Enter, remote_handle : %x", pc->remote_handle);
3947 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3949 if (ret == CAMERA_ERROR_NONE) {
3950 muse_camera_msg_get(get_angle, pc->cb_info->recv_msg);
3953 LOGD("ret : 0x%x", ret);
3957 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
3959 if (camera == NULL) {
3960 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3961 return CAMERA_ERROR_INVALID_PARAMETER;
3963 int ret = CAMERA_ERROR_NONE;
3964 camera_cli_s *pc = (camera_cli_s *)camera;
3965 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
3967 if (pc->cb_info == NULL) {
3968 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3969 return CAMERA_ERROR_INVALID_PARAMETER;
3971 sock_fd = pc->cb_info->fd;
3972 int set_mode = (int)mode;
3973 LOGD("Enter, remote_handle : %x", pc->remote_handle);
3974 muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
3975 LOGD("ret : 0x%x", ret);
3979 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
3981 if (camera == NULL || mode == NULL) {
3982 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3983 return CAMERA_ERROR_INVALID_PARAMETER;
3986 int ret = CAMERA_ERROR_NONE;
3987 camera_cli_s *pc = (camera_cli_s *)camera;
3988 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
3990 if (pc->cb_info == NULL) {
3991 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3992 return CAMERA_ERROR_INVALID_PARAMETER;
3994 sock_fd = pc->cb_info->fd;
3996 LOGD("Enter, remote_handle : %x", pc->remote_handle);
3997 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3999 if (ret == CAMERA_ERROR_NONE) {
4000 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
4001 *mode = (camera_attr_theater_mode_e)get_mode;
4003 LOGD("ret : 0x%x", ret);
4007 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4009 if (camera == NULL || foreach_cb == NULL) {
4010 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4011 return CAMERA_ERROR_INVALID_PARAMETER;
4013 int ret = CAMERA_ERROR_NONE;
4015 camera_cli_s *pc = (camera_cli_s *)camera;
4016 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4018 LOGD("Enter, handle :%x", pc->remote_handle);
4021 if (pc->cb_info == NULL) {
4022 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4023 return CAMERA_ERROR_INVALID_PARAMETER;
4025 sock_fd = pc->cb_info->fd;
4026 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4027 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4029 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4031 LOGD("Finish, return :%x", ret);
4036 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4038 if (camera == NULL) {
4039 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4040 return CAMERA_ERROR_INVALID_PARAMETER;
4042 int ret = CAMERA_ERROR_NONE;
4043 camera_cli_s *pc = (camera_cli_s *)camera;
4044 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4046 if (pc->cb_info == NULL) {
4047 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4048 return CAMERA_ERROR_INVALID_PARAMETER;
4050 sock_fd = pc->cb_info->fd;
4051 int set_fps = (int)fps;
4052 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4053 muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_fps);
4054 LOGD("ret : 0x%x", ret);
4059 int camera_attr_set_image_quality(camera_h camera, int quality)
4061 if (camera == NULL) {
4062 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4063 return CAMERA_ERROR_INVALID_PARAMETER;
4065 int ret = CAMERA_ERROR_NONE;
4067 camera_cli_s *pc = (camera_cli_s *)camera;
4068 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4070 if (pc->cb_info == NULL) {
4071 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4072 return CAMERA_ERROR_INVALID_PARAMETER;
4074 sock_fd = pc->cb_info->fd;
4075 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4076 muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, quality);
4077 LOGD("ret : 0x%x", ret);
4081 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4083 if (camera == NULL || fps == NULL) {
4084 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4085 return CAMERA_ERROR_INVALID_PARAMETER;
4087 int ret = CAMERA_ERROR_NONE;
4089 camera_cli_s *pc = (camera_cli_s *)camera;
4090 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4093 if (pc->cb_info == NULL) {
4094 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4095 return CAMERA_ERROR_INVALID_PARAMETER;
4097 sock_fd = pc->cb_info->fd;
4099 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4100 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4102 if (ret == CAMERA_ERROR_NONE) {
4103 muse_camera_msg_get(get_fps, pc->cb_info->recv_msg);
4104 *fps = (camera_attr_fps_e)get_fps;
4106 LOGD("ret : 0x%x", ret);
4111 int camera_attr_get_image_quality(camera_h camera, int *quality)
4113 if (camera == NULL || quality == NULL) {
4114 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4115 return CAMERA_ERROR_INVALID_PARAMETER;
4117 int ret = CAMERA_ERROR_NONE;
4119 camera_cli_s *pc = (camera_cli_s *)camera;
4120 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4122 if (pc->cb_info == NULL) {
4123 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4124 return CAMERA_ERROR_INVALID_PARAMETER;
4126 sock_fd = pc->cb_info->fd;
4128 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4129 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4131 if (ret == CAMERA_ERROR_NONE) {
4132 muse_camera_msg_get(get_quality, pc->cb_info->recv_msg);
4133 *quality = get_quality;
4135 LOGD("ret : 0x%x", ret);
4140 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4142 if (camera == NULL || bitrate == NULL) {
4143 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4144 return CAMERA_ERROR_INVALID_PARAMETER;
4147 int ret = CAMERA_ERROR_NONE;
4149 camera_cli_s *pc = (camera_cli_s *)camera;
4150 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4152 if (pc->cb_info == NULL) {
4153 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4154 return CAMERA_ERROR_INVALID_PARAMETER;
4156 sock_fd = pc->cb_info->fd;
4159 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4160 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4162 if (ret == CAMERA_ERROR_NONE) {
4163 muse_camera_msg_get(get_bitrate, pc->cb_info->recv_msg);
4164 *bitrate = get_bitrate;
4166 LOGD("ret : 0x%x", ret);
4171 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4173 if (camera == NULL) {
4174 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4175 return CAMERA_ERROR_INVALID_PARAMETER;
4178 int ret = CAMERA_ERROR_NONE;
4180 camera_cli_s *pc = (camera_cli_s *)camera;
4181 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4183 if (pc->cb_info == NULL) {
4184 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4185 return CAMERA_ERROR_INVALID_PARAMETER;
4187 sock_fd = pc->cb_info->fd;
4188 int set_bitrate = bitrate;
4189 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4190 muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_bitrate);
4191 LOGD("ret : 0x%x", ret);
4196 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4198 if (camera == NULL || interval == NULL) {
4199 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4200 return CAMERA_ERROR_INVALID_PARAMETER;
4203 int ret = CAMERA_ERROR_NONE;
4205 camera_cli_s *pc = (camera_cli_s *)camera;
4206 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4208 if (pc->cb_info == NULL) {
4209 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4210 return CAMERA_ERROR_INVALID_PARAMETER;
4212 sock_fd = pc->cb_info->fd;
4213 int get_gop_interval;
4215 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4216 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4218 if (ret == CAMERA_ERROR_NONE) {
4219 muse_camera_msg_get(get_gop_interval, pc->cb_info->recv_msg);
4220 *interval = get_gop_interval;
4222 LOGD("ret : 0x%x", ret);
4227 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4229 if (camera == NULL) {
4230 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4231 return CAMERA_ERROR_INVALID_PARAMETER;
4234 int ret = CAMERA_ERROR_NONE;
4236 camera_cli_s *pc = (camera_cli_s *)camera;
4237 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4239 if (pc->cb_info == NULL) {
4240 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4241 return CAMERA_ERROR_INVALID_PARAMETER;
4243 sock_fd = pc->cb_info->fd;
4244 int set_gop_interval = interval;
4245 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4246 muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_gop_interval);
4247 LOGD("ret : 0x%x", ret);
4252 int camera_attr_set_zoom(camera_h camera, int zoom)
4254 if (camera == NULL) {
4255 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4256 return CAMERA_ERROR_INVALID_PARAMETER;
4258 int ret = CAMERA_ERROR_NONE;
4260 camera_cli_s *pc = (camera_cli_s *)camera;
4261 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4263 if (pc->cb_info == NULL) {
4264 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4265 return CAMERA_ERROR_INVALID_PARAMETER;
4267 sock_fd = pc->cb_info->fd;
4269 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4270 muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, zoom);
4271 LOGD("ret : 0x%x", ret);
4275 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4277 if (camera == NULL) {
4278 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4279 return CAMERA_ERROR_INVALID_PARAMETER;
4281 int ret = CAMERA_ERROR_NONE;
4283 camera_cli_s *pc = (camera_cli_s *)camera;
4284 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4286 if (pc->cb_info == NULL) {
4287 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4288 return CAMERA_ERROR_INVALID_PARAMETER;
4290 sock_fd = pc->cb_info->fd;
4291 int set_mode = (int)mode;
4292 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4293 muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
4294 LOGD("ret : 0x%x", ret);
4298 int camera_attr_set_af_area(camera_h camera, int x, int y)
4300 if (camera == NULL) {
4301 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4302 return CAMERA_ERROR_INVALID_PARAMETER;
4304 int ret = CAMERA_ERROR_NONE;
4305 camera_cli_s *pc = (camera_cli_s *)camera;
4306 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4307 int sock_fd = pc->cb_info->fd;
4308 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4309 muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, x, INT, y);
4310 LOGD("ret : 0x%x", ret);
4315 int camera_attr_clear_af_area(camera_h camera)
4317 if (camera == NULL) {
4318 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4319 return CAMERA_ERROR_INVALID_PARAMETER;
4321 int ret = CAMERA_ERROR_NONE;
4323 camera_cli_s *pc = (camera_cli_s *)camera;
4324 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4326 if (pc->cb_info == NULL) {
4327 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4328 return CAMERA_ERROR_INVALID_PARAMETER;
4330 sock_fd = pc->cb_info->fd;
4331 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4332 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4333 LOGD("ret : 0x%x", ret);
4338 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4340 if (camera == NULL) {
4341 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4342 return CAMERA_ERROR_INVALID_PARAMETER;
4345 if (mode < CAMERA_ATTR_EXPOSURE_MODE_OFF || mode > CAMERA_ATTR_EXPOSURE_MODE_CUSTOM) {
4346 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4347 return CAMERA_ERROR_INVALID_PARAMETER;
4350 int ret = CAMERA_ERROR_NONE;
4351 camera_cli_s *pc = (camera_cli_s *)camera;
4352 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4353 int set_mode = (int)mode;
4355 if (pc->cb_info == NULL) {
4356 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4357 return CAMERA_ERROR_INVALID_PARAMETER;
4359 sock_fd = pc->cb_info->fd;
4360 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4361 muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
4362 LOGD("ret : 0x%x", ret);
4367 int camera_attr_set_exposure(camera_h camera, int value)
4369 if (camera == NULL) {
4370 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4371 return CAMERA_ERROR_INVALID_PARAMETER;
4373 int ret = CAMERA_ERROR_NONE;
4375 camera_cli_s *pc = (camera_cli_s *)camera;
4376 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4378 if (pc->cb_info == NULL) {
4379 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4380 return CAMERA_ERROR_INVALID_PARAMETER;
4382 sock_fd = pc->cb_info->fd;
4384 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4385 muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, value);
4386 LOGD("ret : 0x%x", ret);
4391 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4393 if (camera == NULL) {
4394 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4395 return CAMERA_ERROR_INVALID_PARAMETER;
4397 int ret = CAMERA_ERROR_NONE;
4399 camera_cli_s *pc = (camera_cli_s *)camera;
4400 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4402 if (pc->cb_info == NULL) {
4403 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4404 return CAMERA_ERROR_INVALID_PARAMETER;
4406 sock_fd = pc->cb_info->fd;
4407 int set_iso = (int)iso;
4408 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4409 muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_iso);
4410 LOGD("ret : 0x%x", ret);
4415 int camera_attr_set_brightness(camera_h camera, int level)
4417 if (camera == NULL) {
4418 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4419 return CAMERA_ERROR_INVALID_PARAMETER;
4421 int ret = CAMERA_ERROR_NONE;
4423 camera_cli_s *pc = (camera_cli_s *)camera;
4424 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4426 if (pc->cb_info == NULL) {
4427 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4428 return CAMERA_ERROR_INVALID_PARAMETER;
4430 sock_fd = pc->cb_info->fd;
4432 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4433 muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, level);
4434 LOGD("ret : 0x%x", ret);
4439 int camera_attr_set_contrast(camera_h camera, int level)
4441 if (camera == NULL) {
4442 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4443 return CAMERA_ERROR_INVALID_PARAMETER;
4445 int ret = CAMERA_ERROR_NONE;
4447 camera_cli_s *pc = (camera_cli_s *)camera;
4448 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4450 if (pc->cb_info == NULL) {
4451 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4452 return CAMERA_ERROR_INVALID_PARAMETER;
4454 sock_fd = pc->cb_info->fd;
4456 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4457 muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, level);
4458 LOGD("ret : 0x%x", ret);
4463 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4465 if (camera == NULL) {
4466 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4467 return CAMERA_ERROR_INVALID_PARAMETER;
4470 if (wb < CAMERA_ATTR_WHITE_BALANCE_NONE || wb > CAMERA_ATTR_WHITE_BALANCE_CUSTOM) {
4471 LOGE("invalid white balance %d", wb);
4472 return CAMERA_ERROR_INVALID_PARAMETER;
4475 int ret = CAMERA_ERROR_NONE;
4477 camera_cli_s *pc = (camera_cli_s *)camera;
4478 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4480 if (pc->cb_info == NULL) {
4481 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4482 return CAMERA_ERROR_INVALID_PARAMETER;
4484 sock_fd = pc->cb_info->fd;
4485 int set_whitebalance = (int)wb;
4486 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4487 muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_whitebalance);
4488 LOGD("ret : 0x%x", ret);
4493 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4495 if (camera == NULL) {
4496 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4497 return CAMERA_ERROR_INVALID_PARAMETER;
4499 int ret = CAMERA_ERROR_NONE;
4501 camera_cli_s *pc = (camera_cli_s *)camera;
4502 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4504 if (pc->cb_info == NULL) {
4505 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4506 return CAMERA_ERROR_INVALID_PARAMETER;
4508 sock_fd = pc->cb_info->fd;
4509 int set_effect = (int)effect;
4510 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4511 muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_effect);
4512 LOGD("ret : 0x%x", ret);
4517 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4519 if (camera == NULL) {
4520 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4521 return CAMERA_ERROR_INVALID_PARAMETER;
4523 int ret = CAMERA_ERROR_NONE;
4525 camera_cli_s *pc = (camera_cli_s *)camera;
4526 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4528 if (pc->cb_info == NULL) {
4529 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4530 return CAMERA_ERROR_INVALID_PARAMETER;
4532 sock_fd = pc->cb_info->fd;
4533 int set_mode = (int)mode;
4534 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4535 muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
4536 LOGD("ret : 0x%x", ret);
4541 int camera_attr_enable_tag(camera_h camera, bool enable)
4543 if (camera == NULL) {
4544 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4545 return CAMERA_ERROR_INVALID_PARAMETER;
4547 int ret = CAMERA_ERROR_NONE;
4548 camera_cli_s *pc = (camera_cli_s *)camera;
4549 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4551 if (pc->cb_info == NULL) {
4552 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4553 return CAMERA_ERROR_INVALID_PARAMETER;
4555 sock_fd = pc->cb_info->fd;
4556 int set_enable = (int)enable;
4558 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4559 muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable);
4560 LOGD("ret : 0x%x", ret);
4565 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4567 if (camera == NULL) {
4568 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4569 return CAMERA_ERROR_INVALID_PARAMETER;
4571 if (description == NULL) {
4572 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4573 return CAMERA_ERROR_INVALID_PARAMETER;
4575 int ret = CAMERA_ERROR_NONE;
4576 camera_cli_s *pc = (camera_cli_s *)camera;
4577 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4579 if (pc->cb_info == NULL) {
4580 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4581 return CAMERA_ERROR_INVALID_PARAMETER;
4583 sock_fd = pc->cb_info->fd;
4584 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4585 muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, STRING, description);
4586 LOGD("ret : 0x%x", ret);
4591 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4593 if (camera == NULL) {
4594 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4595 return CAMERA_ERROR_INVALID_PARAMETER;
4597 int ret = CAMERA_ERROR_NONE;
4598 camera_cli_s *pc = (camera_cli_s *)camera;
4599 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4601 if (pc->cb_info == NULL) {
4602 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4603 return CAMERA_ERROR_INVALID_PARAMETER;
4605 sock_fd = pc->cb_info->fd;
4606 int set_orientation = (int)orientation;
4608 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4609 muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_orientation);
4610 LOGD("ret : 0x%x", ret);
4615 int camera_attr_set_tag_software(camera_h camera, const char *software)
4617 if (camera == NULL) {
4618 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4619 return CAMERA_ERROR_INVALID_PARAMETER;
4621 if (software == NULL) {
4622 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4623 return CAMERA_ERROR_INVALID_PARAMETER;
4625 int ret = CAMERA_ERROR_NONE;
4626 camera_cli_s *pc = (camera_cli_s *)camera;
4627 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4629 if (pc->cb_info == NULL) {
4630 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4631 return CAMERA_ERROR_INVALID_PARAMETER;
4633 sock_fd = pc->cb_info->fd;
4634 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4635 muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, STRING, software);
4636 LOGD("ret : 0x%x", ret);
4641 int camera_attr_set_geotag(camera_h camera, double latitude , double longitude, double altitude)
4643 if (camera == NULL) {
4644 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4645 return CAMERA_ERROR_INVALID_PARAMETER;
4647 int ret = CAMERA_ERROR_NONE;
4648 camera_cli_s *pc = (camera_cli_s *)camera;
4649 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4651 if (pc->cb_info == NULL) {
4652 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4653 return CAMERA_ERROR_INVALID_PARAMETER;
4655 sock_fd = pc->cb_info->fd;
4656 double set_geotag[3] = { latitude, longitude, altitude };
4658 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4659 muse_camera_msg_send_array(api, sock_fd, pc->cb_info, ret,
4660 set_geotag, sizeof(set_geotag), sizeof(double));
4661 LOGD("ret : 0x%x", ret);
4666 int camera_attr_remove_geotag(camera_h camera)
4668 if (camera == NULL) {
4669 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4670 return CAMERA_ERROR_INVALID_PARAMETER;
4672 int ret = CAMERA_ERROR_NONE;
4673 camera_cli_s *pc = (camera_cli_s *)camera;
4674 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4676 if (pc->cb_info == NULL) {
4677 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4678 return CAMERA_ERROR_INVALID_PARAMETER;
4680 sock_fd = pc->cb_info->fd;
4681 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4682 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4683 LOGD("ret : 0x%x", ret);
4688 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4690 if (camera == NULL) {
4691 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4692 return CAMERA_ERROR_INVALID_PARAMETER;
4694 int ret = CAMERA_ERROR_NONE;
4695 camera_cli_s *pc = (camera_cli_s *)camera;
4696 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
4698 if (pc->cb_info == NULL) {
4699 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4700 return CAMERA_ERROR_INVALID_PARAMETER;
4702 sock_fd = pc->cb_info->fd;
4703 int set_mode = (int)mode;
4705 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4706 muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
4707 LOGD("ret : 0x%x", ret);
4712 int camera_attr_get_zoom(camera_h camera, int *zoom)
4714 if (camera == NULL || zoom == NULL) {
4715 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4716 return CAMERA_ERROR_INVALID_PARAMETER;
4718 int ret = CAMERA_ERROR_NONE;
4720 camera_cli_s *pc = (camera_cli_s *)camera;
4721 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4724 if (pc->cb_info == NULL) {
4725 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4726 return CAMERA_ERROR_INVALID_PARAMETER;
4728 sock_fd = pc->cb_info->fd;
4730 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4731 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4733 if (ret == CAMERA_ERROR_NONE) {
4734 muse_camera_msg_get(get_zoom, pc->cb_info->recv_msg);
4737 LOGD("ret : 0x%x", ret);
4742 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
4744 if (camera == NULL || min == NULL || max == NULL) {
4745 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4746 return CAMERA_ERROR_INVALID_PARAMETER;
4748 int ret = CAMERA_ERROR_NONE;
4749 camera_cli_s *pc = (camera_cli_s *)camera;
4751 if (pc->cb_info == NULL) {
4752 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4753 return CAMERA_ERROR_INVALID_PARAMETER;
4755 sock_fd = pc->cb_info->fd;
4756 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
4760 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4761 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4763 if (ret == CAMERA_ERROR_NONE) {
4764 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
4765 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
4769 LOGD("ret : 0x%x", ret);
4774 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
4776 if (camera == NULL || mode == NULL) {
4777 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4778 return CAMERA_ERROR_INVALID_PARAMETER;
4780 int ret = CAMERA_ERROR_NONE;
4781 camera_cli_s *pc = (camera_cli_s *)camera;
4783 if (pc->cb_info == NULL) {
4784 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4785 return CAMERA_ERROR_INVALID_PARAMETER;
4787 sock_fd = pc->cb_info->fd;
4788 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
4791 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4792 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4794 if (ret == CAMERA_ERROR_NONE) {
4795 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
4796 *mode = (camera_attr_af_mode_e)get_mode;
4798 LOGD("ret : 0x%x", ret);
4803 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
4805 if (camera == NULL || mode == NULL) {
4806 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4807 return CAMERA_ERROR_INVALID_PARAMETER;
4809 int ret = CAMERA_ERROR_NONE;
4810 camera_cli_s *pc = (camera_cli_s *)camera;
4812 if (pc->cb_info == NULL) {
4813 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4814 return CAMERA_ERROR_INVALID_PARAMETER;
4816 sock_fd = pc->cb_info->fd;
4817 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
4820 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4821 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4823 if (ret == CAMERA_ERROR_NONE) {
4824 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
4825 *mode = (camera_attr_exposure_mode_e)get_mode;
4827 LOGD("ret : 0x%x", ret);
4831 int camera_attr_get_exposure(camera_h camera, int *value)
4833 if (camera == NULL || value == NULL) {
4834 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4835 return CAMERA_ERROR_INVALID_PARAMETER;
4837 int ret = CAMERA_ERROR_NONE;
4838 camera_cli_s *pc = (camera_cli_s *)camera;
4840 if (pc->cb_info == NULL) {
4841 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4842 return CAMERA_ERROR_INVALID_PARAMETER;
4844 sock_fd = pc->cb_info->fd;
4845 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
4848 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4849 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4851 if (ret == CAMERA_ERROR_NONE) {
4852 muse_camera_msg_get(get_value, pc->cb_info->recv_msg);
4855 LOGD("ret : 0x%x", ret);
4860 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
4862 if (camera == NULL || min == NULL || max == NULL) {
4863 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4864 return CAMERA_ERROR_INVALID_PARAMETER;
4866 int ret = CAMERA_ERROR_NONE;
4867 camera_cli_s *pc = (camera_cli_s *)camera;
4869 if (pc->cb_info == NULL) {
4870 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4871 return CAMERA_ERROR_INVALID_PARAMETER;
4873 sock_fd = pc->cb_info->fd;
4874 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
4878 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4879 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4881 if (ret == CAMERA_ERROR_NONE) {
4882 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
4883 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
4887 LOGD("ret : 0x%x", ret);
4892 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
4894 if (camera == NULL || iso == NULL) {
4895 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4896 return CAMERA_ERROR_INVALID_PARAMETER;
4898 int ret = CAMERA_ERROR_NONE;
4899 camera_cli_s *pc = (camera_cli_s *)camera;
4901 if (pc->cb_info == NULL) {
4902 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4903 return CAMERA_ERROR_INVALID_PARAMETER;
4905 sock_fd = pc->cb_info->fd;
4906 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
4909 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4910 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4912 if (ret == CAMERA_ERROR_NONE) {
4913 muse_camera_msg_get(get_iso, pc->cb_info->recv_msg);
4914 *iso = (camera_attr_iso_e)get_iso;
4916 LOGD("ret : 0x%x", ret);
4921 int camera_attr_get_brightness(camera_h camera, int *level)
4923 if (camera == NULL || level == NULL) {
4924 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4925 return CAMERA_ERROR_INVALID_PARAMETER;
4927 int ret = CAMERA_ERROR_NONE;
4928 camera_cli_s *pc = (camera_cli_s *)camera;
4930 if (pc->cb_info == NULL) {
4931 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4932 return CAMERA_ERROR_INVALID_PARAMETER;
4934 sock_fd = pc->cb_info->fd;
4935 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
4938 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4939 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4941 if (ret == CAMERA_ERROR_NONE) {
4942 muse_camera_msg_get(get_level, pc->cb_info->recv_msg);
4945 LOGD("ret : 0x%x", ret);
4950 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
4952 if (camera == NULL || min == NULL || max == NULL) {
4953 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4954 return CAMERA_ERROR_INVALID_PARAMETER;
4956 int ret = CAMERA_ERROR_NONE;
4957 camera_cli_s *pc = (camera_cli_s *)camera;
4959 if (pc->cb_info == NULL) {
4960 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4961 return CAMERA_ERROR_INVALID_PARAMETER;
4963 sock_fd = pc->cb_info->fd;
4964 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
4968 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4969 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4971 if (ret == CAMERA_ERROR_NONE) {
4972 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
4973 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
4977 LOGD("ret : 0x%x", ret);
4982 int camera_attr_get_contrast(camera_h camera, int *level)
4984 if (camera == NULL || level == NULL) {
4985 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4986 return CAMERA_ERROR_INVALID_PARAMETER;
4988 int ret = CAMERA_ERROR_NONE;
4989 camera_cli_s *pc = (camera_cli_s *)camera;
4990 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
4992 if (pc->cb_info == NULL) {
4993 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4994 return CAMERA_ERROR_INVALID_PARAMETER;
4996 sock_fd = pc->cb_info->fd;
4999 LOGD("Enter, remote_handle : %x", pc->remote_handle);
5000 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5002 if (ret == CAMERA_ERROR_NONE) {
5003 muse_camera_msg_get(get_level, pc->cb_info->recv_msg);
5006 LOGD("ret : 0x%x", ret);
5011 int camera_attr_get_contrast_range(camera_h camera, int *min , int *max)
5013 if (camera == NULL || min == NULL || max == NULL) {
5014 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5015 return CAMERA_ERROR_INVALID_PARAMETER;
5017 int ret = CAMERA_ERROR_NONE;
5018 camera_cli_s *pc = (camera_cli_s *)camera;
5019 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5021 if (pc->cb_info == NULL) {
5022 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5023 return CAMERA_ERROR_INVALID_PARAMETER;
5025 sock_fd = pc->cb_info->fd;
5029 LOGD("Enter, remote_handle : %x", pc->remote_handle);
5030 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5032 if (ret == CAMERA_ERROR_NONE) {
5033 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
5034 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
5038 LOGD("ret : 0x%x", ret);
5043 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5045 if (camera == NULL || wb == NULL) {
5046 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5047 return CAMERA_ERROR_INVALID_PARAMETER;
5049 int ret = CAMERA_ERROR_NONE;
5050 camera_cli_s *pc = (camera_cli_s *)camera;
5051 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5053 if (pc->cb_info == NULL) {
5054 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5055 return CAMERA_ERROR_INVALID_PARAMETER;
5057 sock_fd = pc->cb_info->fd;
5060 LOGD("Enter, remote_handle : %x", pc->remote_handle);
5061 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5063 if (ret == CAMERA_ERROR_NONE) {
5064 muse_camera_msg_get(get_wb, pc->cb_info->recv_msg);
5065 *wb = (camera_attr_whitebalance_e)get_wb;
5067 LOGD("ret : 0x%x", ret);
5072 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5074 if (camera == NULL || effect == NULL) {
5075 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5076 return CAMERA_ERROR_INVALID_PARAMETER;
5079 int ret = CAMERA_ERROR_NONE;
5080 camera_cli_s *pc = (camera_cli_s *)camera;
5081 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5083 if (pc->cb_info == NULL) {
5084 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5085 return CAMERA_ERROR_INVALID_PARAMETER;
5087 sock_fd = pc->cb_info->fd;
5090 LOGD("Enter, remote_handle : %x", pc->remote_handle);
5091 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5093 if (ret == CAMERA_ERROR_NONE) {
5094 muse_camera_msg_get(get_effect, pc->cb_info->recv_msg);
5095 *effect = (camera_attr_effect_mode_e)get_effect;
5097 LOGD("ret : 0x%x", ret);
5102 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5104 if (camera == NULL || mode == NULL) {
5105 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5106 return CAMERA_ERROR_INVALID_PARAMETER;
5109 int ret = CAMERA_ERROR_NONE;
5110 camera_cli_s *pc = (camera_cli_s *)camera;
5111 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5113 if (pc->cb_info == NULL) {
5114 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5115 return CAMERA_ERROR_INVALID_PARAMETER;
5117 sock_fd = pc->cb_info->fd;
5120 LOGD("Enter, remote_handle : %x", pc->remote_handle);
5121 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5123 if (ret == CAMERA_ERROR_NONE) {
5124 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
5125 *mode = (camera_attr_scene_mode_e)get_mode;
5127 LOGD("ret : 0x%x", ret);
5132 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5134 if (camera == NULL || enable == NULL) {
5135 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5136 return CAMERA_ERROR_INVALID_PARAMETER;
5139 int ret = CAMERA_ERROR_NONE;
5140 camera_cli_s *pc = (camera_cli_s *)camera;
5141 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5143 if (pc->cb_info == NULL) {
5144 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5145 return CAMERA_ERROR_INVALID_PARAMETER;
5147 sock_fd = pc->cb_info->fd;
5150 LOGD("Enter, remote_handle : %x", pc->remote_handle);
5151 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5153 if (ret == CAMERA_ERROR_NONE) {
5154 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
5155 *enable = (bool)get_enabled;
5157 LOGD("ret : 0x%x", ret);
5162 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5164 if (camera == NULL || description == NULL) {
5165 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5166 return CAMERA_ERROR_INVALID_PARAMETER;
5169 int ret = CAMERA_ERROR_NONE;
5170 camera_cli_s *pc = (camera_cli_s *)camera;
5171 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5173 if (pc->cb_info == NULL) {
5174 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5175 return CAMERA_ERROR_INVALID_PARAMETER;
5177 sock_fd = pc->cb_info->fd;
5178 char get_description[MUSE_CAMERA_MSG_MAX_LENGTH] = {0,};
5180 LOGD("Enter, remote_handle : %x", pc->remote_handle);
5181 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5183 if (ret == CAMERA_ERROR_NONE) {
5184 muse_camera_msg_get_string(get_description, pc->cb_info->recv_msg);
5185 *description = strdup(get_description);
5187 LOGD("ret : 0x%x", ret);
5192 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5194 if (camera == NULL || orientation == NULL) {
5195 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5196 return CAMERA_ERROR_INVALID_PARAMETER;
5199 int ret = CAMERA_ERROR_NONE;
5200 camera_cli_s *pc = (camera_cli_s *)camera;
5201 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5203 if (pc->cb_info == NULL) {
5204 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5205 return CAMERA_ERROR_INVALID_PARAMETER;
5207 sock_fd = pc->cb_info->fd;
5208 int get_orientation;
5210 LOGD("Enter, remote_handle : %x", pc->remote_handle);
5211 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5213 if (ret == CAMERA_ERROR_NONE) {
5214 muse_camera_msg_get(get_orientation, pc->cb_info->recv_msg);
5215 *orientation = (camera_attr_tag_orientation_e)get_orientation;
5216 LOGD("success, orientation : %d", *orientation);
5218 LOGD("ret : 0x%x", ret);
5223 int camera_attr_get_tag_software(camera_h camera, char **software)
5225 if (camera == NULL || software == NULL) {
5226 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5227 return CAMERA_ERROR_INVALID_PARAMETER;
5230 int ret = CAMERA_ERROR_NONE;
5231 camera_cli_s *pc = (camera_cli_s *)camera;
5232 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5234 if (pc->cb_info == NULL) {
5235 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5236 return CAMERA_ERROR_INVALID_PARAMETER;
5238 sock_fd = pc->cb_info->fd;
5239 char get_software[MUSE_CAMERA_MSG_MAX_LENGTH] = {0,};
5241 LOGD("Enter, remote_handle : %x", pc->remote_handle);
5242 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5244 if (ret == CAMERA_ERROR_NONE) {
5245 muse_camera_msg_get_string(get_software, pc->cb_info->recv_msg);
5246 *software = strdup(get_software);
5248 LOGD("ret : 0x%x", ret);
5253 int camera_attr_get_geotag(camera_h camera, double *latitude , double *longitude, double *altitude)
5255 if (camera == NULL || latitude == NULL || longitude == NULL || altitude == NULL) {
5256 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5257 return CAMERA_ERROR_INVALID_PARAMETER;
5260 int ret = CAMERA_ERROR_NONE;
5261 camera_cli_s *pc = (camera_cli_s *)camera;
5262 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5263 double get_geotag[3] = {0,};
5265 if (pc->cb_info == NULL) {
5266 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5267 return CAMERA_ERROR_INVALID_PARAMETER;
5269 sock_fd = pc->cb_info->fd;
5271 LOGD("Enter, remote_handle : %x", pc->remote_handle);
5273 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5275 if (ret == CAMERA_ERROR_NONE) {
5276 muse_camera_msg_get_array(get_geotag, pc->cb_info->recv_msg);
5277 *latitude = get_geotag[0];
5278 *longitude = get_geotag[1];
5279 *altitude = get_geotag[2];
5281 LOGD("ret : 0x%x", ret);
5283 LOGE("Returned value is not valid : 0x%x", ret);
5290 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5292 if (camera == NULL || mode == NULL) {
5293 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5294 return CAMERA_ERROR_INVALID_PARAMETER;
5297 int ret = CAMERA_ERROR_NONE;
5298 camera_cli_s *pc = (camera_cli_s *)camera;
5299 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5301 if (pc->cb_info == NULL) {
5302 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5303 return CAMERA_ERROR_INVALID_PARAMETER;
5305 sock_fd = pc->cb_info->fd;
5308 LOGD("Enter, remote_handle : %x", pc->remote_handle);
5309 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5311 if (ret == CAMERA_ERROR_NONE) {
5312 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
5313 *mode = (camera_attr_flash_mode_e)get_mode;
5315 LOGD("ret : 0x%x", ret);
5320 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5324 int ret = CAMERA_ERROR_NONE;
5325 camera_cli_s *pc = NULL;
5326 int get_flash_state = 0;
5328 /* create muse connection */
5329 muse_camera_api_e api = MUSE_CAMERA_API_GET_FLASH_STATE;
5330 muse_core_api_module_e muse_module = MUSE_CAMERA;
5331 int device_type = (int)device;
5333 if (state == NULL) {
5334 LOGE("invalid pointer for state");
5335 return CAMERA_ERROR_INVALID_PARAMETER;
5338 sock_fd = muse_core_client_new();
5340 LOGE("muse_core_client_new failed - returned fd %d", sock_fd);
5341 ret = CAMERA_ERROR_INVALID_OPERATION;
5345 sndMsg = muse_core_msg_json_factory_new(api,
5346 MUSE_TYPE_INT, "module", muse_module,
5347 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
5350 muse_core_ipc_send_msg(sock_fd, sndMsg);
5351 muse_core_msg_json_factory_free(sndMsg);
5353 pc = g_new0(camera_cli_s, 1);
5355 LOGE("camera_cli_s alloc failed");
5356 ret = CAMERA_ERROR_OUT_OF_MEMORY;
5360 pc->cb_info = _client_callback_new(sock_fd);
5361 if (pc->cb_info == NULL) {
5362 LOGE("cb_info alloc failed");
5363 ret = CAMERA_ERROR_OUT_OF_MEMORY;
5367 ret = _client_wait_for_cb_return(api, pc->cb_info, CALLBACK_TIME_OUT);
5369 if (ret == CAMERA_ERROR_NONE) {
5370 muse_camera_msg_get(get_flash_state, pc->cb_info->recv_msg);
5371 *state = (camera_flash_state_e)get_flash_state;
5374 LOGD("Flash state : %d\n", *state);
5377 /* release resources */
5379 g_atomic_int_set(&pc->cb_info->msg_recv_running, 0);
5380 g_atomic_int_set(&pc->cb_info->msg_handler_running, 0);
5381 _client_callback_destroy(pc->cb_info);
5391 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5393 if (camera == NULL || foreach_cb == NULL) {
5394 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5395 return CAMERA_ERROR_INVALID_PARAMETER;
5397 int ret = CAMERA_ERROR_NONE;
5399 camera_cli_s *pc = (camera_cli_s *)camera;
5400 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5402 LOGD("Enter, handle :%x", pc->remote_handle);
5405 if (pc->cb_info == NULL) {
5406 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5407 return CAMERA_ERROR_INVALID_PARAMETER;
5409 sock_fd = pc->cb_info->fd;
5410 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5411 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5413 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5414 LOGD("ret : 0x%x", ret);
5419 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb , void *user_data)
5421 if (camera == NULL || foreach_cb == NULL) {
5422 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5423 return CAMERA_ERROR_INVALID_PARAMETER;
5425 int ret = CAMERA_ERROR_NONE;
5427 camera_cli_s *pc = (camera_cli_s *)camera;
5428 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5430 LOGD("Enter, handle :%x", pc->remote_handle);
5433 if (pc->cb_info == NULL) {
5434 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5435 return CAMERA_ERROR_INVALID_PARAMETER;
5437 sock_fd = pc->cb_info->fd;
5438 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5439 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5441 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5442 LOGD("ret : 0x%x", ret);
5447 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5449 if (camera == NULL || foreach_cb == NULL) {
5450 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5451 return CAMERA_ERROR_INVALID_PARAMETER;
5453 int ret = CAMERA_ERROR_NONE;
5455 camera_cli_s *pc = (camera_cli_s *)camera;
5456 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5458 LOGD("Enter, handle :%x", pc->remote_handle);
5461 if (pc->cb_info == NULL) {
5462 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5463 return CAMERA_ERROR_INVALID_PARAMETER;
5465 sock_fd = pc->cb_info->fd;
5466 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5467 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5469 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5470 LOGD("ret : 0x%x", ret);
5475 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb , void *user_data)
5477 if (camera == NULL || foreach_cb == NULL) {
5478 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5479 return CAMERA_ERROR_INVALID_PARAMETER;
5481 int ret = CAMERA_ERROR_NONE;
5483 camera_cli_s *pc = (camera_cli_s *)camera;
5484 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5486 LOGD("Enter, handle :%x", pc->remote_handle);
5489 if (pc->cb_info == NULL) {
5490 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5491 return CAMERA_ERROR_INVALID_PARAMETER;
5493 sock_fd = pc->cb_info->fd;
5494 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5495 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5497 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5498 LOGD("ret : 0x%x", ret);
5503 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb , void *user_data)
5505 if (camera == NULL || foreach_cb == NULL) {
5506 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5507 return CAMERA_ERROR_INVALID_PARAMETER;
5509 int ret = CAMERA_ERROR_NONE;
5511 camera_cli_s *pc = (camera_cli_s *)camera;
5512 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5514 LOGD("Enter, handle :%x", pc->remote_handle);
5517 if (pc->cb_info == NULL) {
5518 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5519 return CAMERA_ERROR_INVALID_PARAMETER;
5521 sock_fd = pc->cb_info->fd;
5522 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5523 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5525 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5526 LOGD("ret : 0x%x", ret);
5531 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb , void *user_data)
5533 if (camera == NULL || foreach_cb == NULL) {
5534 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5535 return CAMERA_ERROR_INVALID_PARAMETER;
5537 int ret = CAMERA_ERROR_NONE;
5539 camera_cli_s *pc = (camera_cli_s *)camera;
5540 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5542 LOGD("Enter, handle :%x", pc->remote_handle);
5545 if (pc->cb_info == NULL) {
5546 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5547 return CAMERA_ERROR_INVALID_PARAMETER;
5549 sock_fd = pc->cb_info->fd;
5550 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5551 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5553 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5554 LOGD("ret : 0x%x", ret);
5559 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb , void *user_data)
5561 if (camera == NULL || foreach_cb == NULL) {
5562 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5563 return CAMERA_ERROR_INVALID_PARAMETER;
5565 int ret = CAMERA_ERROR_NONE;
5567 camera_cli_s *pc = (camera_cli_s *)camera;
5568 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5570 LOGD("Enter, handle :%x", pc->remote_handle);
5573 if (pc->cb_info == NULL) {
5574 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5575 return CAMERA_ERROR_INVALID_PARAMETER;
5577 sock_fd = pc->cb_info->fd;
5578 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5579 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5581 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5582 LOGD("ret : 0x%x", ret);
5587 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb , void *user_data)
5589 if (camera == NULL || foreach_cb == NULL) {
5590 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5591 return CAMERA_ERROR_INVALID_PARAMETER;
5593 int ret = CAMERA_ERROR_NONE;
5595 camera_cli_s *pc = (camera_cli_s *)camera;
5596 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5598 if (pc->cb_info == NULL) {
5599 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5600 return CAMERA_ERROR_INVALID_PARAMETER;
5602 sock_fd = pc->cb_info->fd;
5603 LOGD("Enter, handle :%x", pc->remote_handle);
5604 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5605 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5607 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5608 LOGD("Enter, handle :%x", pc->remote_handle);
5612 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)
5614 if (camera == NULL || foreach_cb == NULL) {
5615 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5616 return CAMERA_ERROR_INVALID_PARAMETER;
5618 int ret = CAMERA_ERROR_NONE;
5620 camera_cli_s *pc = (camera_cli_s *)camera;
5621 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5623 if (pc->cb_info == NULL) {
5624 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5625 return CAMERA_ERROR_INVALID_PARAMETER;
5627 sock_fd = pc->cb_info->fd;
5628 LOGD("Enter, handle :%x", pc->remote_handle);
5629 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5630 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5632 muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, width, INT, height);
5633 LOGD("ret : 0x%x", ret);
5637 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5639 if (camera == NULL || foreach_cb == NULL) {
5640 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5641 return CAMERA_ERROR_INVALID_PARAMETER;
5643 int ret = CAMERA_ERROR_NONE;
5645 camera_cli_s *pc = (camera_cli_s *)camera;
5646 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5648 if (pc->cb_info == NULL) {
5649 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5650 return CAMERA_ERROR_INVALID_PARAMETER;
5652 sock_fd = pc->cb_info->fd;
5653 LOGD("Enter, handle :%x", pc->remote_handle);
5654 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5655 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5657 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5658 LOGD("ret : 0x%x", ret);
5663 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5665 if (camera == NULL || foreach_cb == NULL) {
5666 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5667 return CAMERA_ERROR_INVALID_PARAMETER;
5669 int ret = CAMERA_ERROR_NONE;
5671 camera_cli_s *pc = (camera_cli_s *)camera;
5672 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5674 if (pc->cb_info == NULL) {
5675 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5676 return CAMERA_ERROR_INVALID_PARAMETER;
5678 sock_fd = pc->cb_info->fd;
5679 LOGD("Enter, handle :%x", pc->remote_handle);
5680 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5681 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5683 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5684 LOGD("ret : 0x%x", ret);
5689 int camera_attr_set_stream_rotation(camera_h camera , camera_rotation_e rotation)
5691 if (camera == NULL) {
5692 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5693 return CAMERA_ERROR_INVALID_PARAMETER;
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_STREAM_ROTATION;
5700 if (pc->cb_info == NULL) {
5701 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5702 return CAMERA_ERROR_INVALID_PARAMETER;
5704 sock_fd = pc->cb_info->fd;
5705 int set_rotation = (int)rotation;
5707 LOGD("Enter, remote_handle : %x", pc->remote_handle);
5708 muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_rotation);
5709 LOGD("ret : 0x%x", ret);
5714 int camera_attr_get_stream_rotation(camera_h camera , camera_rotation_e *rotation)
5716 if (camera == NULL || rotation == NULL) {
5717 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5718 return CAMERA_ERROR_INVALID_PARAMETER;
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_STREAM_ROTATION;
5725 if (pc->cb_info == NULL) {
5726 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5727 return CAMERA_ERROR_INVALID_PARAMETER;
5729 sock_fd = pc->cb_info->fd;
5732 LOGD("Enter, remote_handle : %x", pc->remote_handle);
5733 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5735 if (ret == CAMERA_ERROR_NONE) {
5736 muse_camera_msg_get(get_rotation, pc->cb_info->recv_msg);
5737 *rotation = (camera_rotation_e)get_rotation;
5739 LOGD("ret : 0x%x", ret);
5744 int camera_attr_set_stream_flip(camera_h camera , camera_flip_e flip)
5746 if (camera == NULL) {
5747 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5748 return CAMERA_ERROR_INVALID_PARAMETER;
5751 int ret = CAMERA_ERROR_NONE;
5752 camera_cli_s *pc = (camera_cli_s *)camera;
5753 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5755 if (pc->cb_info == NULL) {
5756 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5757 return CAMERA_ERROR_INVALID_PARAMETER;
5759 sock_fd = pc->cb_info->fd;
5760 int set_flip = (int)flip;
5762 LOGD("Enter, remote_handle : %x", pc->remote_handle);
5763 muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_flip);
5764 LOGD("ret : 0x%x", ret);
5769 int camera_attr_get_stream_flip(camera_h camera , camera_flip_e *flip)
5771 if (camera == NULL || flip == NULL) {
5772 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5773 return CAMERA_ERROR_INVALID_PARAMETER;
5776 int ret = CAMERA_ERROR_NONE;
5777 camera_cli_s *pc = (camera_cli_s *)camera;
5778 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5780 if (pc->cb_info == NULL) {
5781 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5782 return CAMERA_ERROR_INVALID_PARAMETER;
5784 sock_fd = pc->cb_info->fd;
5787 LOGD("Enter, remote_handle : %x", pc->remote_handle);
5788 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5790 if (ret == CAMERA_ERROR_NONE) {
5791 muse_camera_msg_get(get_flip, pc->cb_info->recv_msg);
5792 *flip = (camera_flip_e)get_flip;
5794 LOGD("ret : 0x%x", ret);
5798 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5800 if (camera == NULL) {
5801 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5802 return CAMERA_ERROR_INVALID_PARAMETER;
5805 int ret = CAMERA_ERROR_NONE;
5806 camera_cli_s *pc = (camera_cli_s *)camera;
5807 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5809 if (pc->cb_info == NULL) {
5810 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5811 return CAMERA_ERROR_INVALID_PARAMETER;
5813 sock_fd = pc->cb_info->fd;
5814 int set_mode = (int)mode;
5816 LOGD("Enter, remote_handle : %x", pc->remote_handle);
5817 muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
5818 LOGD("ret : 0x%x", ret);
5823 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5825 if (camera == NULL) {
5826 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
5827 return CAMERA_ERROR_INVALID_PARAMETER;
5830 LOGE("INVALID_PARAMETER(0x%08x) - mode", CAMERA_ERROR_INVALID_PARAMETER);
5831 return CAMERA_ERROR_INVALID_PARAMETER;
5833 int ret = CAMERA_ERROR_NONE;
5834 camera_cli_s *pc = (camera_cli_s *)camera;
5835 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5837 if (pc->cb_info == NULL) {
5838 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5839 return CAMERA_ERROR_INVALID_PARAMETER;
5841 sock_fd = pc->cb_info->fd;
5844 LOGD("Enter, remote_handle : %x", pc->remote_handle);
5845 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5847 if (ret == CAMERA_ERROR_NONE) {
5848 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
5849 *mode = (camera_attr_hdr_mode_e)get_mode;
5851 LOGD("ret : 0x%x", ret);
5856 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5858 if (camera == NULL) {
5859 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5863 int ret = CAMERA_ERROR_NONE;
5864 camera_cli_s *pc = (camera_cli_s *)camera;
5865 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
5867 if (pc->cb_info == NULL) {
5868 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5869 return CAMERA_ERROR_INVALID_PARAMETER;
5871 sock_fd = pc->cb_info->fd;
5872 LOGD("Enter, remote_handle : %x", pc->remote_handle);
5873 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5874 LOGD("ret : 0x%x", ret);
5879 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5881 int ret = CAMERA_ERROR_NONE;
5882 camera_cli_s *pc = (camera_cli_s *)camera;
5883 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5886 if (camera == NULL) {
5887 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
5888 return CAMERA_ERROR_INVALID_PARAMETER;
5891 if (pc->cb_info == NULL) {
5892 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5893 return CAMERA_ERROR_INVALID_PARAMETER;
5896 sock_fd = pc->cb_info->fd;
5898 LOGD("Enter, handle :%x", pc->remote_handle);
5900 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5902 if (ret == CAMERA_ERROR_NONE) {
5903 if (callback == NULL) {
5904 LOGE("INVALID_PARAMETER(0x%08x) - callback", CAMERA_ERROR_INVALID_PARAMETER);
5905 return CAMERA_ERROR_INVALID_PARAMETER;
5908 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5909 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5912 LOGD("ret : 0x%x", ret);
5918 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5920 if (camera == NULL) {
5921 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5922 return CAMERA_ERROR_INVALID_PARAMETER;
5925 int ret = CAMERA_ERROR_NONE;
5927 camera_cli_s *pc = (camera_cli_s *)camera;
5928 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5930 if (pc->cb_info == NULL) {
5931 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5932 return CAMERA_ERROR_INVALID_PARAMETER;
5934 sock_fd = pc->cb_info->fd;
5935 LOGD("Enter, handle :%x", pc->remote_handle);
5937 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)NULL;
5938 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)NULL;
5940 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5941 LOGD("ret : 0x%x", ret);
5946 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
5948 if (camera == NULL) {
5949 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5950 return CAMERA_ERROR_INVALID_PARAMETER;
5953 int ret = CAMERA_ERROR_NONE;
5954 camera_cli_s *pc = (camera_cli_s *)camera;
5955 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
5957 if (pc->cb_info == NULL) {
5958 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5959 return CAMERA_ERROR_INVALID_PARAMETER;
5961 sock_fd = pc->cb_info->fd;
5962 int set_enable = (int)enable;
5964 LOGD("Enter, remote_handle : %x", pc->remote_handle);
5965 muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable);
5966 LOGD("ret : 0x%x", ret);
5971 int camera_attr_is_enabled_anti_shake(camera_h camera , bool *enabled)
5973 if (camera == NULL) {
5974 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
5975 return CAMERA_ERROR_INVALID_PARAMETER;
5977 if (enabled == NULL) {
5978 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
5979 return CAMERA_ERROR_INVALID_PARAMETER;
5981 int ret = CAMERA_ERROR_NONE;
5982 camera_cli_s *pc = (camera_cli_s *)camera;
5983 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
5985 if (pc->cb_info == NULL) {
5986 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5987 return CAMERA_ERROR_INVALID_PARAMETER;
5989 sock_fd = pc->cb_info->fd;
5992 LOGD("Enter, remote_handle : %x", pc->remote_handle);
5993 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5995 if (ret == CAMERA_ERROR_NONE) {
5996 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
5997 *enabled = (bool)get_enabled;
5999 LOGD("ret : 0x%x", ret);
6004 bool camera_attr_is_supported_anti_shake(camera_h camera)
6007 if (camera == NULL) {
6008 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6012 int ret = CAMERA_ERROR_NONE;
6013 camera_cli_s *pc = (camera_cli_s *)camera;
6014 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6016 if (pc->cb_info == NULL) {
6017 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6018 return CAMERA_ERROR_INVALID_PARAMETER;
6020 sock_fd = pc->cb_info->fd;
6021 LOGD("Enter, remote_handle : %x", pc->remote_handle);
6022 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
6023 LOGD("ret : 0x%x", ret);
6028 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6030 if (camera == NULL) {
6031 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6032 return CAMERA_ERROR_INVALID_PARAMETER;
6035 int ret = CAMERA_ERROR_NONE;
6036 camera_cli_s *pc = (camera_cli_s *)camera;
6037 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6039 if (pc->cb_info == NULL) {
6040 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6041 return CAMERA_ERROR_INVALID_PARAMETER;
6043 sock_fd = pc->cb_info->fd;
6044 int set_enable = (int)enable;
6046 LOGD("Enter, remote_handle : %x", pc->remote_handle);
6047 muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable);
6048 LOGD("ret : 0x%x", ret);
6053 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6055 if (camera == NULL) {
6056 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
6057 return CAMERA_ERROR_INVALID_PARAMETER;
6059 if (enabled == NULL) {
6060 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
6061 return CAMERA_ERROR_INVALID_PARAMETER;
6063 int ret = CAMERA_ERROR_NONE;
6064 camera_cli_s *pc = (camera_cli_s *)camera;
6065 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6067 if (pc->cb_info == NULL) {
6068 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6069 return CAMERA_ERROR_INVALID_PARAMETER;
6071 sock_fd = pc->cb_info->fd;
6074 LOGD("Enter, remote_handle : %x", pc->remote_handle);
6075 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
6077 if (ret == CAMERA_ERROR_NONE) {
6078 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
6079 *enabled = (bool)get_enabled;
6081 LOGD("ret : 0x%x", ret);
6086 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6088 if (camera == NULL) {
6089 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6093 int ret = CAMERA_ERROR_NONE;
6094 camera_cli_s *pc = (camera_cli_s *)camera;
6095 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6097 if (pc->cb_info == NULL) {
6098 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6099 return CAMERA_ERROR_INVALID_PARAMETER;
6101 sock_fd = pc->cb_info->fd;
6102 LOGD("Enter, remote_handle : %x", pc->remote_handle);
6103 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
6104 LOGD("ret : 0x%x", ret);
6109 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6111 if (camera == NULL) {
6112 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6113 return CAMERA_ERROR_INVALID_PARAMETER;
6116 int ret = CAMERA_ERROR_NONE;
6117 camera_cli_s *pc = (camera_cli_s *)camera;
6118 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6120 if (pc->cb_info == NULL) {
6121 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6122 return CAMERA_ERROR_INVALID_PARAMETER;
6124 sock_fd = pc->cb_info->fd;
6125 int set_enable = (int)enable;
6127 LOGD("Enter, remote_handle : %x", pc->remote_handle);
6128 muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable);
6129 LOGD("ret : 0x%x", ret);
6134 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6136 if (camera == NULL) {
6137 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
6138 return CAMERA_ERROR_INVALID_PARAMETER;
6140 if (enabled == NULL) {
6141 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
6142 return CAMERA_ERROR_INVALID_PARAMETER;
6144 int ret = CAMERA_ERROR_NONE;
6145 camera_cli_s *pc = (camera_cli_s *)camera;
6146 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6148 if (pc->cb_info == NULL) {
6149 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6150 return CAMERA_ERROR_INVALID_PARAMETER;
6152 sock_fd = pc->cb_info->fd;
6155 LOGD("Enter, remote_handle : %x", pc->remote_handle);
6156 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
6158 if (ret == CAMERA_ERROR_NONE) {
6159 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
6160 *enabled = (bool)get_enabled;
6162 LOGD("ret : 0x%x", ret);
6167 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6169 if (camera == NULL) {
6170 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6174 int ret = CAMERA_ERROR_NONE;
6175 camera_cli_s *pc = (camera_cli_s *)camera;
6176 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6178 if (pc->cb_info == NULL) {
6179 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6180 return CAMERA_ERROR_INVALID_PARAMETER;
6182 sock_fd = pc->cb_info->fd;
6183 LOGD("Enter, remote_handle : %x", pc->remote_handle);
6184 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
6185 LOGD("ret : 0x%x", ret);
6190 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6192 if (camera == NULL) {
6193 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6194 return CAMERA_ERROR_INVALID_PARAMETER;
6197 int ret = CAMERA_ERROR_NONE;
6198 camera_cli_s *pc = (camera_cli_s *)camera;
6199 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6201 if (pc->cb_info == NULL) {
6202 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6203 return CAMERA_ERROR_INVALID_PARAMETER;
6205 sock_fd = pc->cb_info->fd;
6206 int set_disable = (int)disable;
6208 LOGD("Enter, remote_handle : %x", pc->remote_handle);
6209 muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_disable);
6210 LOGD("ret : 0x%x", ret);
6215 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6217 if (camera == NULL) {
6218 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6219 return CAMERA_ERROR_INVALID_PARAMETER;
6222 camera_cli_s *pc = (camera_cli_s *)camera;
6223 if (pc->cb_info == NULL) {
6224 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6225 return CAMERA_ERROR_INVALID_PARAMETER;
6228 int ret = CAMERA_ERROR_NONE;
6229 int sock_fd = pc->cb_info->fd;
6230 int set_move_type = (int)move_type;
6231 int set_pan_step = pan_step;
6232 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6234 LOGD("Enter, remote_handle : %x", pc->remote_handle);
6235 muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, set_move_type, INT, set_pan_step);
6236 LOGD("ret : 0x%x", ret);
6241 int camera_attr_get_pan(camera_h camera, int *pan_step)
6243 if (camera == NULL || pan_step == NULL) {
6244 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6245 return CAMERA_ERROR_INVALID_PARAMETER;
6248 camera_cli_s *pc = (camera_cli_s *)camera;
6249 if (pc->cb_info == NULL) {
6250 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6251 return CAMERA_ERROR_INVALID_PARAMETER;
6254 int ret = CAMERA_ERROR_NONE;
6255 int sock_fd = pc->cb_info->fd;
6257 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6259 LOGD("Enter, remote_handle : %x", pc->remote_handle);
6260 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
6262 if (ret == CAMERA_ERROR_NONE) {
6263 muse_camera_msg_get(get_pan_step, pc->cb_info->recv_msg);
6264 *pan_step = get_pan_step;
6266 LOGD("ret : 0x%x", ret);
6271 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6273 if (camera == NULL || min == NULL || max == NULL) {
6274 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6275 return CAMERA_ERROR_INVALID_PARAMETER;
6278 camera_cli_s *pc = (camera_cli_s *)camera;
6279 if (pc->cb_info == NULL) {
6280 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6281 return CAMERA_ERROR_INVALID_PARAMETER;
6284 int ret = CAMERA_ERROR_NONE;
6285 int sock_fd = pc->cb_info->fd;
6288 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6290 LOGD("Enter, remote_handle : %x", pc->remote_handle);
6291 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
6293 if (ret == CAMERA_ERROR_NONE) {
6294 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
6295 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
6299 LOGD("ret : 0x%x", ret);
6304 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6306 if (camera == NULL) {
6307 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6308 return CAMERA_ERROR_INVALID_PARAMETER;
6311 camera_cli_s *pc = (camera_cli_s *)camera;
6312 if (pc->cb_info == NULL) {
6313 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6314 return CAMERA_ERROR_INVALID_PARAMETER;
6317 int ret = CAMERA_ERROR_NONE;
6318 int sock_fd = pc->cb_info->fd;
6319 int set_move_type = (int)move_type;
6320 int set_tilt_step = tilt_step;
6321 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6323 LOGD("Enter, remote_handle : %x", pc->remote_handle);
6324 muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, set_move_type, INT, set_tilt_step);
6325 LOGD("ret : 0x%x", ret);
6330 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6332 if (camera == NULL || tilt_step == NULL) {
6333 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6334 return CAMERA_ERROR_INVALID_PARAMETER;
6337 camera_cli_s *pc = (camera_cli_s *)camera;
6338 if (pc->cb_info == NULL) {
6339 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6340 return CAMERA_ERROR_INVALID_PARAMETER;
6343 int ret = CAMERA_ERROR_NONE;
6344 int sock_fd = pc->cb_info->fd;
6346 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6348 LOGD("Enter, remote_handle : %x", pc->remote_handle);
6349 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
6351 if (ret == CAMERA_ERROR_NONE) {
6352 muse_camera_msg_get(get_tilt_step, pc->cb_info->recv_msg);
6353 *tilt_step = get_tilt_step;
6355 LOGD("ret : 0x%x", ret);
6360 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6362 if (camera == NULL || min == NULL || max == NULL) {
6363 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6364 return CAMERA_ERROR_INVALID_PARAMETER;
6367 camera_cli_s *pc = (camera_cli_s *)camera;
6368 if (pc->cb_info == NULL) {
6369 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6370 return CAMERA_ERROR_INVALID_PARAMETER;
6373 int ret = CAMERA_ERROR_NONE;
6374 int sock_fd = pc->cb_info->fd;
6377 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6379 LOGD("Enter, remote_handle : %x", pc->remote_handle);
6380 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
6382 if (ret == CAMERA_ERROR_NONE) {
6383 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
6384 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
6388 LOGD("ret : 0x%x", ret);
6393 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6395 if (camera == NULL) {
6396 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6397 return CAMERA_ERROR_INVALID_PARAMETER;
6400 camera_cli_s *pc = (camera_cli_s *)camera;
6401 if (pc->cb_info == NULL) {
6402 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6403 return CAMERA_ERROR_INVALID_PARAMETER;
6406 int ret = CAMERA_ERROR_NONE;
6407 int sock_fd = pc->cb_info->fd;
6408 int set_ptz_type = (int)ptz_type;
6409 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6411 LOGD("Enter, remote_handle : %x", pc->remote_handle);
6412 muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_ptz_type);
6413 LOGD("ret : 0x%x", ret);
6418 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6420 if (camera == NULL || foreach_cb == NULL) {
6421 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6422 return CAMERA_ERROR_INVALID_PARAMETER;
6424 int ret = CAMERA_ERROR_NONE;
6426 camera_cli_s *pc = (camera_cli_s *)camera;
6427 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6429 if (pc->cb_info == NULL) {
6430 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6431 return CAMERA_ERROR_INVALID_PARAMETER;
6433 sock_fd = pc->cb_info->fd;
6434 LOGD("Enter, handle :%x", pc->remote_handle);
6435 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6436 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6438 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
6439 LOGD("ret : 0x%x", ret);
6444 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6446 if (camera == NULL) {
6447 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6448 return CAMERA_ERROR_INVALID_PARAMETER;
6451 camera_cli_s *pc = (camera_cli_s *)camera;
6452 if (pc->cb_info == NULL) {
6453 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6454 return CAMERA_ERROR_INVALID_PARAMETER;
6457 int ret = CAMERA_ERROR_NONE;
6458 int sock_fd = pc->cb_info->fd;
6459 int set_display_roi_area[4] = {x, y, width, height};
6460 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6462 LOGD("Enter, remote_handle : %x", pc->remote_handle);
6464 #ifdef TIZEN_FEATURE_EVAS_RENDERER
6465 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6466 g_mutex_lock(&pc->cb_info->evas_mutex);
6468 ret = mm_evas_renderer_set_roi_area(pc->cb_info->evas_info, x, y, width, height);
6470 g_mutex_unlock(&pc->cb_info->evas_mutex);
6472 if (ret != MM_ERROR_NONE) {
6473 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6474 return CAMERA_ERROR_INVALID_OPERATION;
6477 #endif /* TIZEN_FEATURE_EVAS_RENDERER */
6479 muse_camera_msg_send_array(api, sock_fd, pc->cb_info, ret,
6480 set_display_roi_area, sizeof(set_display_roi_area), sizeof(int));
6482 LOGD("ret : 0x%x", ret);
6488 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6490 if (camera == NULL || x == NULL || y == NULL || width == NULL || height == NULL) {
6491 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6492 return CAMERA_ERROR_INVALID_PARAMETER;
6495 camera_cli_s *pc = (camera_cli_s *)camera;
6496 if (pc->cb_info == NULL) {
6497 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6498 return CAMERA_ERROR_INVALID_PARAMETER;
6501 int ret = CAMERA_ERROR_NONE;
6502 int sock_fd = pc->cb_info->fd;
6503 int get_display_roi_area[4] = {0,};
6504 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6506 LOGD("Enter, remote_handle : %x", pc->remote_handle);
6508 muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
6510 if (ret == CAMERA_ERROR_NONE) {
6511 muse_camera_msg_get_array(get_display_roi_area, pc->cb_info->recv_msg);
6513 *x = get_display_roi_area[0];
6514 *y = get_display_roi_area[1];
6515 *width = get_display_roi_area[2];
6516 *height = get_display_roi_area[3];
6518 LOGD("ret : 0x%x", ret);
6520 LOGE("Returned value is not valid : 0x%x", ret);