2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
24 #include <muse_camera.h>
25 #include <muse_camera_msg.h>
26 #include <camera_private.h>
27 #include <muse_core.h>
28 #include <muse_client.h>
30 #include <tbm_surface_internal.h>
36 #define LOG_TAG "TIZEN_N_CAMERA"
38 /* for device changed callback */
39 static GMutex g_cam_dev_state_changed_cb_lock;
40 static GList *g_cam_dev_state_changed_cb_list;
41 static int g_cam_dev_state_changed_cb_id;
42 static GDBusConnection *g_cam_dev_state_changed_cb_conn;
43 static guint g_cam_dev_state_changed_cb_subscribe_id;
45 static void _camera_msg_send(int api, camera_cb_info_s *cb_info,
46 int *ret, int timeout);
47 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
48 int *ret, camera_msg_param *param, int timeout);
49 static void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
50 int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout);
51 static int _camera_import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle);
52 static void _camera_release_imported_bo(tbm_bo *bo);
53 static void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_key,
54 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame);
55 static int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
56 camera_media_packet_data *mp_data, media_packet_h *packet);
57 static int _camera_media_packet_data_create(int tbm_key, int num_buffer_key, tbm_bo bo,
58 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data);
59 static void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info);
62 static void __camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value)
65 api < 0 || api >= MUSE_CAMERA_API_MAX) {
66 LOGE("invalid param %p %d", cb_info, api);
70 g_mutex_lock(&(cb_info->api_mutex[api]));
71 cb_info->api_waiting[api] += value;
72 g_mutex_unlock(&(cb_info->api_mutex[api]));
74 /*LOGD("api %d, value %d, waiting %d",
75 api, value, cb_info->api_waiting[api]);*/
81 static void __camera_device_state_changed_cb(GDBusConnection *connection,
82 const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
83 const gchar *signal_name, GVariant *param, gpointer user_data)
86 camera_device_e device = CAMERA_DEVICE_CAMERA0;
87 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
88 GList *tmp_list = NULL;
89 camera_cb_info *info = NULL;
91 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
93 if (!g_cam_dev_state_changed_cb_list || !param) {
94 LOGW("no callback or NULL param %p", param);
98 /* get device and state */
99 g_variant_get(param, "(i)", &value);
101 device = value >> 16;
102 state = 0x0000ffff & value;
104 LOGD("device %d, state %d", device, state);
106 tmp_list = g_cam_dev_state_changed_cb_list;
109 info = (camera_cb_info *)tmp_list->data;
112 if (info->callback) {
113 LOGD("start id[%d] callback", info->id);
114 ((camera_device_state_changed_cb)info->callback)(device, state, info->user_data);
115 LOGD("returned id[%d] callback", info->id);
117 LOGW("NULL callback for id %d", info->id);
121 tmp_list = tmp_list->next;
125 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
131 static void __camera_event_handler_preview(camera_cb_info_s *cb_info, char *recv_msg)
135 int num_buffer_key = 0;
136 int buffer_key[BUFFER_MAX_PLANE_NUM] = {0, };
139 unsigned char *buf_pos = NULL;
140 camera_msg_param param;
143 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
144 tbm_bo_handle bo_handle = {.ptr = NULL};
145 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
146 tbm_bo data_bo = NULL;
147 tbm_bo_handle data_bo_handle = {.ptr = NULL};
149 camera_preview_data_s frame;
150 camera_stream_data_s *stream = NULL;
151 camera_media_packet_data *mp_data = NULL;
152 media_packet_h pkt = NULL;
153 media_packet_h pkt_evas = NULL;
155 if (!cb_info || !recv_msg) {
156 LOGE("invalid param %p %p", cb_info, recv_msg);
160 muse_camera_msg_get(tbm_key, recv_msg);
161 muse_camera_msg_get(num_buffer_key, recv_msg);
162 muse_camera_msg_get_array(buffer_key, recv_msg);
163 muse_camera_msg_get(data_key, recv_msg);
165 memset(&frame, 0x0, sizeof(camera_preview_data_s));
168 LOGE("invalid key %d", tbm_key);
172 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
174 if (num_buffer_key < 0 || num_buffer_key > BUFFER_MAX_PLANE_NUM) {
175 LOGE("invalid num buffer key %d", num_buffer_key);
176 goto _PREVIEW_CB_HANDLER_DONE;
180 /* import tbm data_bo and get virtual address */
181 if (!_camera_import_tbm_key(cb_info->bufmgr, data_key, &data_bo, &data_bo_handle)) {
182 LOGE("failed to import data key %d", data_key);
183 goto _PREVIEW_CB_HANDLER_DONE;
187 /* import tbm bo and get virtual address */
188 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
189 LOGE("failed to import key %d", tbm_key);
190 goto _PREVIEW_CB_HANDLER_DONE;
193 buf_pos = (unsigned char *)bo_handle.ptr;
195 /* get stream info */
196 stream = (camera_stream_data_s *)buf_pos;
198 for (i = 0 ; i < num_buffer_key ; i++) {
199 /* import buffer bo and get virtual address */
200 if (!_camera_import_tbm_key(cb_info->bufmgr, buffer_key[i], &buffer_bo[i], &buffer_bo_handle[i])) {
201 LOGE("failed to import buffer key %d", buffer_key[i]);
202 goto _PREVIEW_CB_HANDLER_DONE;
206 /* call preview callback */
207 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
208 _camera_preview_frame_create(stream, num_buffer_key, buffer_bo_handle, &data_bo_handle, &frame);
210 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
211 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
214 if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
215 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
217 if (ret == CAMERA_ERROR_NONE) {
218 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt_evas);
219 if (ret != CAMERA_ERROR_NONE) {
220 LOGE("create pkt for evas failed");
221 _camera_media_packet_data_release(mp_data, cb_info);
227 /* call media packet callback */
228 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
229 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
231 if (ret == CAMERA_ERROR_NONE) {
232 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt);
234 if (ret == CAMERA_ERROR_NONE) {
235 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
236 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
238 _camera_media_packet_data_release(mp_data, cb_info);
244 /* call evas renderer */
246 if (cb_info->run_evas_render) {
247 mm_display_interface_evas_render(cb_info->dp_interface, pkt_evas);
249 LOGW("evas renderer is stopped, skip this buffer...");
250 media_packet_destroy(pkt_evas);
255 /* send message for preview callback return */
256 if (!CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS))
257 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info, NULL, 0);
259 _PREVIEW_CB_HANDLER_DONE:
260 if (mp_data == NULL) {
261 /* release imported bo */
262 for (i = 0 ; i < num_buffer_key && i < BUFFER_MAX_PLANE_NUM ; i++)
263 _camera_release_imported_bo(&buffer_bo[i]);
265 /* unmap and unref tbm bo */
266 _camera_release_imported_bo(&data_bo);
267 _camera_release_imported_bo(&bo);
270 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
272 /*LOGD("return buffer Done");*/
279 static void __camera_event_handler_capture(camera_cb_info_s *cb_info, char *recv_msg)
282 int tbm_key_main = 0;
283 int tbm_key_post = 0;
284 int tbm_key_thumb = 0;
285 unsigned char *buf_pos = NULL;
287 camera_msg_param param;
288 camera_image_data_s *rImage = NULL;
289 camera_image_data_s *rPostview = NULL;
290 camera_image_data_s *rThumbnail = NULL;
292 tbm_bo bo_main = NULL;
293 tbm_bo bo_post = NULL;
294 tbm_bo bo_thumb = NULL;
295 tbm_bo_handle bo_main_handle = {.ptr = NULL};
296 tbm_bo_handle bo_post_handle = {.ptr = NULL};
297 tbm_bo_handle bo_thumb_handle = {.ptr = NULL};
299 if (!cb_info || !recv_msg) {
300 LOGE("invalid param %p %p", cb_info, recv_msg);
304 muse_camera_msg_get(tbm_key_main, recv_msg);
305 muse_camera_msg_get(tbm_key_post, recv_msg);
306 muse_camera_msg_get(tbm_key_thumb, recv_msg);
309 LOGD("camera capture callback came in. tbm_key_main %d, tbm_key_post %d, tbm_key_thumb %d",
310 tbm_key_main, tbm_key_post, tbm_key_thumb);
313 if (tbm_key_main <= 0) {
314 LOGE("invalid key %d", tbm_key_main);
315 goto _CAPTURE_CB_HANDLER_DONE;
318 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] == NULL) {
319 LOGW("NULL callback");
320 goto _CAPTURE_CB_HANDLER_DONE;
323 /* import tbm bo and get virtual address */
324 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_main, &bo_main, &bo_main_handle)) {
325 LOGE("failed to import key [%d] for main", tbm_key_main);
326 goto _CAPTURE_CB_HANDLER_DONE;
329 buf_pos = (unsigned char *)bo_main_handle.ptr;
330 rImage = (camera_image_data_s *)buf_pos;
331 rImage->data = buf_pos + sizeof(camera_image_data_s);
332 if (rImage->exif && rImage->exif_size > 0) {
333 rImage->exif = rImage->data + rImage->size;
336 rImage->exif_size = 0;
339 LOGD("image info %dx%d, size %d, EXIF info %p, size %d",
340 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
342 if (tbm_key_post > 0) {
343 /* import tbm bo and get virtual address */
344 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key_post, &bo_post, &bo_post_handle)) {
345 buf_pos = (unsigned char *)bo_post_handle.ptr;
346 rPostview = (camera_image_data_s *)buf_pos;
347 LOGD("rPostview->size : %d", rPostview->size);
348 rPostview->data = buf_pos + sizeof(camera_image_data_s);
350 LOGE("failed to import key [%d] for postview", tbm_key_post);
354 if (tbm_key_thumb > 0) {
355 /* import tbm bo and get virtual address */
356 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key_thumb, &bo_thumb, &bo_thumb_handle)) {
357 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
358 rThumbnail = (camera_image_data_s *)buf_pos;
359 LOGD("rThumbnail->size : %d", rThumbnail->size);
360 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
362 LOGE("failed to import key [%d] for thumbnail", tbm_key_thumb);
366 ((camera_capturing_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE])(rImage,
367 rPostview, rThumbnail, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE]);
369 _CAPTURE_CB_HANDLER_DONE:
371 if (tbm_key_main > 0) {
372 _camera_release_imported_bo(&bo_main);
374 tbm_key = tbm_key_main;
375 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
377 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
380 if (tbm_key_post > 0) {
381 _camera_release_imported_bo(&bo_post);
383 tbm_key = tbm_key_post;
384 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
386 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
389 if (tbm_key_thumb > 0) {
390 _camera_release_imported_bo(&bo_thumb);
392 tbm_key = tbm_key_thumb;
393 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
395 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
398 LOGD("return buffer done");
404 static void __camera_event_handler_face_detection(camera_cb_info_s *cb_info, char *recv_msg)
408 camera_detected_face_s *faces = NULL;
409 camera_msg_param param;
412 tbm_bo_handle bo_handle = {.ptr = NULL};
414 if (!cb_info || !recv_msg) {
415 LOGE("invalid param %p %p", cb_info, recv_msg);
419 muse_camera_msg_get(count, recv_msg);
420 muse_camera_msg_get(tbm_key, recv_msg);
422 if (count >= 0 && cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]) {
423 LOGD("FACE_DETECTION - count %d, tbm_key %d", count, tbm_key);
427 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
429 faces = bo_handle.ptr;
433 ((camera_face_detected_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION])(faces,
434 count, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
437 _camera_release_imported_bo(&bo);
439 LOGW("skip face detection message [count %d, key %d, cb %p",
440 count, tbm_key, cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
445 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
446 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
447 /*LOGD("return buffer done");*/
454 static int _camera_import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle)
456 tbm_bo tmp_bo = NULL;
457 tbm_bo_handle tmp_bo_handle = {NULL, };
459 if (!bufmgr || !bo || !bo_handle || !tbm_key) {
460 LOGE("invalid parameter - %p %p %p, key %d",
461 bufmgr, bo, bo_handle, tbm_key);
465 tmp_bo = tbm_bo_import(bufmgr, tbm_key);
466 if (tmp_bo == NULL) {
467 LOGE("import failed - key %d", tbm_key);
471 tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
472 if (tmp_bo_handle.ptr == NULL) {
473 LOGE("map failed %p", tmp_bo);
474 tbm_bo_unref(tmp_bo);
479 tbm_bo_unmap(tmp_bo);
481 /* set bo and bo_handle */
483 *bo_handle = tmp_bo_handle;
488 static void _camera_release_imported_bo(tbm_bo *bo)
501 static int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
503 int ret = CAMERA_ERROR_NONE;
506 /*LOGD("Enter api : %d", api);*/
508 if (!cb_info->is_server_connected) {
509 LOGE("server is disconnected");
510 return CAMERA_ERROR_SERVICE_DISCONNECTED;
513 g_mutex_lock(&(cb_info->api_mutex[api]));
515 if (cb_info->api_activating[api] == 0) {
516 if (time_out == CAMERA_CB_NO_TIMEOUT) {
517 LOGW("wait for api %d", api);
518 g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
519 ret = cb_info->api_ret[api];
520 cb_info->api_activating[api] = 0;
521 LOGW("api %d returned 0x%x", api, ret);
523 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
524 if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
525 ret = cb_info->api_ret[api];
526 cb_info->api_activating[api] = 0;
527 /*LOGD("return value : 0x%x", ret);*/
529 ret = CAMERA_ERROR_INVALID_OPERATION;
530 LOGE("api %d was TIMED OUT!", api);
534 ret = cb_info->api_ret[api];
535 cb_info->api_activating[api] = 0;
537 /*LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);*/
540 g_mutex_unlock(&(cb_info->api_mutex[api]));
542 if (ret != CAMERA_ERROR_NONE)
543 LOGE("api %d : error 0x%x", api, ret);
549 static void _camera_msg_send(int api, camera_cb_info_s *cb_info,
550 int *ret, int timeout)
556 LOGE("NULL info - api %d", api);
559 *ret = CAMERA_ERROR_INVALID_PARAMETER;
564 msg = muse_core_msg_new(api, NULL);
566 LOGE("msg failed: api %d", api);
569 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
574 /*LOGD("send msg %s", msg);*/
576 if (cb_info->is_server_connected) {
577 __camera_update_api_waiting(cb_info, api, 1);
579 g_mutex_lock(&cb_info->fd_lock);
580 send_ret = muse_core_msg_send(cb_info->fd, msg);
581 g_mutex_unlock(&cb_info->fd_lock);
585 LOGE("msg send failed");
587 *ret = CAMERA_ERROR_INVALID_OPERATION;
590 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
593 __camera_update_api_waiting(cb_info, api, -1);
595 muse_core_msg_free(msg);
601 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
602 int *ret, camera_msg_param *param, int timeout)
607 if (!cb_info || !param) {
608 LOGE("invalid pointer : api %d - %p %p", api, cb_info, param);
611 *ret = CAMERA_ERROR_INVALID_PARAMETER;
616 /*LOGD("type %d, name %s", param->type, param->name);*/
618 switch (param->type) {
620 msg = muse_core_msg_new(api,
621 param->type, param->name, param->value.value_INT,
624 case MUSE_TYPE_STRING:
625 msg = muse_core_msg_new(api,
626 param->type, param->name, param->value.value_STRING,
630 LOGE("unknown type %d", param->type);
635 LOGE("msg failed: api %d", api);
638 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
643 /*LOGD("send msg %s", msg);*/
645 if (cb_info->is_server_connected) {
646 __camera_update_api_waiting(cb_info, api, 1);
648 g_mutex_lock(&cb_info->fd_lock);
649 send_ret = muse_core_msg_send(cb_info->fd, msg);
650 g_mutex_unlock(&cb_info->fd_lock);
654 LOGE("msg send failed");
657 *ret = CAMERA_ERROR_INVALID_OPERATION;
660 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
663 __camera_update_api_waiting(cb_info, api, -1);
665 muse_core_msg_free(msg);
671 static void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
672 int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout)
674 int func_ret = CAMERA_ERROR_NONE;
678 if (!cb_info || !param0 || !param1) {
679 LOGE("invalid ptr %p %p %p : api %d",
680 cb_info, param0, param1, api);
681 func_ret = CAMERA_ERROR_INVALID_PARAMETER;
682 goto _SEND_PARAM2_INT_DONE;
685 /*LOGD("api %d, param0 [%s:%d], param1 [%s:%d]",
687 param0->name, param0->value.value_INT,
688 param1->name, param1->value.value_INT);*/
690 msg = muse_core_msg_new(api,
691 param0->type, param0->name, param0->value.value_INT,
692 param1->type, param1->name, param1->value.value_INT,
695 LOGE("msg failed: api %d", api);
696 func_ret = CAMERA_ERROR_OUT_OF_MEMORY;
697 goto _SEND_PARAM2_INT_DONE;
700 /*LOGD("send msg [%s]", msg);*/
702 if (cb_info->is_server_connected) {
703 __camera_update_api_waiting(cb_info, api, 1);
705 g_mutex_lock(&cb_info->fd_lock);
706 send_ret = muse_core_msg_send(cb_info->fd, msg);
707 g_mutex_unlock(&cb_info->fd_lock);
711 LOGE("msg send failed");
713 func_ret = CAMERA_ERROR_INVALID_OPERATION;
715 func_ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
718 __camera_update_api_waiting(cb_info, api, -1);
720 muse_core_msg_free(msg);
722 _SEND_PARAM2_INT_DONE:
730 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
732 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
733 in_format >= MM_PIXEL_FORMAT_NUM ||
734 out_format == NULL) {
735 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
736 return CAMERA_ERROR_INVALID_PARAMETER;
740 case MM_PIXEL_FORMAT_NV12:
741 case MM_PIXEL_FORMAT_NV12T:
742 *out_format = TBM_FORMAT_NV12;
745 case MM_PIXEL_FORMAT_NV16:
746 *out_format = TBM_FORMAT_NV16;
748 case MM_PIXEL_FORMAT_NV21:
749 *out_format = TBM_FORMAT_NV21;
751 case MM_PIXEL_FORMAT_YUYV:
752 *out_format = TBM_FORMAT_YUYV;
754 case MM_PIXEL_FORMAT_UYVY:
755 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
756 *out_format = TBM_FORMAT_UYVY;
758 case MM_PIXEL_FORMAT_422P:
759 *out_format = TBM_FORMAT_YUV422;
761 case MM_PIXEL_FORMAT_I420:
762 *out_format = TBM_FORMAT_YUV420;
764 case MM_PIXEL_FORMAT_YV12:
765 *out_format = TBM_FORMAT_YVU420;
767 case MM_PIXEL_FORMAT_RGB565:
768 *out_format = TBM_FORMAT_RGB565;
770 case MM_PIXEL_FORMAT_RGB888:
771 *out_format = TBM_FORMAT_RGB888;
773 case MM_PIXEL_FORMAT_RGBA:
774 *out_format = TBM_FORMAT_RGBA8888;
776 case MM_PIXEL_FORMAT_ARGB:
777 *out_format = TBM_FORMAT_ARGB8888;
780 LOGE("invalid in_format %d", in_format);
781 return CAMERA_ERROR_INVALID_PARAMETER;
785 return CAMERA_ERROR_NONE;
789 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
791 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
792 in_format >= MM_PIXEL_FORMAT_NUM ||
794 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
795 return CAMERA_ERROR_INVALID_PARAMETER;
799 case MM_PIXEL_FORMAT_NV12:
800 case MM_PIXEL_FORMAT_NV12T:
801 *mimetype = MEDIA_FORMAT_NV12;
804 case MM_PIXEL_FORMAT_NV16:
805 *mimetype = MEDIA_FORMAT_NV16;
807 case MM_PIXEL_FORMAT_NV21:
808 *mimetype = MEDIA_FORMAT_NV21;
810 case MM_PIXEL_FORMAT_YUYV:
811 *mimetype = MEDIA_FORMAT_YUYV;
813 case MM_PIXEL_FORMAT_UYVY:
814 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
815 *mimetype = MEDIA_FORMAT_UYVY;
817 case MM_PIXEL_FORMAT_422P:
818 *mimetype = MEDIA_FORMAT_422P;
820 case MM_PIXEL_FORMAT_I420:
821 *mimetype = MEDIA_FORMAT_I420;
823 case MM_PIXEL_FORMAT_YV12:
824 *mimetype = MEDIA_FORMAT_YV12;
826 case MM_PIXEL_FORMAT_RGB565:
827 *mimetype = MEDIA_FORMAT_RGB565;
829 case MM_PIXEL_FORMAT_RGB888:
830 *mimetype = MEDIA_FORMAT_RGB888;
832 case MM_PIXEL_FORMAT_RGBA:
833 *mimetype = MEDIA_FORMAT_RGBA;
835 case MM_PIXEL_FORMAT_ARGB:
836 *mimetype = MEDIA_FORMAT_ARGB;
839 LOGE("invalid in_format %d", in_format);
840 return CAMERA_ERROR_INVALID_PARAMETER;
844 return CAMERA_ERROR_NONE;
847 static void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_key,
848 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame)
851 unsigned char *buf_pos = NULL;
853 if (stream == NULL || buffer_bo_handle == NULL || frame == NULL) {
854 LOGE("invalid parameter - stream:%p, buffer_bo_handle:%p", stream, buffer_bo_handle);
859 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
860 frame->format = MM_PIXEL_FORMAT_UYVY;
862 frame->format = stream->format;
864 frame->width = stream->width;
865 frame->height = stream->height;
866 frame->timestamp = stream->timestamp;
867 frame->num_of_planes = stream->num_planes;
869 if (num_buffer_key == 0) {
872 if (!data_bo_handle || !data_bo_handle->ptr) {
873 LOGE("NULL pointer");
877 buf_pos = data_bo_handle->ptr;
879 if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) {
880 frame->data.encoded_plane.data = buf_pos;
881 frame->data.encoded_plane.size = stream->data.encoded.length_data;
882 total_size = stream->data.encoded.length_data;
883 } else if (stream->format == MM_PIXEL_FORMAT_INVZ) {
884 frame->data.depth_plane.data = buf_pos;
885 frame->data.depth_plane.size = stream->data.depth.length_data;
886 total_size = stream->data.depth.length_data;
887 } else if (stream->format == MM_PIXEL_FORMAT_RGBA ||
888 stream->format == MM_PIXEL_FORMAT_ARGB) {
889 frame->data.rgb_plane.data = buf_pos;
890 frame->data.rgb_plane.size = stream->data.rgb.length_data;
891 total_size = stream->data.rgb.length_data;
893 switch (stream->num_planes) {
895 frame->data.single_plane.yuv = buf_pos;
896 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
897 total_size = stream->data.yuv420.length_yuv;
900 frame->data.double_plane.y = buf_pos;
901 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
902 buf_pos += stream->data.yuv420sp.length_y;
903 frame->data.double_plane.uv = buf_pos;
904 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
905 total_size = stream->data.yuv420sp.length_y + \
906 stream->data.yuv420sp.length_uv;
909 frame->data.triple_plane.y = buf_pos;
910 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
911 buf_pos += stream->data.yuv420p.length_y;
912 frame->data.triple_plane.u = buf_pos;
913 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
914 buf_pos += stream->data.yuv420p.length_u;
915 frame->data.triple_plane.v = buf_pos;
916 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
917 total_size = stream->data.yuv420p.length_y + \
918 stream->data.yuv420p.length_u + \
919 stream->data.yuv420p.length_v;
928 switch (stream->num_planes) {
931 frame->data.single_plane.yuv = buffer_bo_handle[0].ptr;
932 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
933 total_size = stream->data.yuv420.length_yuv;
937 frame->data.double_plane.y = buffer_bo_handle[0].ptr;
938 if (stream->num_planes == (unsigned int)num_buffer_key)
939 frame->data.double_plane.uv = buffer_bo_handle[1].ptr;
941 frame->data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
942 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
943 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
944 total_size = stream->data.yuv420sp.length_y + \
945 stream->data.yuv420sp.length_uv;
949 frame->data.triple_plane.y = buffer_bo_handle[0].ptr;
950 if (stream->num_planes == (unsigned int)num_buffer_key) {
951 frame->data.triple_plane.u = buffer_bo_handle[1].ptr;
952 frame->data.triple_plane.v = buffer_bo_handle[2].ptr;
954 frame->data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y;
955 frame->data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u;
957 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
958 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
959 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
960 total_size = stream->data.yuv420p.length_y + \
961 stream->data.yuv420p.length_u + \
962 stream->data.yuv420p.length_v;
971 LOGD("format %d, %dx%d, size %d plane num %d",
972 frame.format, frame.width, frame.height, total_size, frame.num_of_planes);
978 static int _camera_media_packet_data_create(int tbm_key, int num_buffer_key, tbm_bo bo,
979 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
982 int ret = CAMERA_ERROR_NONE;
983 camera_media_packet_data *tmp_mp_data = NULL;
985 if (*mp_data == NULL) {
986 tmp_mp_data = g_new0(camera_media_packet_data, 1);
988 tmp_mp_data->tbm_key = tbm_key;
989 tmp_mp_data->num_buffer_key = num_buffer_key;
990 tmp_mp_data->bo = bo;
991 tmp_mp_data->data_bo = data_bo;
992 tmp_mp_data->ref_cnt++;
994 for (i = 0 ; i < num_buffer_key ; i++)
995 tmp_mp_data->buffer_bo[i] = buffer_bo[i];
997 *mp_data = tmp_mp_data;
998 /*LOGD("mp_data %p", tmp_mp_data);*/
1000 ret = CAMERA_ERROR_OUT_OF_MEMORY;
1001 LOGE("failed to alloc media packet data");
1004 ((camera_media_packet_data *)*mp_data)->ref_cnt++;
1010 static void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
1014 camera_msg_param param;
1016 if (!mp_data || !cb_info) {
1017 LOGE("NULL pointer %p %p", mp_data, cb_info);
1021 if (mp_data->ref_cnt > 1) {
1023 LOGD("ref count %d", mp_data->ref_cnt);
1025 /* release imported bo */
1026 for (i = 0 ; i < mp_data->num_buffer_key ; i++) {
1027 tbm_bo_unref(mp_data->buffer_bo[i]);
1028 mp_data->buffer_bo[i] = NULL;
1032 _camera_release_imported_bo(&mp_data->bo);
1033 _camera_release_imported_bo(&mp_data->data_bo);
1036 tbm_key = mp_data->tbm_key;
1038 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1040 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1049 static int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
1050 camera_media_packet_data *mp_data, media_packet_h *packet)
1052 media_packet_h pkt = NULL;
1053 bool make_pkt_fmt = false;
1054 tbm_surface_h tsurf = NULL;
1055 tbm_surface_info_s tsurf_info;
1056 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
1057 uint32_t bo_format = 0;
1060 int num_buffer_key = 0;
1061 tbm_bo *buffer_bo = NULL;
1063 if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) {
1064 LOGE("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p",
1065 cb_info, stream, mp_data, packet);
1066 return CAMERA_ERROR_INVALID_PARAMETER;
1069 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
1070 buffer_bo = mp_data->buffer_bo;
1071 num_buffer_key = mp_data->num_buffer_key;
1073 /* create tbm surface */
1074 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
1075 tsurf_info.planes[i].stride = stream->stride[i];
1077 /* get tbm surface format */
1078 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
1079 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
1081 if (ret == CAMERA_ERROR_NONE) {
1082 tsurf_info.width = stream->width;
1083 tsurf_info.height = stream->height;
1084 tsurf_info.format = bo_format;
1085 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
1086 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
1088 if (num_buffer_key > 0) {
1089 switch (bo_format) {
1090 case TBM_FORMAT_NV12:
1091 case TBM_FORMAT_NV21:
1092 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1093 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1094 tsurf_info.planes[0].offset = 0;
1095 if (num_buffer_key == 1)
1096 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1097 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1100 case TBM_FORMAT_YUV420:
1101 case TBM_FORMAT_YVU420:
1102 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1103 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1104 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
1105 tsurf_info.planes[0].offset = 0;
1106 if (num_buffer_key == 1) {
1107 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1108 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1110 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1112 case TBM_FORMAT_UYVY:
1113 case TBM_FORMAT_YUYV:
1114 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
1115 tsurf_info.planes[0].offset = 0;
1116 tsurf_info.size = tsurf_info.planes[0].size;
1123 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_key);
1124 } else if (mp_data->data_bo) {
1126 switch (bo_format) {
1127 case TBM_FORMAT_NV12:
1128 case TBM_FORMAT_NV21:
1129 tsurf_info.planes[0].size = stream->width * stream->height;
1130 tsurf_info.planes[1].size = (tsurf_info.planes[0].size) >> 1;
1131 tsurf_info.planes[0].offset = 0;
1132 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1133 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1135 case TBM_FORMAT_YUV420:
1136 case TBM_FORMAT_YVU420:
1137 tsurf_info.planes[0].size = stream->width * stream->height;
1138 tsurf_info.planes[1].size = (stream->width >> 1) * (stream->height >> 1);
1139 tsurf_info.planes[2].size = tsurf_info.planes[1].size;
1140 tsurf_info.planes[0].offset = 0;
1141 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1142 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1143 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1145 case TBM_FORMAT_UYVY:
1146 case TBM_FORMAT_YUYV:
1147 tsurf_info.planes[0].size = (stream->width * stream->height) << 1;
1148 tsurf_info.planes[0].offset = 0;
1149 tsurf_info.size = tsurf_info.planes[0].size;
1155 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1);
1158 /*LOGD("tbm surface %p", tsurf);*/
1162 /* check media packet format */
1163 if (cb_info->pkt_fmt) {
1164 int pkt_fmt_width = 0;
1165 int pkt_fmt_height = 0;
1166 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
1168 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
1169 if (pkt_fmt_mimetype != mimetype ||
1170 pkt_fmt_width != stream->width ||
1171 pkt_fmt_height != stream->height) {
1172 LOGW("change fmt: current 0x%x, %dx%d",
1173 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
1174 media_format_unref(cb_info->pkt_fmt);
1175 cb_info->pkt_fmt = NULL;
1176 make_pkt_fmt = true;
1179 make_pkt_fmt = true;
1182 /* create packet format */
1184 LOGW("make new pkt_fmt - 0x%x, %dx%d", mimetype, stream->width, stream->height);
1185 ret = media_format_create(&cb_info->pkt_fmt);
1186 if (ret == MEDIA_FORMAT_ERROR_NONE) {
1187 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
1188 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
1189 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
1190 LOGW("media_format_set : 0x%x", ret);
1192 LOGW("media_format_create failed 0x%x", ret);
1196 /* create media packet */
1197 ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt,
1198 tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
1199 (void *)cb_info, &pkt);
1200 if (ret != MEDIA_PACKET_ERROR_NONE) {
1201 LOGE("media_packet_create failed 0x%x", ret);
1202 tbm_surface_destroy(tsurf);
1206 LOGE("tbm surface failed. %dx%d, format %d, num_buffer_key %d, data_bo %p",
1207 stream->width, stream->height, stream->format, num_buffer_key, mp_data->data_bo);
1211 /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
1212 /* set media packet data */
1213 ret = media_packet_set_extra(pkt, (void *)mp_data);
1214 if (ret != MEDIA_PACKET_ERROR_NONE) {
1215 LOGE("media_packet_set_extra failed");
1217 _camera_media_packet_data_release(mp_data, cb_info);
1220 media_packet_destroy(pkt);
1223 /* set timestamp : msec -> nsec */
1224 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
1225 LOGW("media_packet_set_pts failed");
1234 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
1237 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1238 camera_media_packet_data *mp_data = NULL;
1239 tbm_surface_h tsurf = NULL;
1241 if (!pkt || !cb_info) {
1242 LOGE("NULL pointer %p %p", pkt, cb_info);
1243 return MEDIA_PACKET_FINALIZE;
1246 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1247 if (ret != MEDIA_PACKET_ERROR_NONE) {
1248 LOGE("media_packet_get_extra failed 0x%x", ret);
1249 return MEDIA_PACKET_FINALIZE;
1252 /*LOGD("mp_data %p", mp_data);*/
1254 g_mutex_lock(&cb_info->mp_data_mutex);
1256 _camera_media_packet_data_release(mp_data, cb_info);
1259 g_mutex_unlock(&cb_info->mp_data_mutex);
1261 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1262 if (ret != MEDIA_PACKET_ERROR_NONE)
1263 LOGE("get tbm_surface failed 0x%x", ret);
1266 tbm_surface_destroy(tsurf);
1270 return MEDIA_PACKET_FINALIZE;
1273 static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event)
1278 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1279 LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event);
1283 /*LOGD("get camera msg %s, event %d", recv_msg, event);*/
1285 g_mutex_lock(&cb_info->user_cb_mutex[event]);
1287 if (cb_info->user_cb[event] == NULL) {
1288 if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
1289 event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
1290 event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
1291 event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1292 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1293 LOGW("NULL callback for event %d, return here", event);
1297 /* return buffer message should be sent for some events.
1298 - MUSE_CAMERA_EVENT_TYPE_PREVIEW
1299 - MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW
1300 - MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION
1301 - MUSE_CAMERA_EVENT_TYPE_CAPTURE
1306 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1312 muse_camera_msg_get(previous, recv_msg);
1313 muse_camera_msg_get(current, recv_msg);
1314 muse_camera_msg_get(by_policy, recv_msg);
1316 LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
1317 previous, current, by_policy);
1319 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1320 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1323 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1327 muse_camera_msg_get(state, recv_msg);
1329 LOGD("FOCUS state - %d", state);
1331 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1334 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1335 LOGD("CAPTURE_COMPLETED");
1336 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1338 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1339 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1340 __camera_event_handler_preview(cb_info, recv_msg);
1343 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1347 muse_camera_msg_get(percent, recv_msg);
1349 LOGD("HDR progress - %d %%", percent);
1351 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1354 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1360 muse_camera_msg_get(policy, recv_msg);
1361 muse_camera_msg_get(previous, recv_msg);
1362 muse_camera_msg_get(current, recv_msg);
1364 LOGW("INTERRUPTED - policy %d, state %d -> %d", policy, previous, current);
1366 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1367 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1370 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1375 muse_camera_msg_get(policy, recv_msg);
1376 muse_camera_msg_get(state, recv_msg);
1378 LOGW("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1380 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1381 (camera_state_e)state, cb_info->user_data[event]);
1384 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1385 __camera_event_handler_face_detection(cb_info, recv_msg);
1387 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1390 int current_state = 0;
1392 muse_camera_msg_get(error, recv_msg);
1393 muse_camera_msg_get(current_state, recv_msg);
1395 LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
1397 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1398 (camera_state_e)current_state, cb_info->user_data[event]);
1402 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1404 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1405 muse_camera_msg_get(param1, recv_msg);
1406 muse_camera_msg_get(param2, recv_msg);
1408 /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/
1410 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1411 cb_info->user_cb[event] = NULL;
1412 cb_info->user_data[event] = NULL;
1413 LOGW("stop foreach callback for event %d", event);
1416 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1418 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1420 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1422 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1424 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1426 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1428 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1430 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1432 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1434 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1436 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1438 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1440 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1443 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1445 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1446 muse_camera_msg_get(param1, recv_msg);
1448 /*LOGD("event %d SUPPORTED %d ", event, param1);*/
1450 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1451 cb_info->user_cb[event] = NULL;
1452 cb_info->user_data[event] = NULL;
1453 LOGW("stop foreach callback for event %d", event);
1457 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1458 __camera_event_handler_capture(cb_info, recv_msg);
1461 LOGW("unhandled event %d", event);
1465 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1470 static bool _camera_idle_event_callback(void *data)
1472 camera_cb_info_s *cb_info = NULL;
1473 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1475 if (cam_idle_event == NULL) {
1476 LOGE("cam_idle_event is NULL");
1481 g_mutex_lock(&cam_idle_event->event_mutex);
1483 cb_info = cam_idle_event->cb_info;
1484 if (cb_info == NULL) {
1485 LOGW("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1486 goto IDLE_EVENT_CALLBACK_DONE;
1489 /* remove event from list */
1490 g_mutex_lock(&cb_info->idle_event_mutex);
1492 if (cb_info->idle_event_list)
1493 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1495 /*LOGD("remove camera idle event %p, %p", cam_idle_event, cb_info->idle_event_list);*/
1496 g_mutex_unlock(&cb_info->idle_event_mutex);
1499 _camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
1501 /* send signal for waiting thread */
1502 g_cond_signal(&cb_info->idle_event_cond);
1504 IDLE_EVENT_CALLBACK_DONE:
1505 /* unlock and release event */
1506 g_mutex_unlock(&cam_idle_event->event_mutex);
1507 g_mutex_clear(&cam_idle_event->event_mutex);
1509 g_free(cam_idle_event);
1510 cam_idle_event = NULL;
1515 static void *_camera_msg_handler_func(gpointer data)
1519 camera_message_s *cam_msg = NULL;
1520 camera_idle_event_s *cam_idle_event = NULL;
1521 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1522 camera_cb_info_s *cb_info = NULL;
1524 if (!handler_info || !handler_info->cb_info) {
1525 LOGE("NULL handler %p", handler_info);
1529 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1530 type = handler_info->type;
1532 LOGD("t:%d start", type);
1534 g_mutex_lock(&handler_info->mutex);
1536 while (g_atomic_int_get(&handler_info->running)) {
1537 if (g_queue_is_empty(handler_info->queue)) {
1538 /*LOGD("t:%d signal wait...", type);*/
1539 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1540 /*LOGD("t:%d signal received", type);*/
1542 if (g_atomic_int_get(&handler_info->running) == 0) {
1543 LOGD("t:%d stop event thread", type);
1548 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1550 g_mutex_unlock(&handler_info->mutex);
1552 if (cam_msg == NULL) {
1553 LOGE("t:%d NULL message", type);
1554 g_mutex_lock(&handler_info->mutex);
1560 if (api < MUSE_CAMERA_API_MAX) {
1563 g_mutex_lock(&cb_info->api_mutex[api]);
1565 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1566 if (cb_info->api_waiting[api] > 0) {
1567 cb_info->api_ret[api] = ret;
1568 cb_info->api_activating[api] = 1;
1570 /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
1572 g_cond_signal(&cb_info->api_cond[api]);
1574 LOGW("no waiting for this api [%d]", api);
1577 LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1580 g_mutex_unlock(&cb_info->api_mutex[api]);
1581 } else if (api == MUSE_CAMERA_CB_EVENT) {
1582 switch (cam_msg->event_class) {
1583 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1584 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event);
1586 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1587 cam_idle_event = g_new0(camera_idle_event_s, 1);
1588 if (cam_idle_event == NULL) {
1589 LOGE("t:%d cam_idle_event alloc failed", type);
1593 cam_idle_event->event = cam_msg->event;
1594 cam_idle_event->cb_info = cb_info;
1595 g_mutex_init(&cam_idle_event->event_mutex);
1596 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg) - 1);
1598 /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, cam_msg->event, cam_idle_event);*/
1600 g_mutex_lock(&cb_info->idle_event_mutex);
1601 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1602 g_mutex_unlock(&cb_info->idle_event_mutex);
1604 g_idle_add_full(G_PRIORITY_DEFAULT,
1605 (GSourceFunc)_camera_idle_event_callback,
1606 (gpointer)cam_idle_event,
1610 LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
1614 LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1620 g_mutex_lock(&handler_info->mutex);
1623 /* remove remained event */
1624 while (!g_queue_is_empty(handler_info->queue)) {
1625 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1627 LOGD("t:%d remove camera message %p", type, cam_msg);
1631 LOGW("t:%d NULL camera message", type);
1635 g_mutex_unlock(&handler_info->mutex);
1637 LOGD("t:%d return", type);
1643 static void _camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1645 camera_idle_event_s *cam_idle_event = NULL;
1647 gint64 end_time = 0;
1649 if (cb_info == NULL) {
1650 LOGE("cb_info is NULL");
1654 g_mutex_lock(&cb_info->idle_event_mutex);
1656 if (cb_info->idle_event_list == NULL) {
1657 LOGD("No remained idle event");
1658 g_mutex_unlock(&cb_info->idle_event_mutex);
1662 list = cb_info->idle_event_list;
1665 cam_idle_event = list->data;
1666 list = g_list_next(list);
1668 if (!cam_idle_event) {
1669 LOGW("Fail to remove idle event. The event is NULL");
1673 if (g_idle_remove_by_data(cam_idle_event)) {
1674 LOGW("remove idle event %p done", cam_idle_event);
1676 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1678 g_mutex_clear(&cam_idle_event->event_mutex);
1679 g_free(cam_idle_event);
1680 cam_idle_event = NULL;
1685 LOGW("remove idle event %p failed", cam_idle_event);
1687 if (!g_mutex_trylock(&cam_idle_event->event_mutex)) {
1688 LOGW("lock failed, %p event is calling now", cam_idle_event);
1690 end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
1692 if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
1693 LOGW("signal received");
1700 LOGW("set NULL cb_info for event %p %d, it will be freed on idle callback",
1701 cam_idle_event, cam_idle_event->event);
1703 cam_idle_event->cb_info = NULL;
1705 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1707 g_mutex_unlock(&cam_idle_event->event_mutex);
1710 g_list_free(cb_info->idle_event_list);
1711 cb_info->idle_event_list = NULL;
1713 g_mutex_unlock(&cb_info->idle_event_mutex);
1719 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg)
1721 camera_message_s *cam_msg = NULL;
1723 if (!cb_info || !msg) {
1724 LOGE("NULL pointer %p %p", cb_info, msg);
1728 cam_msg = g_new0(camera_message_s, 1);
1730 LOGE("failed to alloc cam_msg for [%s]", msg);
1735 cam_msg->event = event;
1736 cam_msg->event_class = event_class;
1738 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1740 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1742 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1743 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1744 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1745 g_cond_signal(&cb_info->preview_cb_info.cond);
1746 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1747 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1748 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1749 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1750 g_cond_signal(&cb_info->capture_cb_info.cond);
1751 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1753 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1754 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1755 g_cond_signal(&cb_info->msg_handler_info.cond);
1756 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1765 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg)
1767 int ret = CAMERA_ERROR_NONE;
1771 int event_class = -1;
1775 if (!cb_info || !msg) {
1776 LOGE("invalid ptr %p %p", cb_info, msg);
1780 /*LOGD("msg [%s]", msg);*/
1782 if (!muse_camera_msg_get(api, msg)) {
1783 LOGE("failed to get camera api");
1787 if (api == MUSE_CAMERA_CB_EVENT) {
1788 if (!muse_camera_msg_get(event, msg) ||
1789 !muse_camera_msg_get(event_class, msg)) {
1790 LOGE("failed to get camera event or event_class [%s]", msg);
1794 if (!muse_camera_msg_get(api_class, msg)) {
1795 LOGE("failed to get camera api_class [%s]", msg);
1800 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1801 if (api >= MUSE_CAMERA_API_MAX) {
1802 LOGE("invalid api %d", api);
1806 if (!muse_camera_msg_get(ret, msg)) {
1807 LOGE("failed to get camera ret");
1811 g_mutex_lock(&cb_info->api_mutex[api]);
1814 case MUSE_CAMERA_API_CREATE:
1815 if (ret != CAMERA_ERROR_NONE) {
1816 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1817 LOGE("camera create error 0x%x. close client cb handler", ret);
1820 case MUSE_CAMERA_API_DESTROY:
1821 if (ret == CAMERA_ERROR_NONE) {
1822 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1823 LOGD("camera destroy done. close client cb handler");
1827 muse_camera_msg_get(get_type, msg);
1828 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1829 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1830 muse_camera_msg_get(get_index, msg);
1833 case MUSE_CAMERA_GET_TYPE_INT:
1834 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
1836 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1837 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
1838 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
1840 case MUSE_CAMERA_GET_TYPE_ARRAY:
1841 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
1842 muse_core_msg_deserialize("get_value",
1843 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
1844 LOGD("get display roi %d,%d,%dx%d",
1845 cb_info->get_display_roi_area[0],
1846 cb_info->get_display_roi_area[1],
1847 cb_info->get_display_roi_area[2],
1848 cb_info->get_display_roi_area[3]);
1850 muse_core_msg_deserialize("get_value",
1851 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
1852 LOGD("get geotag %lf, %lf, %lf",
1853 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
1856 case MUSE_CAMERA_GET_TYPE_STRING:
1857 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
1860 LOGW("unknown type %d", get_type);
1867 if (cb_info->api_waiting[api] > 0) {
1868 cb_info->api_ret[api] = ret;
1869 cb_info->api_activating[api] = 1;
1871 g_cond_signal(&cb_info->api_cond[api]);
1873 LOGW("no waiting for this api [%d]", api);
1876 g_mutex_unlock(&cb_info->api_mutex[api]);
1877 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
1878 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg);
1880 LOGW("unknown camera api %d, class %d", api, api_class);
1887 static void *_camera_msg_recv_func(gpointer data)
1889 int recv_length = 0;
1890 int single_length = 0;
1891 int remained_length = 0;
1892 char *recv_msg = NULL;
1893 char *single_msg = NULL;
1894 char *remained_msg = NULL;
1898 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
1901 LOGE("cb_info NULL");
1905 LOGD("start - fd : %d", cb_info->fd);
1907 single_msg = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
1909 LOGE("single_msg malloc failed");
1913 recv_msg = cb_info->recv_msg;
1915 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
1916 recv_length = muse_core_msg_recv(cb_info->fd, recv_msg, MUSE_MSG_MAX_LENGTH);
1917 if (recv_length <= 0) {
1918 cb_info->is_server_connected = FALSE;
1919 LOGE("receive msg failed - server disconnected");
1927 /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
1929 /* Need to split the combined entering msgs */
1930 for (cur_pos = 0 ; cur_pos < recv_length ; cur_pos++) {
1931 if (recv_msg[cur_pos] == '}') {
1932 single_length = cur_pos - prev_pos + 1;
1934 if (single_length < MUSE_CAMERA_MSG_MAX_LENGTH) {
1935 /* check remained msg */
1936 if (remained_length > 0) {
1938 strncpy(single_msg, remained_msg, remained_length);
1939 strncpy(single_msg + remained_length, recv_msg + prev_pos, single_length);
1940 single_msg[remained_length + single_length] = '\0';
1943 remained_msg = NULL;
1945 strncpy(single_msg, recv_msg + prev_pos, single_length);
1946 single_msg[single_length] = '\0';
1947 LOGE("lost msg [%s], skip...", single_msg);
1950 remained_length = 0;
1952 strncpy(single_msg, recv_msg + prev_pos, single_length);
1953 single_msg[single_length] = '\0';
1956 if (single_msg[0] == '{') {
1958 /*LOGD("splitted msg : [%s], Index : %d", single_msg, num_msg);*/
1959 /* process each message */
1960 __camera_process_msg(cb_info, single_msg);
1962 LOGE("invalid msg [%s]", single_msg);
1965 LOGE("too long message [len %d] skip...", single_length);
1968 prev_pos = cur_pos + 1;
1972 /* check incompleted message */
1973 if (recv_msg[recv_length - 1] != '}') {
1974 remained_length = recv_length - prev_pos;
1976 LOGW("incompleted message [len %d]", remained_length);
1980 remained_msg = NULL;
1983 remained_msg = (char *)malloc(remained_length + 1);
1985 strncpy(remained_msg, recv_msg + prev_pos, remained_length);
1986 remained_msg[remained_length] = '\0';
1988 LOGE("failed to alloc for remained msg");
1991 remained_length = 0;
1995 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
1997 if (!cb_info->is_server_connected) {
1998 char *error_msg = NULL;
2000 if (cb_info->fd < 0) {
2001 LOGE("fd is closed in client side");
2002 goto CB_HANDLER_EXIT;
2005 /* send error msg for server disconnection */
2006 error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
2007 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
2008 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
2012 LOGE("error_msg failed");
2013 goto CB_HANDLER_EXIT;
2016 __camera_add_msg_to_queue(cb_info,
2017 MUSE_CAMERA_CB_EVENT,
2018 MUSE_CAMERA_EVENT_TYPE_ERROR,
2019 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
2022 muse_core_msg_free(error_msg);
2025 LOGE("add error msg for service disconnection done");
2036 remained_msg = NULL;
2043 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2044 int type, const char *thread_name, camera_cb_info_s *cb_info)
2046 if (!handler_info || !thread_name || !cb_info) {
2047 LOGE("t:%d NULL %p %p %p",
2048 type, handler_info, thread_name, cb_info);
2054 handler_info->type = type;
2055 handler_info->queue = g_queue_new();
2056 if (handler_info->queue == NULL) {
2057 LOGE("t:%d queue failed", type);
2061 g_mutex_init(&handler_info->mutex);
2062 g_cond_init(&handler_info->cond);
2064 handler_info->cb_info = (void *)cb_info;
2065 g_atomic_int_set(&handler_info->running, 1);
2067 handler_info->thread = g_thread_try_new(thread_name,
2068 _camera_msg_handler_func, (gpointer)handler_info, NULL);
2069 if (handler_info->thread == NULL) {
2070 LOGE("t:%d thread failed", type);
2072 g_mutex_clear(&handler_info->mutex);
2073 g_cond_clear(&handler_info->cond);
2074 g_queue_free(handler_info->queue);
2075 handler_info->queue = NULL;
2080 LOGD("t:%d done", type);
2086 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2090 if (!handler_info) {
2091 LOGE("NULL handler");
2095 if (!handler_info->thread) {
2096 LOGW("thread is not created");
2100 type = handler_info->type;
2102 LOGD("t:%d thread %p", type, handler_info->thread);
2104 g_mutex_lock(&handler_info->mutex);
2105 g_atomic_int_set(&handler_info->running, 0);
2106 g_cond_signal(&handler_info->cond);
2107 g_mutex_unlock(&handler_info->mutex);
2109 g_thread_join(handler_info->thread);
2110 handler_info->thread = NULL;
2112 g_mutex_clear(&handler_info->mutex);
2113 g_cond_clear(&handler_info->cond);
2114 g_queue_free(handler_info->queue);
2115 handler_info->queue = NULL;
2117 LOGD("t:%d done", type);
2123 static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
2125 camera_cb_info_s *cb_info = NULL;
2128 g_return_val_if_fail(sockfd > 0, NULL);
2130 cb_info = g_new0(camera_cb_info_s, 1);
2131 if (cb_info == NULL) {
2132 LOGE("cb_info failed");
2136 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2138 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2139 g_mutex_init(&cb_info->api_mutex[i]);
2140 g_cond_init(&cb_info->api_cond[i]);
2143 g_mutex_init(&cb_info->fd_lock);
2144 g_mutex_init(&cb_info->idle_event_mutex);
2145 g_cond_init(&cb_info->idle_event_cond);
2146 g_mutex_init(&cb_info->mp_data_mutex);
2148 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2149 g_mutex_init(&cb_info->user_cb_mutex[i]);
2151 /* message handler thread */
2152 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2153 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2154 LOGE("msg_handler_info failed");
2158 /* message handler thread for preview callback */
2159 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2160 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2161 LOGE("preview_cb_info failed");
2165 /* message handler thread for capture callback */
2166 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2167 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2168 LOGE("capture_cb_info failed");
2172 cb_info->fd = sockfd;
2173 cb_info->preview_cb_flag = 0;
2175 /* message receive thread */
2176 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2177 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2178 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2179 if (cb_info->msg_recv_thread == NULL) {
2180 LOGE("message receive thread creation failed");
2184 cb_info->is_server_connected = TRUE;
2190 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2191 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2192 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2194 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2195 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2197 g_mutex_clear(&cb_info->fd_lock);
2198 g_mutex_clear(&cb_info->idle_event_mutex);
2199 g_cond_clear(&cb_info->idle_event_cond);
2200 g_mutex_clear(&cb_info->mp_data_mutex);
2202 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2203 g_mutex_clear(&cb_info->api_mutex[i]);
2204 g_cond_clear(&cb_info->api_cond[i]);
2215 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2219 g_return_if_fail(cb_info != NULL);
2221 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2223 g_thread_join(cb_info->msg_recv_thread);
2224 cb_info->msg_recv_thread = NULL;
2226 LOGD("msg_recv thread removed");
2228 /* destroy msg handler threads */
2229 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2230 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2231 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2233 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2234 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2236 g_mutex_clear(&cb_info->fd_lock);
2237 g_mutex_clear(&cb_info->idle_event_mutex);
2238 g_cond_clear(&cb_info->idle_event_cond);
2239 g_mutex_clear(&cb_info->mp_data_mutex);
2241 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2242 g_mutex_clear(&cb_info->api_mutex[i]);
2243 g_cond_clear(&cb_info->api_cond[i]);
2246 if (cb_info->fd > -1) {
2247 muse_client_close(cb_info->fd);
2251 if (cb_info->bufmgr) {
2252 tbm_bufmgr_deinit(cb_info->bufmgr);
2253 cb_info->bufmgr = NULL;
2255 if (cb_info->pkt_fmt) {
2256 media_format_unref(cb_info->pkt_fmt);
2257 cb_info->pkt_fmt = NULL;
2260 if (cb_info->dp_interface) {
2261 mm_display_interface_deinit(cb_info->dp_interface);
2262 cb_info->dp_interface = NULL;
2265 cb_info->preview_cb_flag = 0;
2274 int _camera_start_evas_rendering(camera_h camera)
2276 camera_cli_s *pc = (camera_cli_s *)camera;
2278 if (!pc || !pc->cb_info) {
2279 LOGE("NULL handle");
2280 return CAMERA_ERROR_INVALID_PARAMETER;
2285 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2286 LOGE("EVAS surface is not set");
2287 return CAMERA_ERROR_NONE;
2290 /* set evas render flag as RUN */
2291 pc->cb_info->run_evas_render = true;
2293 return CAMERA_ERROR_NONE;
2297 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2299 int ret = CAMERA_ERROR_NONE;
2300 camera_cli_s *pc = (camera_cli_s *)camera;
2302 if (!pc || !pc->cb_info) {
2303 LOGE("NULL handle");
2304 return CAMERA_ERROR_INVALID_PARAMETER;
2307 LOGD("stop - keep screen %d", keep_screen);
2309 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2310 LOGE("EVAS surface is not set");
2311 return CAMERA_ERROR_NONE;
2314 /* set evas render flag as STOP and release buffers */
2315 pc->cb_info->run_evas_render = false;
2317 ret = mm_display_interface_evas_flush(pc->cb_info->dp_interface, keep_screen);
2318 if (ret == MM_ERROR_NONE) {
2319 ret = CAMERA_ERROR_NONE;
2321 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2322 ret = CAMERA_ERROR_INVALID_OPERATION;
2329 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2331 int ret = CAMERA_ERROR_NONE;
2334 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2336 /* create muse connection */
2337 if (!key || !value) {
2338 LOGE("NULL pointer");
2339 return CAMERA_ERROR_INVALID_PARAMETER;
2342 sock_fd = muse_client_new();
2344 LOGE("muse_client_new failed");
2345 return CAMERA_ERROR_INVALID_OPERATION;
2348 msg = muse_core_msg_new(api,
2349 MUSE_TYPE_INT, "module", MUSE_CAMERA,
2350 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2354 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2358 ret = muse_core_msg_send(sock_fd, msg);
2360 muse_core_msg_free(msg);
2364 LOGE("send msg failed");
2365 ret = CAMERA_ERROR_INVALID_OPERATION;
2369 ret = muse_core_msg_recv(sock_fd, recv_msg, MUSE_CAMERA_MSG_MAX_LENGTH);
2371 LOGE("recv msg failed %d", errno);
2372 ret = CAMERA_ERROR_INVALID_OPERATION;
2376 if (!muse_camera_msg_get(ret, recv_msg)) {
2377 LOGE("failed to get return value from msg [%s]", recv_msg);
2378 ret = CAMERA_ERROR_INVALID_OPERATION;
2382 if (ret == CAMERA_ERROR_NONE)
2383 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2385 LOGD("api %d - value %d", api, *value);
2389 muse_client_close(sock_fd);
2397 int camera_create(camera_device_e device, camera_h *camera)
2400 char *send_msg = NULL;
2402 int ret = CAMERA_ERROR_NONE;
2404 camera_cli_s *pc = NULL;
2405 tbm_bufmgr bufmgr = NULL;
2407 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2408 muse_core_api_module_e muse_module = MUSE_CAMERA;
2409 int device_type = (int)device;
2412 LOGE("NULL pointer");
2413 return CAMERA_ERROR_INVALID_PARAMETER;
2416 sock_fd = muse_client_new();
2418 LOGE("muse_client_new failed - returned fd %d", sock_fd);
2419 ret = CAMERA_ERROR_INVALID_OPERATION;
2425 send_msg = muse_core_msg_new(api,
2426 MUSE_TYPE_INT, "module", muse_module,
2427 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2428 MUSE_TYPE_INT, "pid", pid,
2433 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2437 send_ret = muse_core_msg_send(sock_fd, send_msg);
2439 muse_core_msg_free(send_msg);
2443 LOGE("send msg failed %d", errno);
2444 ret = CAMERA_ERROR_INVALID_OPERATION;
2448 pc = g_new0(camera_cli_s, 1);
2450 LOGE("camera_cli_s alloc failed");
2451 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2455 bufmgr = tbm_bufmgr_init(-1);
2456 if (bufmgr == NULL) {
2457 LOGE("get tbm bufmgr failed");
2458 ret = CAMERA_ERROR_INVALID_OPERATION;
2462 pc->cb_info = _camera_client_callback_new(sock_fd);
2463 if (pc->cb_info == NULL) {
2464 LOGE("cb_info alloc failed");
2465 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2471 LOGD("cb info : %d", pc->cb_info->fd);
2473 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2475 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2477 if (ret == CAMERA_ERROR_NONE) {
2478 intptr_t handle = 0;
2480 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2482 LOGE("Receiving Handle Failed!!");
2483 ret = CAMERA_ERROR_INVALID_OPERATION;
2487 pc->remote_handle = handle;
2488 pc->cb_info->bufmgr = bufmgr;
2490 ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL);
2491 if (ret != CAMERA_ERROR_NONE) {
2492 LOGE("init display failed 0x%x", ret);
2496 LOGD("camera create 0x%x", pc->remote_handle);
2498 *camera = (camera_h)pc;
2500 /* get display interface handle */
2501 if (mm_display_interface_init(&pc->cb_info->dp_interface) != MM_ERROR_NONE)
2502 LOGW("display interface init failed");
2504 /* get default preview format */
2505 if (camera_get_preview_format(*camera, &pc->cb_info->preview_format) != CAMERA_ERROR_NONE) {
2506 LOGW("get default preview format failed");
2507 pc->cb_info->preview_format = CAMERA_PIXEL_FORMAT_INVALID;
2517 tbm_bufmgr_deinit(bufmgr);
2522 muse_client_close(sock_fd);
2528 int temp_fd = pc->cb_info->fd;
2530 /* pc->cb_info->fd should be closed,
2531 because g_thread_join for msg_recv_thread is not returned
2532 in _camera_client_callback_destroy. */
2534 pc->cb_info->fd = -1;
2535 muse_client_close(temp_fd);
2538 _camera_client_callback_destroy(pc->cb_info);
2545 LOGE("camera create error : 0x%x", ret);
2552 int camera_change_device(camera_h camera, camera_device_e device)
2555 int ret = CAMERA_ERROR_NONE;
2556 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2557 camera_cli_s *pc = (camera_cli_s *)camera;
2558 camera_msg_param param;
2560 if (!pc || !pc->cb_info) {
2561 LOGE("NULL handle");
2562 return CAMERA_ERROR_INVALID_PARAMETER;
2565 CAMERA_MSG_PARAM_SET(param, INT, device);
2567 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2569 if (ret == CAMERA_ERROR_NONE) {
2570 /* reset callback and user data */
2571 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2572 pc->cb_info->user_cb[i] = NULL;
2573 pc->cb_info->user_data[i] = NULL;
2575 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
2582 int camera_destroy(camera_h camera)
2584 int ret = CAMERA_ERROR_NONE;
2585 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2586 camera_cli_s *pc = (camera_cli_s *)camera;
2588 if (!pc || !pc->cb_info) {
2589 LOGE("NULL handle");
2590 return CAMERA_ERROR_INVALID_PARAMETER;
2595 if (pc->cb_info->is_server_connected)
2596 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2598 LOGW("server disconnected. release resource without send message.");
2600 if (ret == CAMERA_ERROR_NONE) {
2601 _camera_deactivate_idle_event_all(pc->cb_info);
2602 _camera_client_callback_destroy(pc->cb_info);
2609 LOGD("ret : 0x%x", ret);
2614 int camera_start_preview(camera_h camera)
2616 int ret = CAMERA_ERROR_NONE;
2617 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2618 camera_cli_s *pc = (camera_cli_s *)camera;
2620 if (!pc || !pc->cb_info) {
2621 LOGE("NULL handle");
2622 return CAMERA_ERROR_INVALID_PARAMETER;
2625 LOGD("Enter : preview format %d, display type %d",
2626 pc->cb_info->preview_format, pc->cb_info->dp_type);
2628 if (pc->cb_info->preview_format == CAMERA_PIXEL_FORMAT_INVZ &&
2629 pc->cb_info->dp_type != CAMERA_DISPLAY_TYPE_NONE) {
2630 LOGE("CAMERA_DISPLAY_TYPE_NONE[current %d] should be set with INVZ format",
2631 pc->cb_info->dp_type);
2632 return CAMERA_ERROR_INVALID_OPERATION;
2635 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2636 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2637 ret = _camera_start_evas_rendering(camera);
2638 if (ret != CAMERA_ERROR_NONE) {
2639 LOGE("stop preview because of error");
2640 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, pc->cb_info, NULL, 0);
2644 LOGD("ret : 0x%x", ret);
2650 int camera_stop_preview(camera_h camera)
2652 int ret = CAMERA_ERROR_NONE;
2653 camera_cli_s *pc = (camera_cli_s *)camera;
2654 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2655 camera_state_e current_state = CAMERA_STATE_NONE;
2657 if (!pc || !pc->cb_info) {
2658 LOGE("NULL handle");
2659 return CAMERA_ERROR_INVALID_PARAMETER;
2665 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2666 ret = camera_get_state(camera, ¤t_state);
2667 if (ret != CAMERA_ERROR_NONE) {
2668 LOGE("failed to get current state 0x%x", ret);
2672 if (current_state == CAMERA_STATE_PREVIEW) {
2673 ret = _camera_stop_evas_rendering(camera, false);
2674 if (ret != CAMERA_ERROR_NONE)
2679 /* send stop preview message */
2680 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2682 if (ret != CAMERA_ERROR_NONE &&
2683 current_state == CAMERA_STATE_PREVIEW) {
2684 LOGW("restart evas rendering");
2685 _camera_start_evas_rendering(camera);
2688 LOGD("ret : 0x%x", ret);
2694 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2696 int ret = CAMERA_ERROR_NONE;
2697 camera_cli_s *pc = (camera_cli_s *)camera;
2698 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2700 if (!pc || !pc->cb_info) {
2701 LOGE("NULL handle");
2702 return CAMERA_ERROR_INVALID_PARAMETER;
2707 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2708 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2710 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2711 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2713 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2715 LOGD("ret : 0x%x", ret);
2721 bool camera_is_supported_continuous_capture(camera_h camera)
2723 int ret = CAMERA_ERROR_NONE;
2724 camera_cli_s *pc = (camera_cli_s *)camera;
2725 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2727 if (!pc || !pc->cb_info) {
2728 LOGE("NULL handle");
2729 return CAMERA_ERROR_INVALID_PARAMETER;
2734 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2737 LOGE("error is occurred 0x%x", ret);
2741 LOGD("ret : %d", ret);
2747 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)
2749 int ret = CAMERA_ERROR_NONE;
2750 camera_cli_s *pc = (camera_cli_s *)camera;
2751 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2752 camera_msg_param param;
2755 if (!pc || !pc->cb_info) {
2756 LOGE("NULL handle");
2757 return CAMERA_ERROR_INVALID_PARAMETER;
2762 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2763 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2765 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2766 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2768 value = (count << 16) | interval;
2769 CAMERA_MSG_PARAM_SET(param, INT, value);
2771 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2773 LOGD("ret : 0x%x", ret);
2779 int camera_stop_continuous_capture(camera_h camera)
2781 int ret = CAMERA_ERROR_NONE;
2782 camera_cli_s *pc = (camera_cli_s *)camera;
2783 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2785 if (!pc || !pc->cb_info) {
2786 LOGE("NULL handle");
2787 return CAMERA_ERROR_INVALID_PARAMETER;
2792 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2794 LOGD("ret : 0x%x", ret);
2800 bool camera_is_supported_face_detection(camera_h camera)
2802 int ret = CAMERA_ERROR_NONE;
2803 camera_cli_s *pc = (camera_cli_s *)camera;
2804 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2806 if (!pc || !pc->cb_info) {
2807 LOGE("NULL handle");
2808 return CAMERA_ERROR_INVALID_PARAMETER;
2813 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2816 LOGE("error is occurred 0x%x", ret);
2820 LOGD("ret : %d", ret);
2826 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2828 int ret = CAMERA_ERROR_NONE;
2829 camera_cli_s *pc = (camera_cli_s *)camera;
2830 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2832 if (!pc || !pc->cb_info) {
2833 LOGE("NULL handle");
2834 return CAMERA_ERROR_INVALID_PARAMETER;
2839 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2842 LOGE("error is occurred 0x%x", ret);
2846 LOGD("ret : %d", ret);
2852 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2854 int ret = CAMERA_ERROR_NONE;
2855 camera_cli_s *pc = (camera_cli_s *)camera;
2856 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2858 if (!pc || !pc->cb_info) {
2859 LOGE("NULL handle");
2860 return CAMERA_ERROR_INVALID_PARAMETER;
2865 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2868 LOGE("error is occurred 0x%x", ret);
2872 LOGD("ret : %d", ret);
2877 int camera_get_device_count(camera_h camera, int *device_count)
2879 int ret = CAMERA_ERROR_NONE;
2880 camera_cli_s *pc = (camera_cli_s *)camera;
2881 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2883 if (!pc || !pc->cb_info) {
2884 LOGE("NULL handle");
2885 return CAMERA_ERROR_INVALID_PARAMETER;
2890 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2892 if (ret == CAMERA_ERROR_NONE)
2893 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2895 LOGD("ret : 0x%x", ret);
2900 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2902 int ret = CAMERA_ERROR_NONE;
2903 camera_cli_s *pc = (camera_cli_s *)camera;
2904 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2906 if (!pc || !pc->cb_info) {
2907 LOGE("NULL handle");
2908 return CAMERA_ERROR_INVALID_PARAMETER;
2913 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2915 if (ret == CAMERA_ERROR_NONE) {
2916 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2918 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2919 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2921 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2924 LOGD("ret : 0x%x", ret);
2929 int camera_stop_face_detection(camera_h camera)
2931 int ret = CAMERA_ERROR_NONE;
2932 camera_cli_s *pc = (camera_cli_s *)camera;
2933 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
2935 if (!pc || !pc->cb_info) {
2936 LOGE("NULL handle");
2937 return CAMERA_ERROR_INVALID_PARAMETER;
2942 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2944 if (ret == CAMERA_ERROR_NONE) {
2945 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2947 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
2948 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
2950 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2953 LOGD("ret : 0x%x", ret);
2958 int camera_get_state(camera_h camera, camera_state_e *state)
2960 int ret = CAMERA_ERROR_NONE;
2961 camera_cli_s *pc = (camera_cli_s *)camera;
2962 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
2964 if (!pc || !pc->cb_info || !state) {
2965 LOGE("NULL pointer %p %p", pc, state);
2966 return CAMERA_ERROR_INVALID_PARAMETER;
2971 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2973 if (ret == CAMERA_ERROR_NONE)
2974 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
2976 LOGD("ret : 0x%x", ret);
2981 int camera_start_focusing(camera_h camera, bool continuous)
2983 int ret = CAMERA_ERROR_NONE;
2984 camera_cli_s *pc = (camera_cli_s *)camera;
2985 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
2986 camera_msg_param param;
2987 int is_continuous = (int)continuous;
2989 if (!pc || !pc->cb_info) {
2990 LOGE("NULL handle");
2991 return CAMERA_ERROR_INVALID_PARAMETER;
2996 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
2998 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3000 LOGD("ret : 0x%x", ret);
3005 int camera_cancel_focusing(camera_h camera)
3007 int ret = CAMERA_ERROR_NONE;
3008 camera_cli_s *pc = (camera_cli_s *)camera;
3009 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3011 if (!pc || !pc->cb_info) {
3012 LOGE("NULL handle");
3013 return CAMERA_ERROR_INVALID_PARAMETER;
3016 LOGD("Enter, remote_handle : %x", pc->remote_handle);
3018 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3020 LOGD("ret : 0x%x", ret);
3025 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3027 int ret = CAMERA_ERROR_NONE;
3029 camera_cli_s *pc = (camera_cli_s *)camera;
3030 camera_cb_info_s *cb_info = NULL;
3031 camera_state_e current_state = CAMERA_STATE_NONE;
3032 camera_msg_param param0;
3033 camera_msg_param param1;
3034 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3036 if (!pc || !pc->cb_info) {
3037 LOGE("NULL handle");
3038 return CAMERA_ERROR_INVALID_PARAMETER;
3041 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
3042 LOGE("invalid type %d", type);
3043 return CAMERA_ERROR_INVALID_PARAMETER;
3046 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
3047 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
3048 return CAMERA_ERROR_INVALID_PARAMETER;
3051 cb_info = (camera_cb_info_s *)pc->cb_info;
3053 ret = camera_get_state(camera, ¤t_state);
3054 if (ret != CAMERA_ERROR_NONE) {
3055 LOGE("failed to get current state 0x%x", ret);
3059 if (current_state != CAMERA_STATE_CREATED) {
3060 LOGE("INVALID_STATE : current %d", current_state);
3061 return CAMERA_ERROR_INVALID_STATE;
3064 LOGD("Enter - type : %d, display : %p", type, display);
3066 if (type != CAMERA_DISPLAY_TYPE_NONE) {
3067 /* check display interface handle */
3068 if (!cb_info->dp_interface) {
3069 LOGE("display interface not supported");
3070 return CAMERA_ERROR_NOT_SUPPORTED;
3073 ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &parent_id);
3074 if (ret != MM_ERROR_NONE) {
3075 LOGE("[INVALID_OPERATION] set display failed[0x%x]", ret);
3076 return CAMERA_ERROR_INVALID_OPERATION;
3079 if (type == CAMERA_DISPLAY_TYPE_EVAS) {
3081 camera_flip_e flip = CAMERA_FLIP_NONE;
3082 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3083 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3090 camera_get_display_flip(camera, &flip);
3091 camera_get_display_mode(camera, &mode);
3092 camera_get_display_rotation(camera, &rotation);
3093 camera_is_display_visible(camera, &visible);
3094 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3096 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
3097 flip, mode, rotation, visible, x, y, width, height);
3099 ret = mm_display_interface_evas_set_flip(cb_info->dp_interface, flip);
3100 ret |= mm_display_interface_evas_set_mode(cb_info->dp_interface, mode);
3101 ret |= mm_display_interface_evas_set_rotation(cb_info->dp_interface, rotation);
3102 ret |= mm_display_interface_evas_set_visible(cb_info->dp_interface, visible);
3104 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
3105 ret |= mm_display_interface_evas_set_roi_area(cb_info->dp_interface, x, y, width, height);
3110 CAMERA_MSG_PARAM_SET(param0, INT, type);
3111 CAMERA_MSG_PARAM_SET(param1, INT, parent_id);
3113 _camera_msg_send_param2_int(api, cb_info, &ret,
3114 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
3116 if (ret == CAMERA_ERROR_NONE) {
3117 pc->cb_info->dp_type = type;
3119 if (type == CAMERA_DISPLAY_TYPE_EVAS)
3120 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3127 int camera_set_preview_resolution(camera_h camera, int width, int height)
3129 int ret = CAMERA_ERROR_NONE;
3130 camera_state_e current_state = CAMERA_STATE_NONE;
3131 camera_cli_s *pc = (camera_cli_s *)camera;
3132 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3133 camera_msg_param param;
3136 if (!pc || !pc->cb_info) {
3137 LOGE("NULL handle");
3138 return CAMERA_ERROR_INVALID_PARAMETER;
3141 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3142 ret = camera_get_state(camera, ¤t_state);
3143 if (ret != CAMERA_ERROR_NONE) {
3144 LOGE("failed to get current state 0x%x", ret);
3148 if (current_state == CAMERA_STATE_PREVIEW) {
3149 ret = _camera_stop_evas_rendering(camera, true);
3150 if (ret != CAMERA_ERROR_NONE)
3155 value = (width << 16) | height;
3156 CAMERA_MSG_PARAM_SET(param, INT, value);
3158 LOGD("%dx%d -> 0x%x", width, height, value);
3160 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3162 LOGD("ret : 0x%x", ret);
3164 if (current_state == CAMERA_STATE_PREVIEW) {
3165 LOGW("restart evas rendering");
3166 _camera_start_evas_rendering(camera);
3173 int camera_set_capture_resolution(camera_h camera, int width, int height)
3175 int ret = CAMERA_ERROR_NONE;
3176 camera_cli_s *pc = (camera_cli_s *)camera;
3177 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3178 camera_msg_param param;
3181 if (!pc || !pc->cb_info) {
3182 LOGE("NULL handle");
3183 return CAMERA_ERROR_INVALID_PARAMETER;
3188 value = (width << 16) | height;
3189 CAMERA_MSG_PARAM_SET(param, INT, value);
3191 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3193 LOGD("ret : 0x%x", ret);
3199 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3201 int ret = CAMERA_ERROR_NONE;
3202 int set_format = (int)format;
3203 camera_cli_s *pc = (camera_cli_s *)camera;
3204 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3205 camera_msg_param param;
3207 if (!pc || !pc->cb_info) {
3208 LOGE("NULL handle");
3209 return CAMERA_ERROR_INVALID_PARAMETER;
3212 LOGD("Enter - format %d", set_format);
3214 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3216 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3218 LOGD("ret : 0x%x", ret);
3224 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3226 int ret = CAMERA_ERROR_NONE;
3227 int set_format = (int)format;
3228 camera_msg_param param;
3229 camera_cli_s *pc = (camera_cli_s *)camera;
3230 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3232 if (!pc || !pc->cb_info) {
3233 LOGE("NULL handle");
3234 return CAMERA_ERROR_INVALID_PARAMETER;
3237 LOGD("Enter - capture_format %d", set_format);
3239 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3241 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3243 if (ret == CAMERA_ERROR_NONE)
3244 pc->cb_info->preview_format = set_format;
3246 LOGD("ret : 0x%x", ret);
3252 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3254 int ret = CAMERA_ERROR_NONE;
3255 camera_cli_s *pc = (camera_cli_s *)camera;
3256 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3258 if (!pc || !pc->cb_info || !width || !height) {
3259 LOGE("NULL pointer %p %p %p", pc, width, height);
3260 return CAMERA_ERROR_INVALID_PARAMETER;
3265 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3267 if (ret == CAMERA_ERROR_NONE) {
3268 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3269 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3272 LOGD("ret : 0x%x", ret);
3278 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3280 int ret = CAMERA_ERROR_NONE;
3281 int set_rotation = (int)rotation;
3282 camera_cli_s *pc = (camera_cli_s *)camera;
3283 camera_msg_param param;
3285 if (!pc || !pc->cb_info) {
3286 LOGE("NULL handle");
3287 return CAMERA_ERROR_INVALID_PARAMETER;
3290 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3291 ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
3292 if (ret != MM_ERROR_NONE) {
3293 LOGE("failed to set rotation for evas surface 0x%x", ret);
3294 return CAMERA_ERROR_INVALID_OPERATION;
3298 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3300 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3306 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3308 int ret = CAMERA_ERROR_NONE;
3309 camera_cli_s *pc = (camera_cli_s *)camera;
3311 if (!pc || !pc->cb_info || !rotation) {
3312 LOGE("NULL pointer %p %p", pc, rotation);
3313 return CAMERA_ERROR_INVALID_PARAMETER;
3316 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3318 if (ret == CAMERA_ERROR_NONE)
3319 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3325 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3327 int ret = CAMERA_ERROR_NONE;
3328 int set_flip = (int)flip;
3329 camera_cli_s *pc = (camera_cli_s *)camera;
3330 camera_msg_param param;
3332 if (!pc || !pc->cb_info) {
3333 LOGE("NULL handle");
3334 return CAMERA_ERROR_INVALID_PARAMETER;
3337 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3338 ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
3339 if (ret != MM_ERROR_NONE) {
3340 LOGE("failed to set flip for evas surface 0x%x", ret);
3341 return CAMERA_ERROR_INVALID_OPERATION;
3345 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3347 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3353 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3355 int ret = CAMERA_ERROR_NONE;
3356 camera_cli_s *pc = (camera_cli_s *)camera;
3358 if (!pc || !pc->cb_info || !flip) {
3359 LOGE("NULL pointer %p %p", pc, flip);
3360 return CAMERA_ERROR_INVALID_PARAMETER;
3363 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3365 if (ret == CAMERA_ERROR_NONE)
3366 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3372 int camera_set_display_visible(camera_h camera, bool visible)
3374 int ret = CAMERA_ERROR_NONE;
3375 int set_visible = (int)visible;
3376 camera_cli_s *pc = (camera_cli_s *)camera;
3377 camera_msg_param param;
3379 if (!pc || !pc->cb_info) {
3380 LOGE("NULL handle");
3381 return CAMERA_ERROR_INVALID_PARAMETER;
3384 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3385 ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
3386 if (ret != MM_ERROR_NONE) {
3387 LOGE("failed to set visible for evas surface 0x%x", ret);
3388 return CAMERA_ERROR_INVALID_OPERATION;
3392 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3394 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3400 int camera_is_display_visible(camera_h camera, bool *visible)
3402 int ret = CAMERA_ERROR_NONE;
3403 camera_cli_s *pc = (camera_cli_s *)camera;
3405 if (!pc || !pc->cb_info || !visible) {
3406 LOGE("NULL pointer %p %p", pc, visible);
3407 return CAMERA_ERROR_INVALID_PARAMETER;
3410 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3412 if (ret == CAMERA_ERROR_NONE)
3413 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3419 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3421 int ret = CAMERA_ERROR_NONE;
3422 int set_mode = (int)mode;
3423 camera_cli_s *pc = (camera_cli_s *)camera;
3424 camera_msg_param param;
3426 if (!pc || !pc->cb_info) {
3427 LOGE("NULL handle");
3428 return CAMERA_ERROR_INVALID_PARAMETER;
3431 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3432 ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
3433 if (ret != MM_ERROR_NONE) {
3434 LOGE("failed to set geometry for evas surface 0x%x", ret);
3435 return CAMERA_ERROR_INVALID_OPERATION;
3439 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3441 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3447 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3449 int ret = CAMERA_ERROR_NONE;
3450 camera_cli_s *pc = (camera_cli_s *)camera;
3452 if (!pc || !pc->cb_info || !mode) {
3453 LOGE("NULL pointer %p %p", pc, mode);
3454 return CAMERA_ERROR_INVALID_PARAMETER;
3457 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3459 if (ret == CAMERA_ERROR_NONE)
3460 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3466 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3468 int ret = CAMERA_ERROR_NONE;
3469 int set_hint = (int)hint;
3470 camera_cli_s *pc = (camera_cli_s *)camera;
3471 camera_msg_param param;
3473 if (!pc || !pc->cb_info) {
3474 LOGE("NULL handle");
3475 return CAMERA_ERROR_INVALID_PARAMETER;
3478 LOGD("Enter - hint %d", set_hint);
3480 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3482 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3488 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3490 int ret = CAMERA_ERROR_NONE;
3491 camera_cli_s *pc = (camera_cli_s *)camera;
3492 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3494 if (!pc || !pc->cb_info || !hint) {
3495 LOGE("NULL pointer %p %p", pc, hint);
3496 return CAMERA_ERROR_INVALID_PARAMETER;
3499 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3501 if (ret == CAMERA_ERROR_NONE) {
3502 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3503 LOGD("display reuse hint %d", *hint);
3510 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3512 int ret = CAMERA_ERROR_NONE;
3513 camera_cli_s *pc = (camera_cli_s *)camera;
3514 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3516 if (!pc || !pc->cb_info || !width || !height) {
3517 LOGE("NULL pointer %p %p %p", pc, width, height);
3518 return CAMERA_ERROR_INVALID_PARAMETER;
3523 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3525 if (ret == CAMERA_ERROR_NONE) {
3526 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3527 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3530 LOGD("ret : 0x%x", ret);
3536 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3538 int ret = CAMERA_ERROR_NONE;
3539 camera_cli_s *pc = (camera_cli_s *)camera;
3540 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3542 if (!pc || !pc->cb_info || !format) {
3543 LOGE("NULL pointer %p %p", pc, format);
3544 return CAMERA_ERROR_INVALID_PARAMETER;
3549 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3551 if (ret == CAMERA_ERROR_NONE)
3552 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3554 LOGD("ret : 0x%x", ret);
3560 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3562 int ret = CAMERA_ERROR_NONE;
3563 camera_cli_s *pc = (camera_cli_s *)camera;
3564 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3566 if (!pc || !pc->cb_info || !format) {
3567 LOGE("NULL pointer %p %p", pc, format);
3568 return CAMERA_ERROR_INVALID_PARAMETER;
3573 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3575 if (ret == CAMERA_ERROR_NONE)
3576 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3578 LOGD("ret : 0x%x", ret);
3584 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3586 int ret = CAMERA_ERROR_NONE;
3587 camera_cli_s *pc = (camera_cli_s *)camera;
3588 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3590 if (!pc || !pc->cb_info || !facing_direction) {
3591 LOGE("NULL pointer %p %p", pc, facing_direction);
3592 return CAMERA_ERROR_INVALID_PARAMETER;
3597 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3599 if (ret == CAMERA_ERROR_NONE)
3600 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3602 LOGD("ret : 0x%x", ret);
3608 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3610 int ret = CAMERA_ERROR_NONE;
3611 camera_cli_s *pc = (camera_cli_s *)camera;
3612 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3614 if (!pc || !pc->cb_info || !callback) {
3615 LOGE("NULL pointer %p %p", pc, callback);
3616 return CAMERA_ERROR_INVALID_PARAMETER;
3621 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3623 if (ret == CAMERA_ERROR_NONE) {
3624 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3626 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3627 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3629 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3631 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3634 LOGD("ret : 0x%x", ret);
3640 int camera_unset_preview_cb(camera_h camera)
3642 int ret = CAMERA_ERROR_NONE;
3643 camera_cli_s *pc = (camera_cli_s *)camera;
3644 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3646 if (!pc || !pc->cb_info) {
3647 LOGE("NULL handle");
3648 return CAMERA_ERROR_INVALID_PARAMETER;
3653 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3655 if (ret == CAMERA_ERROR_NONE) {
3656 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3658 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3659 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3661 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3663 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3666 LOGD("ret : 0x%x", ret);
3672 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3674 int ret = CAMERA_ERROR_NONE;
3675 camera_cli_s *pc = (camera_cli_s *)camera;
3676 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3678 if (!pc || !pc->cb_info) {
3679 LOGE("NULL handle");
3680 return CAMERA_ERROR_INVALID_PARAMETER;
3683 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3684 LOGE("NOT SUPPORTED");
3685 return CAMERA_ERROR_NOT_SUPPORTED;
3688 if (callback == NULL) {
3689 LOGE("NULL callback");
3690 return CAMERA_ERROR_INVALID_PARAMETER;
3695 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3697 if (ret == CAMERA_ERROR_NONE) {
3698 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3700 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3701 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3703 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3706 LOGD("ret : 0x%x", ret);
3712 int camera_unset_media_packet_preview_cb(camera_h camera)
3714 int ret = CAMERA_ERROR_NONE;
3715 camera_cli_s *pc = (camera_cli_s *)camera;
3716 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3718 if (!pc || !pc->cb_info) {
3719 LOGE("NULL handle");
3720 return CAMERA_ERROR_INVALID_PARAMETER;
3725 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3727 if (ret == CAMERA_ERROR_NONE) {
3728 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3730 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3731 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3733 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3736 LOGD("ret : 0x%x", ret);
3742 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3744 int ret = CAMERA_ERROR_NONE;
3745 camera_cli_s *pc = (camera_cli_s *)camera;
3746 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3748 if (!pc || !pc->cb_info || !callback) {
3749 LOGE("NULL pointer %p %p", pc, callback);
3750 return CAMERA_ERROR_INVALID_PARAMETER;
3755 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3757 if (ret == CAMERA_ERROR_NONE) {
3758 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3760 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3761 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3763 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3766 LOGD("ret : 0x%x", ret);
3772 int camera_unset_state_changed_cb(camera_h camera)
3774 int ret = CAMERA_ERROR_NONE;
3775 camera_cli_s *pc = (camera_cli_s *)camera;
3776 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3778 if (!pc || !pc->cb_info) {
3779 LOGE("NULL handle");
3780 return CAMERA_ERROR_INVALID_PARAMETER;
3785 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3787 if (ret == CAMERA_ERROR_NONE) {
3788 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3790 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3791 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3793 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3796 LOGD("ret : 0x%x", ret);
3802 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3804 int ret = CAMERA_ERROR_NONE;
3805 camera_cli_s *pc = (camera_cli_s *)camera;
3806 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3808 if (!pc || !pc->cb_info || !callback) {
3809 LOGE("NULL pointer %p %p", pc, callback);
3810 return CAMERA_ERROR_INVALID_PARAMETER;
3815 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3817 if (ret == CAMERA_ERROR_NONE) {
3818 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3820 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3821 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3823 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3826 LOGD("ret : 0x%x", ret);
3832 int camera_unset_interrupted_cb(camera_h camera)
3834 int ret = CAMERA_ERROR_NONE;
3835 camera_cli_s *pc = (camera_cli_s *)camera;
3836 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3838 if (!pc || !pc->cb_info) {
3839 LOGE("NULL handle");
3840 return CAMERA_ERROR_INVALID_PARAMETER;
3845 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3847 if (ret == CAMERA_ERROR_NONE) {
3848 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3850 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3851 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3853 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3856 LOGD("ret : 0x%x", ret);
3862 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
3864 int ret = CAMERA_ERROR_NONE;
3865 camera_cli_s *pc = (camera_cli_s *)camera;
3866 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
3868 if (!pc || !pc->cb_info || !callback) {
3869 LOGE("NULL pointer %p %p", pc, callback);
3870 return CAMERA_ERROR_INVALID_PARAMETER;
3875 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3877 if (ret == CAMERA_ERROR_NONE) {
3878 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3880 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
3881 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
3883 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3886 LOGD("ret : 0x%x", ret);
3892 int camera_unset_interrupt_started_cb(camera_h camera)
3894 int ret = CAMERA_ERROR_NONE;
3895 camera_cli_s *pc = (camera_cli_s *)camera;
3896 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
3898 if (!pc || !pc->cb_info) {
3899 LOGE("NULL handle");
3900 return CAMERA_ERROR_INVALID_PARAMETER;
3905 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3907 if (ret == CAMERA_ERROR_NONE) {
3908 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3910 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3911 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3913 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3916 LOGD("ret : 0x%x", ret);
3922 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
3924 int ret = CAMERA_ERROR_NONE;
3925 camera_cli_s *pc = (camera_cli_s *)camera;
3926 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3928 if (!pc || !pc->cb_info || !callback) {
3929 LOGE("NULL pointer %p %p", pc, callback);
3930 return CAMERA_ERROR_INVALID_PARAMETER;
3935 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3937 if (ret == CAMERA_ERROR_NONE) {
3938 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3940 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3941 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3943 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3946 LOGD("ret : 0x%x", ret);
3952 int camera_unset_focus_changed_cb(camera_h camera)
3954 int ret = CAMERA_ERROR_NONE;
3955 camera_cli_s *pc = (camera_cli_s *)camera;
3956 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
3958 if (!pc || !pc->cb_info) {
3959 LOGE("NULL handle");
3960 return CAMERA_ERROR_INVALID_PARAMETER;
3965 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3967 if (ret == CAMERA_ERROR_NONE) {
3968 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3970 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3971 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3973 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3976 LOGD("ret : 0x%x", ret);
3982 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
3984 int ret = CAMERA_ERROR_NONE;
3985 camera_cli_s *pc = (camera_cli_s *)camera;
3986 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
3988 if (!pc || !pc->cb_info || !callback) {
3989 LOGE("NULL pointer %p %p", pc, callback);
3990 return CAMERA_ERROR_INVALID_PARAMETER;
3995 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3997 if (ret == CAMERA_ERROR_NONE) {
3998 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4000 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
4001 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
4003 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4006 LOGD("ret : 0x%x", ret);
4012 int camera_unset_error_cb(camera_h camera)
4014 int ret = CAMERA_ERROR_NONE;
4015 camera_cli_s *pc = (camera_cli_s *)camera;
4016 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4018 if (!pc || !pc->cb_info) {
4019 LOGE("NULL handle");
4020 return CAMERA_ERROR_INVALID_PARAMETER;
4025 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4027 if (ret == CAMERA_ERROR_NONE) {
4028 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4030 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4031 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4033 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4036 LOGD("ret : 0x%x", ret);
4042 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4044 int ret = CAMERA_ERROR_NONE;
4045 camera_cli_s *pc = (camera_cli_s *)camera;
4046 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4048 if (!pc || !pc->cb_info || !foreach_cb) {
4049 LOGE("NULL pointer %p %p", pc, foreach_cb);
4050 return CAMERA_ERROR_INVALID_PARAMETER;
4055 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4056 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4058 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4060 LOGD("ret : 0x%x", ret);
4066 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4068 int ret = CAMERA_ERROR_NONE;
4069 camera_cli_s *pc = (camera_cli_s *)camera;
4070 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4072 if (!pc || !pc->cb_info || !foreach_cb) {
4073 LOGE("NULL pointer %p %p", pc, foreach_cb);
4074 return CAMERA_ERROR_INVALID_PARAMETER;
4079 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4080 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4082 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4084 LOGD("ret : 0x%x", ret);
4090 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4092 int ret = CAMERA_ERROR_NONE;
4093 camera_cli_s *pc = (camera_cli_s *)camera;
4094 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4096 if (!pc || !pc->cb_info || !foreach_cb) {
4097 LOGE("NULL pointer %p %p", pc, foreach_cb);
4098 return CAMERA_ERROR_INVALID_PARAMETER;
4103 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4104 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4106 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4108 LOGD("ret : 0x%x", ret);
4114 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4116 int ret = CAMERA_ERROR_NONE;
4117 camera_cli_s *pc = (camera_cli_s *)camera;
4118 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4120 if (!pc || !pc->cb_info || !foreach_cb) {
4121 LOGE("NULL pointer %p %p", pc, foreach_cb);
4122 return CAMERA_ERROR_INVALID_PARAMETER;
4127 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4128 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4130 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4132 LOGD("ret : 0x%x", ret);
4138 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4140 int ret = CAMERA_ERROR_NONE;
4141 camera_cli_s *pc = (camera_cli_s *)camera;
4142 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4144 if (!pc || !pc->cb_info || !width || !height) {
4145 LOGE("NULL pointer %p %p %p", pc, width, height);
4146 return CAMERA_ERROR_INVALID_PARAMETER;
4150 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4152 if (ret == CAMERA_ERROR_NONE) {
4153 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4154 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4157 LOGD("ret : 0x%x", ret);
4163 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4165 int ret = CAMERA_ERROR_NONE;
4166 camera_cli_s *pc = (camera_cli_s *)camera;
4167 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4169 if (!pc || !pc->cb_info || !angle) {
4170 LOGE("NULL pointer %p %p", pc, angle);
4171 return CAMERA_ERROR_INVALID_PARAMETER;
4176 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4178 if (ret == CAMERA_ERROR_NONE)
4179 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4181 LOGD("ret : 0x%x", ret);
4187 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4189 int ret = CAMERA_ERROR_NONE;
4190 camera_cli_s *pc = (camera_cli_s *)camera;
4191 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4192 camera_msg_param param;
4193 int set_mode = (int)mode;
4195 if (!pc || !pc->cb_info) {
4196 LOGE("NULL handle");
4197 return CAMERA_ERROR_INVALID_PARAMETER;
4202 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4204 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4206 LOGD("ret : 0x%x", ret);
4212 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4214 int ret = CAMERA_ERROR_NONE;
4215 camera_cli_s *pc = (camera_cli_s *)camera;
4216 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4218 if (!pc || !pc->cb_info || !mode) {
4219 LOGE("NULL pointer %p %p", pc, mode);
4220 return CAMERA_ERROR_INVALID_PARAMETER;
4225 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4227 if (ret == CAMERA_ERROR_NONE)
4228 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4230 LOGD("ret : 0x%x", ret);
4236 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4238 int ret = CAMERA_ERROR_NONE;
4239 camera_cli_s *pc = (camera_cli_s *)camera;
4240 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4242 if (!pc || !pc->cb_info || !foreach_cb) {
4243 LOGE("NULL pointer %p %p", pc, foreach_cb);
4244 return CAMERA_ERROR_INVALID_PARAMETER;
4249 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4250 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4252 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4254 LOGD("Finish, return :%x", ret);
4260 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4262 int ret = CAMERA_ERROR_NONE;
4263 camera_cli_s *pc = (camera_cli_s *)camera;
4264 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4265 camera_msg_param param;
4266 int set_fps = (int)fps;
4268 if (!pc || !pc->cb_info) {
4269 LOGE("NULL handle");
4270 return CAMERA_ERROR_INVALID_PARAMETER;
4275 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4277 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4279 LOGD("ret : 0x%x", ret);
4285 int camera_attr_set_image_quality(camera_h camera, int quality)
4287 int ret = CAMERA_ERROR_NONE;
4288 camera_cli_s *pc = (camera_cli_s *)camera;
4289 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4290 camera_msg_param param;
4292 if (!pc || !pc->cb_info) {
4293 LOGE("NULL handle");
4294 return CAMERA_ERROR_INVALID_PARAMETER;
4299 CAMERA_MSG_PARAM_SET(param, INT, quality);
4301 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4303 LOGD("ret : 0x%x", ret);
4309 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4311 int ret = CAMERA_ERROR_NONE;
4312 camera_cli_s *pc = (camera_cli_s *)camera;
4313 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4315 if (!pc || !pc->cb_info || !fps) {
4316 LOGE("NULL pointer %p %p", pc, fps);
4317 return CAMERA_ERROR_INVALID_PARAMETER;
4322 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4324 if (ret == CAMERA_ERROR_NONE)
4325 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4327 LOGD("ret : 0x%x", ret);
4333 int camera_attr_get_image_quality(camera_h camera, int *quality)
4335 int ret = CAMERA_ERROR_NONE;
4336 camera_cli_s *pc = (camera_cli_s *)camera;
4337 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4339 if (!pc || !pc->cb_info || !quality) {
4340 LOGE("NULL pointer %p %p", pc, quality);
4341 return CAMERA_ERROR_INVALID_PARAMETER;
4346 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4348 if (ret == CAMERA_ERROR_NONE)
4349 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4351 LOGD("ret : 0x%x", ret);
4357 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4359 int ret = CAMERA_ERROR_NONE;
4360 camera_cli_s *pc = (camera_cli_s *)camera;
4361 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4363 if (!pc || !pc->cb_info || !bitrate) {
4364 LOGE("NULL pointer %p %p", pc, bitrate);
4365 return CAMERA_ERROR_INVALID_PARAMETER;
4370 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4372 if (ret == CAMERA_ERROR_NONE)
4373 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4375 LOGD("ret : 0x%x", ret);
4381 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4383 int ret = CAMERA_ERROR_NONE;
4384 camera_cli_s *pc = (camera_cli_s *)camera;
4385 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4386 camera_msg_param param;
4387 int set_bitrate = bitrate;
4389 if (!pc || !pc->cb_info) {
4390 LOGE("NULL handle");
4391 return CAMERA_ERROR_INVALID_PARAMETER;
4396 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4398 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4400 LOGD("ret : 0x%x", ret);
4406 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4408 int ret = CAMERA_ERROR_NONE;
4409 camera_cli_s *pc = (camera_cli_s *)camera;
4410 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4412 if (!pc || !pc->cb_info || !interval) {
4413 LOGE("NULL pointer %p %p", pc, interval);
4414 return CAMERA_ERROR_INVALID_PARAMETER;
4419 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4421 if (ret == CAMERA_ERROR_NONE)
4422 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4424 LOGD("ret : 0x%x", ret);
4430 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4432 int ret = CAMERA_ERROR_NONE;
4433 camera_cli_s *pc = (camera_cli_s *)camera;
4434 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4435 camera_msg_param param;
4436 int set_gop_interval = interval;
4438 if (!pc || !pc->cb_info) {
4439 LOGE("NULL handle");
4440 return CAMERA_ERROR_INVALID_PARAMETER;
4445 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4447 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4449 LOGD("ret : 0x%x", ret);
4455 int camera_attr_set_zoom(camera_h camera, int zoom)
4457 int ret = CAMERA_ERROR_NONE;
4458 camera_cli_s *pc = (camera_cli_s *)camera;
4459 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4460 camera_msg_param param;
4462 if (!pc || !pc->cb_info) {
4463 LOGE("NULL handle");
4464 return CAMERA_ERROR_INVALID_PARAMETER;
4467 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4469 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4471 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4473 LOGD("ret : 0x%x", ret);
4479 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4481 int ret = CAMERA_ERROR_NONE;
4482 camera_cli_s *pc = (camera_cli_s *)camera;
4483 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4484 camera_msg_param param;
4485 int set_mode = (int)mode;
4487 if (!pc || !pc->cb_info) {
4488 LOGE("NULL handle");
4489 return CAMERA_ERROR_INVALID_PARAMETER;
4492 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4494 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4496 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4502 int camera_attr_set_af_area(camera_h camera, int x, int y)
4504 int ret = CAMERA_ERROR_NONE;
4505 camera_cli_s *pc = (camera_cli_s *)camera;
4506 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4507 camera_msg_param param;
4510 if (!pc || !pc->cb_info) {
4511 LOGE("NULL handle");
4512 return CAMERA_ERROR_INVALID_PARAMETER;
4515 LOGD("Enter - %d,%d", x, y);
4517 value = (x << 16) | y;
4518 CAMERA_MSG_PARAM_SET(param, INT, value);
4520 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4522 LOGD("ret : 0x%x", ret);
4528 int camera_attr_clear_af_area(camera_h camera)
4530 int ret = CAMERA_ERROR_NONE;
4531 camera_cli_s *pc = (camera_cli_s *)camera;
4532 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4534 if (!pc || !pc->cb_info) {
4535 LOGE("NULL handle");
4536 return CAMERA_ERROR_INVALID_PARAMETER;
4541 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4543 LOGD("ret : 0x%x", ret);
4549 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4551 int ret = CAMERA_ERROR_NONE;
4552 camera_cli_s *pc = (camera_cli_s *)camera;
4553 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4554 camera_msg_param param;
4555 int set_mode = (int)mode;
4557 if (!pc || !pc->cb_info) {
4558 LOGE("NULL handle");
4559 return CAMERA_ERROR_INVALID_PARAMETER;
4564 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4566 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4568 LOGD("ret : 0x%x", ret);
4574 int camera_attr_set_exposure(camera_h camera, int value)
4576 int ret = CAMERA_ERROR_NONE;
4577 camera_cli_s *pc = (camera_cli_s *)camera;
4578 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4579 camera_msg_param param;
4581 if (!pc || !pc->cb_info) {
4582 LOGE("NULL handle");
4583 return CAMERA_ERROR_INVALID_PARAMETER;
4588 CAMERA_MSG_PARAM_SET(param, INT, value);
4590 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4592 LOGD("ret : 0x%x", ret);
4598 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4600 int ret = CAMERA_ERROR_NONE;
4601 camera_cli_s *pc = (camera_cli_s *)camera;
4602 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4603 camera_msg_param param;
4604 int set_iso = (int)iso;
4606 if (!pc || !pc->cb_info) {
4607 LOGE("NULL handle");
4608 return CAMERA_ERROR_INVALID_PARAMETER;
4613 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4615 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4617 LOGD("ret : 0x%x", ret);
4623 int camera_attr_set_brightness(camera_h camera, int level)
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_BRIGHTNESS;
4628 camera_msg_param param;
4630 if (!pc || !pc->cb_info) {
4631 LOGE("NULL handle");
4632 return CAMERA_ERROR_INVALID_PARAMETER;
4637 CAMERA_MSG_PARAM_SET(param, INT, level);
4639 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4641 LOGD("ret : 0x%x", ret);
4647 int camera_attr_set_contrast(camera_h camera, int level)
4649 int ret = CAMERA_ERROR_NONE;
4650 camera_cli_s *pc = (camera_cli_s *)camera;
4651 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4652 camera_msg_param param;
4654 if (!pc || !pc->cb_info) {
4655 LOGE("NULL handle");
4656 return CAMERA_ERROR_INVALID_PARAMETER;
4661 CAMERA_MSG_PARAM_SET(param, INT, level);
4663 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4665 LOGD("ret : 0x%x", ret);
4671 int camera_attr_set_hue(camera_h camera, int level)
4673 int ret = CAMERA_ERROR_NONE;
4674 camera_cli_s *pc = (camera_cli_s *)camera;
4675 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HUE;
4676 camera_msg_param param;
4678 if (!pc || !pc->cb_info) {
4679 LOGE("NULL handle");
4680 return CAMERA_ERROR_INVALID_PARAMETER;
4685 CAMERA_MSG_PARAM_SET(param, INT, level);
4687 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4689 LOGD("ret : 0x%x", ret);
4695 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4697 int ret = CAMERA_ERROR_NONE;
4698 camera_cli_s *pc = (camera_cli_s *)camera;
4699 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4700 camera_msg_param param;
4701 int set_whitebalance = (int)wb;
4703 if (!pc || !pc->cb_info) {
4704 LOGE("NULL handle");
4705 return CAMERA_ERROR_INVALID_PARAMETER;
4710 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4712 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4714 LOGD("ret : 0x%x", ret);
4720 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4722 int ret = CAMERA_ERROR_NONE;
4723 camera_cli_s *pc = (camera_cli_s *)camera;
4724 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4725 camera_msg_param param;
4726 int set_effect = (int)effect;
4728 if (!pc || !pc->cb_info) {
4729 LOGE("NULL handle");
4730 return CAMERA_ERROR_INVALID_PARAMETER;
4735 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4737 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4739 LOGD("ret : 0x%x", ret);
4745 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4747 int ret = CAMERA_ERROR_NONE;
4748 camera_cli_s *pc = (camera_cli_s *)camera;
4749 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4750 camera_msg_param param;
4751 int set_mode = (int)mode;
4753 if (!pc || !pc->cb_info) {
4754 LOGE("NULL handle");
4755 return CAMERA_ERROR_INVALID_PARAMETER;
4760 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4762 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4764 LOGD("ret : 0x%x", ret);
4770 int camera_attr_enable_tag(camera_h camera, bool enable)
4772 int ret = CAMERA_ERROR_NONE;
4773 camera_cli_s *pc = (camera_cli_s *)camera;
4774 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4775 camera_msg_param param;
4776 int set_enable = (int)enable;
4778 if (!pc || !pc->cb_info) {
4779 LOGE("NULL handle");
4780 return CAMERA_ERROR_INVALID_PARAMETER;
4785 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4787 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4789 LOGD("ret : 0x%x", ret);
4795 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4797 int ret = CAMERA_ERROR_NONE;
4798 camera_cli_s *pc = (camera_cli_s *)camera;
4799 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4800 camera_msg_param param;
4802 if (!pc || !pc->cb_info || !description) {
4803 LOGE("NULL pointer %p %p", pc, description);
4804 return CAMERA_ERROR_INVALID_PARAMETER;
4809 CAMERA_MSG_PARAM_SET(param, STRING, description);
4811 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4813 LOGD("ret : 0x%x", ret);
4819 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4821 int ret = CAMERA_ERROR_NONE;
4822 camera_cli_s *pc = (camera_cli_s *)camera;
4823 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4824 camera_msg_param param;
4825 int set_orientation = (int)orientation;
4827 if (!pc || !pc->cb_info) {
4828 LOGE("NULL handle");
4829 return CAMERA_ERROR_INVALID_PARAMETER;
4834 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4836 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4838 LOGD("ret : 0x%x", ret);
4844 int camera_attr_set_tag_software(camera_h camera, const char *software)
4846 int ret = CAMERA_ERROR_NONE;
4847 camera_cli_s *pc = (camera_cli_s *)camera;
4848 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4849 camera_msg_param param;
4851 if (!pc || !pc->cb_info || !software) {
4852 LOGE("NULL pointer %p %p", pc, software);
4853 return CAMERA_ERROR_INVALID_PARAMETER;
4856 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4858 CAMERA_MSG_PARAM_SET(param, STRING, software);
4860 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4862 LOGD("ret : 0x%x", ret);
4868 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4870 int ret = CAMERA_ERROR_NONE;
4871 camera_cli_s *pc = (camera_cli_s *)camera;
4872 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4873 double set_geotag[3] = {latitude, longitude, altitude};
4878 if (!pc || !pc->cb_info) {
4879 LOGE("NULL handle");
4880 return CAMERA_ERROR_INVALID_PARAMETER;
4885 length = sizeof(set_geotag) / sizeof(int) + \
4886 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4888 msg = muse_core_msg_new(api,
4889 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4892 LOGE("msg creation failed: api %d", api);
4893 return CAMERA_ERROR_OUT_OF_MEMORY;
4896 if (pc->cb_info->is_server_connected) {
4897 __camera_update_api_waiting(pc->cb_info, api, 1);
4899 g_mutex_lock(&pc->cb_info->fd_lock);
4900 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
4901 g_mutex_unlock(&pc->cb_info->fd_lock);
4905 LOGE("message send failed");
4906 ret = CAMERA_ERROR_INVALID_OPERATION;
4908 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
4911 __camera_update_api_waiting(pc->cb_info, api, -1);
4913 muse_core_msg_free(msg);
4915 LOGD("ret : 0x%x", ret);
4921 int camera_attr_remove_geotag(camera_h camera)
4923 int ret = CAMERA_ERROR_NONE;
4924 camera_cli_s *pc = (camera_cli_s *)camera;
4925 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4927 if (!pc || !pc->cb_info) {
4928 LOGE("NULL handle");
4929 return CAMERA_ERROR_INVALID_PARAMETER;
4934 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4936 LOGD("ret : 0x%x", ret);
4942 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4944 int ret = CAMERA_ERROR_NONE;
4945 camera_cli_s *pc = (camera_cli_s *)camera;
4946 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
4947 camera_msg_param param;
4948 int set_mode = (int)mode;
4950 if (!pc || !pc->cb_info) {
4951 LOGE("NULL handle");
4952 return CAMERA_ERROR_INVALID_PARAMETER;
4957 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4959 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4961 LOGD("ret : 0x%x", ret);
4967 int camera_attr_get_zoom(camera_h camera, int *zoom)
4969 int ret = CAMERA_ERROR_NONE;
4970 camera_cli_s *pc = (camera_cli_s *)camera;
4971 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4973 if (!pc || !pc->cb_info || !zoom) {
4974 LOGE("NULL pointer %p %p", pc, zoom);
4975 return CAMERA_ERROR_INVALID_PARAMETER;
4980 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4982 if (ret == CAMERA_ERROR_NONE)
4983 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
4985 LOGD("ret : 0x%x", ret);
4991 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
4993 int ret = CAMERA_ERROR_NONE;
4994 camera_cli_s *pc = (camera_cli_s *)camera;
4995 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
4997 if (!pc || !pc->cb_info || !min || !max) {
4998 LOGE("NULL pointer %p %p %p", pc, min, max);
4999 return CAMERA_ERROR_INVALID_PARAMETER;
5004 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5006 if (ret == CAMERA_ERROR_NONE) {
5007 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
5008 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
5011 LOGD("ret : 0x%x", ret);
5017 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
5019 int ret = CAMERA_ERROR_NONE;
5020 camera_cli_s *pc = (camera_cli_s *)camera;
5021 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
5023 if (!pc || !pc->cb_info || !mode) {
5024 LOGE("NULL pointer %p %p", pc, mode);
5025 return CAMERA_ERROR_INVALID_PARAMETER;
5030 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5032 if (ret == CAMERA_ERROR_NONE)
5033 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5035 LOGD("ret : 0x%x", ret);
5041 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5043 int ret = CAMERA_ERROR_NONE;
5044 camera_cli_s *pc = (camera_cli_s *)camera;
5045 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5047 if (!pc || !pc->cb_info || !mode) {
5048 LOGE("NULL pointer %p %p", pc, mode);
5049 return CAMERA_ERROR_INVALID_PARAMETER;
5054 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5056 if (ret == CAMERA_ERROR_NONE)
5057 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5059 LOGD("ret : 0x%x", ret);
5065 int camera_attr_get_exposure(camera_h camera, int *value)
5067 int ret = CAMERA_ERROR_NONE;
5068 camera_cli_s *pc = (camera_cli_s *)camera;
5069 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5071 if (!pc || !pc->cb_info || !value) {
5072 LOGE("NULL pointer %p %p", pc, value);
5073 return CAMERA_ERROR_INVALID_PARAMETER;
5078 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5080 if (ret == CAMERA_ERROR_NONE)
5081 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5083 LOGD("ret : 0x%x", ret);
5089 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5091 int ret = CAMERA_ERROR_NONE;
5092 camera_cli_s *pc = (camera_cli_s *)camera;
5093 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5095 if (!pc || !pc->cb_info || !min || !max) {
5096 LOGE("NULL pointer %p %p %p", pc, min, max);
5097 return CAMERA_ERROR_INVALID_PARAMETER;
5102 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5104 if (ret == CAMERA_ERROR_NONE) {
5105 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5106 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5109 LOGD("ret : 0x%x", ret);
5115 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5117 int ret = CAMERA_ERROR_NONE;
5118 camera_cli_s *pc = (camera_cli_s *)camera;
5119 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5121 if (!pc || !pc->cb_info || !iso) {
5122 LOGE("NULL pointer %p %p", pc, iso);
5123 return CAMERA_ERROR_INVALID_PARAMETER;
5128 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5130 if (ret == CAMERA_ERROR_NONE)
5131 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5133 LOGD("ret : 0x%x", ret);
5139 int camera_attr_get_brightness(camera_h camera, int *level)
5141 int ret = CAMERA_ERROR_NONE;
5142 camera_cli_s *pc = (camera_cli_s *)camera;
5143 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5145 if (!pc || !pc->cb_info || !level) {
5146 LOGE("NULL pointer %p %p", pc, level);
5147 return CAMERA_ERROR_INVALID_PARAMETER;
5152 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5154 if (ret == CAMERA_ERROR_NONE)
5155 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5157 LOGD("ret : 0x%x", ret);
5163 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5165 int ret = CAMERA_ERROR_NONE;
5166 camera_cli_s *pc = (camera_cli_s *)camera;
5167 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5169 if (!pc || !pc->cb_info || !min || !max) {
5170 LOGE("NULL pointer %p %p %p", pc, min, max);
5171 return CAMERA_ERROR_INVALID_PARAMETER;
5176 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5178 if (ret == CAMERA_ERROR_NONE) {
5179 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5180 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5183 LOGD("ret : 0x%x", ret);
5189 int camera_attr_get_contrast(camera_h camera, int *level)
5191 int ret = CAMERA_ERROR_NONE;
5192 camera_cli_s *pc = (camera_cli_s *)camera;
5193 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5195 if (!pc || !pc->cb_info || !level) {
5196 LOGE("NULL pointer %p %p", pc, level);
5197 return CAMERA_ERROR_INVALID_PARAMETER;
5202 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5204 if (ret == CAMERA_ERROR_NONE)
5205 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5207 LOGD("ret : 0x%x", ret);
5213 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5215 int ret = CAMERA_ERROR_NONE;
5216 camera_cli_s *pc = (camera_cli_s *)camera;
5217 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5219 if (!pc || !pc->cb_info || !min || !max) {
5220 LOGE("NULL pointer %p %p %p", pc, min, max);
5221 return CAMERA_ERROR_INVALID_PARAMETER;
5226 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5228 if (ret == CAMERA_ERROR_NONE) {
5229 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5230 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5231 LOGD("min %d, max %d", *min, *max);
5234 LOGD("ret : 0x%x", ret);
5240 int camera_attr_get_hue(camera_h camera, int *level)
5242 int ret = CAMERA_ERROR_NONE;
5243 camera_cli_s *pc = (camera_cli_s *)camera;
5244 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE;
5246 if (!pc || !pc->cb_info || !level) {
5247 LOGE("NULL pointer %p %p", pc, level);
5248 return CAMERA_ERROR_INVALID_PARAMETER;
5253 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5255 if (ret == CAMERA_ERROR_NONE)
5256 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HUE];
5258 LOGD("ret : 0x%x", ret);
5264 int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
5266 int ret = CAMERA_ERROR_NONE;
5267 camera_cli_s *pc = (camera_cli_s *)camera;
5268 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE_RANGE;
5270 if (!pc || !pc->cb_info || !min || !max) {
5271 LOGE("NULL pointer %p %p %p", pc, min, max);
5272 return CAMERA_ERROR_INVALID_PARAMETER;
5277 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5279 if (ret == CAMERA_ERROR_NONE) {
5280 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][0];
5281 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][1];
5282 LOGD("min %d, max %d", *min, *max);
5285 LOGD("ret : 0x%x", ret);
5291 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5293 int ret = CAMERA_ERROR_NONE;
5294 camera_cli_s *pc = (camera_cli_s *)camera;
5295 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5297 if (!pc || !pc->cb_info || !wb) {
5298 LOGE("NULL pointer %p %p", pc, wb);
5299 return CAMERA_ERROR_INVALID_PARAMETER;
5304 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5306 if (ret == CAMERA_ERROR_NONE)
5307 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5309 LOGD("ret : 0x%x", ret);
5315 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5317 int ret = CAMERA_ERROR_NONE;
5318 camera_cli_s *pc = (camera_cli_s *)camera;
5319 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5321 if (!pc || !pc->cb_info || !effect) {
5322 LOGE("NULL pointer %p %p", pc, effect);
5323 return CAMERA_ERROR_INVALID_PARAMETER;
5328 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5330 if (ret == CAMERA_ERROR_NONE)
5331 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5333 LOGD("ret : 0x%x", ret);
5339 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5341 int ret = CAMERA_ERROR_NONE;
5342 camera_cli_s *pc = (camera_cli_s *)camera;
5343 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5345 if (!pc || !pc->cb_info || !mode) {
5346 LOGE("NULL pointer %p %p", pc, mode);
5347 return CAMERA_ERROR_INVALID_PARAMETER;
5352 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5354 if (ret == CAMERA_ERROR_NONE)
5355 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5357 LOGD("ret : 0x%x", ret);
5363 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5365 int ret = CAMERA_ERROR_NONE;
5366 camera_cli_s *pc = (camera_cli_s *)camera;
5367 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5369 if (!pc || !pc->cb_info || !enable) {
5370 LOGE("NULL pointer %p %p", pc, enable);
5371 return CAMERA_ERROR_INVALID_PARAMETER;
5376 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5378 if (ret == CAMERA_ERROR_NONE)
5379 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5381 LOGD("ret : 0x%x", ret);
5387 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5389 int ret = CAMERA_ERROR_NONE;
5390 camera_cli_s *pc = (camera_cli_s *)camera;
5391 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5393 if (!pc || !pc->cb_info || !description) {
5394 LOGE("NULL pointer %p %p", pc, description);
5395 return CAMERA_ERROR_INVALID_PARAMETER;
5400 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5402 if (ret == CAMERA_ERROR_NONE)
5403 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5405 LOGD("ret : 0x%x", ret);
5411 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5413 int ret = CAMERA_ERROR_NONE;
5414 camera_cli_s *pc = (camera_cli_s *)camera;
5415 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5417 if (!pc || !pc->cb_info || !orientation) {
5418 LOGE("NULL pointer %p %p", pc, orientation);
5419 return CAMERA_ERROR_INVALID_PARAMETER;
5424 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5426 if (ret == CAMERA_ERROR_NONE)
5427 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5429 LOGD("ret : 0x%x", ret);
5435 int camera_attr_get_tag_software(camera_h camera, char **software)
5437 int ret = CAMERA_ERROR_NONE;
5438 camera_cli_s *pc = (camera_cli_s *)camera;
5439 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5441 if (!pc || !pc->cb_info || !software) {
5442 LOGE("NULL pointer %p %p", pc, software);
5443 return CAMERA_ERROR_INVALID_PARAMETER;
5448 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5450 if (ret == CAMERA_ERROR_NONE)
5451 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5453 LOGD("ret : 0x%x", ret);
5459 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5461 int ret = CAMERA_ERROR_NONE;
5462 camera_cli_s *pc = (camera_cli_s *)camera;
5463 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5465 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5466 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5467 return CAMERA_ERROR_INVALID_PARAMETER;
5472 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5474 if (ret == CAMERA_ERROR_NONE) {
5475 *latitude = pc->cb_info->get_geotag[0];
5476 *longitude = pc->cb_info->get_geotag[1];
5477 *altitude = pc->cb_info->get_geotag[2];
5480 LOGD("ret : 0x%x", ret);
5486 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5488 int ret = CAMERA_ERROR_NONE;
5489 camera_cli_s *pc = (camera_cli_s *)camera;
5490 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5492 if (!pc || !pc->cb_info || !mode) {
5493 LOGE("NULL pointer %p %p", pc, mode);
5494 return CAMERA_ERROR_INVALID_PARAMETER;
5499 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5501 if (ret == CAMERA_ERROR_NONE)
5502 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5504 LOGD("ret : 0x%x", ret);
5510 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5512 int ret = CAMERA_ERROR_NONE;
5513 int get_flash_state = 0;
5516 LOGE("NULL pointer");
5517 return CAMERA_ERROR_INVALID_PARAMETER;
5520 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5521 (int)device, "get_flash_state", &get_flash_state);
5523 if (ret == CAMERA_ERROR_NONE) {
5524 *state = (camera_flash_state_e)get_flash_state;
5525 LOGD("flash state %d", *state);
5527 LOGE("failed 0x%x", ret);
5534 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5536 int ret = CAMERA_ERROR_NONE;
5537 camera_cli_s *pc = (camera_cli_s *)camera;
5538 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5540 if (!pc || !pc->cb_info || !foreach_cb) {
5541 LOGE("NULL pointer %p %p", pc, foreach_cb);
5542 return CAMERA_ERROR_INVALID_PARAMETER;
5547 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5548 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5550 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5552 LOGD("ret : 0x%x", ret);
5558 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5560 int ret = CAMERA_ERROR_NONE;
5561 camera_cli_s *pc = (camera_cli_s *)camera;
5562 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5564 if (!pc || !pc->cb_info || !foreach_cb) {
5565 LOGE("NULL pointer %p %p", pc, foreach_cb);
5566 return CAMERA_ERROR_INVALID_PARAMETER;
5571 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5572 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5574 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5576 LOGD("ret : 0x%x", ret);
5582 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5584 int ret = CAMERA_ERROR_NONE;
5585 camera_cli_s *pc = (camera_cli_s *)camera;
5586 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5588 if (!pc || !pc->cb_info || !foreach_cb) {
5589 LOGE("NULL pointer %p %p", pc, foreach_cb);
5590 return CAMERA_ERROR_INVALID_PARAMETER;
5595 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5596 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5598 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5600 LOGD("ret : 0x%x", ret);
5606 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5608 int ret = CAMERA_ERROR_NONE;
5609 camera_cli_s *pc = (camera_cli_s *)camera;
5610 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5612 if (!pc || !pc->cb_info || !foreach_cb) {
5613 LOGE("NULL pointer %p %p", pc, foreach_cb);
5614 return CAMERA_ERROR_INVALID_PARAMETER;
5619 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5620 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5622 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5624 LOGD("ret : 0x%x", ret);
5630 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5632 int ret = CAMERA_ERROR_NONE;
5633 camera_cli_s *pc = (camera_cli_s *)camera;
5634 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5636 if (!pc || !pc->cb_info || !foreach_cb) {
5637 LOGE("NULL pointer %p %p", pc, foreach_cb);
5638 return CAMERA_ERROR_INVALID_PARAMETER;
5643 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5644 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5646 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5648 LOGD("ret : 0x%x", ret);
5654 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5656 int ret = CAMERA_ERROR_NONE;
5657 camera_cli_s *pc = (camera_cli_s *)camera;
5658 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5660 if (!pc || !pc->cb_info || !foreach_cb) {
5661 LOGE("NULL pointer %p %p", pc, foreach_cb);
5662 return CAMERA_ERROR_INVALID_PARAMETER;
5667 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5668 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5670 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5672 LOGD("ret : 0x%x", ret);
5678 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5680 int ret = CAMERA_ERROR_NONE;
5681 camera_cli_s *pc = (camera_cli_s *)camera;
5682 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5684 if (!pc || !pc->cb_info || !foreach_cb) {
5685 LOGE("NULL pointer %p %p", pc, foreach_cb);
5686 return CAMERA_ERROR_INVALID_PARAMETER;
5691 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5692 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5694 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5696 LOGD("ret : 0x%x", ret);
5702 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5704 int ret = CAMERA_ERROR_NONE;
5705 camera_cli_s *pc = (camera_cli_s *)camera;
5706 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5708 if (!pc || !pc->cb_info || !foreach_cb) {
5709 LOGE("NULL pointer %p %p", pc, foreach_cb);
5710 return CAMERA_ERROR_INVALID_PARAMETER;
5715 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5716 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5718 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5720 LOGD("Enter, handle :%x", pc->remote_handle);
5726 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)
5728 int ret = CAMERA_ERROR_NONE;
5729 camera_cli_s *pc = (camera_cli_s *)camera;
5730 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5731 camera_msg_param param;
5734 if (!pc || !pc->cb_info || !foreach_cb) {
5735 LOGE("NULL pointer %p %p", pc, foreach_cb);
5736 return CAMERA_ERROR_INVALID_PARAMETER;
5741 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5742 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5744 value = (width << 16) | height;
5745 CAMERA_MSG_PARAM_SET(param, INT, value);
5747 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5749 LOGD("ret : 0x%x", ret);
5755 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5757 int ret = CAMERA_ERROR_NONE;
5758 camera_cli_s *pc = (camera_cli_s *)camera;
5759 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5761 if (!pc || !pc->cb_info || !foreach_cb) {
5762 LOGE("NULL pointer %p %p", pc, foreach_cb);
5763 return CAMERA_ERROR_INVALID_PARAMETER;
5768 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5769 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5771 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5773 LOGD("ret : 0x%x", ret);
5779 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5781 int ret = CAMERA_ERROR_NONE;
5782 camera_cli_s *pc = (camera_cli_s *)camera;
5783 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5785 if (!pc || !pc->cb_info || !foreach_cb) {
5786 LOGE("NULL pointer %p %p", pc, foreach_cb);
5787 return CAMERA_ERROR_INVALID_PARAMETER;
5792 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5793 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5795 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5797 LOGD("ret : 0x%x", ret);
5803 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
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_STREAM_ROTATION;
5808 camera_msg_param param;
5809 int set_rotation = (int)rotation;
5811 if (!pc || !pc->cb_info) {
5812 LOGE("NULL handle");
5813 return CAMERA_ERROR_INVALID_PARAMETER;
5818 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5820 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5822 LOGD("ret : 0x%x", ret);
5828 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5830 int ret = CAMERA_ERROR_NONE;
5831 camera_cli_s *pc = (camera_cli_s *)camera;
5832 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5834 if (!pc || !pc->cb_info || !rotation) {
5835 LOGE("NULL pointer %p %p", pc, rotation);
5836 return CAMERA_ERROR_INVALID_PARAMETER;
5841 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5843 if (ret == CAMERA_ERROR_NONE)
5844 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5846 LOGD("ret : 0x%x", ret);
5852 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5854 int ret = CAMERA_ERROR_NONE;
5855 camera_cli_s *pc = (camera_cli_s *)camera;
5856 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5857 camera_msg_param param;
5858 int set_flip = (int)flip;
5860 if (!pc || !pc->cb_info) {
5861 LOGE("NULL handle");
5862 return CAMERA_ERROR_INVALID_PARAMETER;
5867 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5869 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5871 LOGD("ret : 0x%x", ret);
5877 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5879 int ret = CAMERA_ERROR_NONE;
5880 camera_cli_s *pc = (camera_cli_s *)camera;
5881 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5883 if (!pc || !pc->cb_info || !flip) {
5884 LOGE("NULL pointer %p %p", pc, flip);
5885 return CAMERA_ERROR_INVALID_PARAMETER;
5890 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5892 if (ret == CAMERA_ERROR_NONE)
5893 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5895 LOGD("ret : 0x%x", ret);
5900 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5902 int ret = CAMERA_ERROR_NONE;
5903 camera_cli_s *pc = (camera_cli_s *)camera;
5904 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5905 camera_msg_param param;
5906 int set_mode = (int)mode;
5908 if (!pc || !pc->cb_info) {
5909 LOGE("NULL handle");
5910 return CAMERA_ERROR_INVALID_PARAMETER;
5915 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5917 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5919 LOGD("ret : 0x%x", ret);
5925 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5927 int ret = CAMERA_ERROR_NONE;
5928 camera_cli_s *pc = (camera_cli_s *)camera;
5929 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5931 if (!pc || !pc->cb_info || !mode) {
5932 LOGE("NULL pointer %p %p", pc, mode);
5933 return CAMERA_ERROR_INVALID_PARAMETER;
5938 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5940 if (ret == CAMERA_ERROR_NONE)
5941 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
5943 LOGD("ret : 0x%x", ret);
5949 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5951 int ret = CAMERA_ERROR_NONE;
5952 camera_cli_s *pc = (camera_cli_s *)camera;
5953 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
5955 if (!pc || !pc->cb_info) {
5956 LOGE("NULL handle");
5957 return CAMERA_ERROR_INVALID_PARAMETER;
5962 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5965 LOGE("error is occurred 0x%x", ret);
5969 LOGD("ret : %d", ret);
5975 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5977 int ret = CAMERA_ERROR_NONE;
5978 camera_cli_s *pc = (camera_cli_s *)camera;
5979 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5981 if (!pc || !pc->cb_info) {
5982 LOGE("NULL handle");
5983 return CAMERA_ERROR_INVALID_PARAMETER;
5988 if (!camera_attr_is_supported_hdr_capture(camera)) {
5989 LOGE("HDR not supported");
5990 return CAMERA_ERROR_NOT_SUPPORTED;
5994 LOGE("NULL callback");
5995 return CAMERA_ERROR_INVALID_PARAMETER;
5998 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6000 if (ret == CAMERA_ERROR_NONE) {
6001 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6003 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
6004 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
6006 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6009 LOGD("ret : 0x%x", ret);
6015 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
6017 int ret = CAMERA_ERROR_NONE;
6018 camera_cli_s *pc = (camera_cli_s *)camera;
6019 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
6021 if (!pc || !pc->cb_info) {
6022 LOGE("NULL handle");
6023 return CAMERA_ERROR_INVALID_PARAMETER;
6028 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6030 if (ret == CAMERA_ERROR_NONE) {
6031 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6033 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6034 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6036 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6039 LOGD("ret : 0x%x", ret);
6045 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6047 int ret = CAMERA_ERROR_NONE;
6048 camera_cli_s *pc = (camera_cli_s *)camera;
6049 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
6050 camera_msg_param param;
6051 int set_enable = (int)enable;
6053 if (!pc || !pc->cb_info) {
6054 LOGE("NULL handle");
6055 return CAMERA_ERROR_INVALID_PARAMETER;
6060 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6062 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6064 LOGD("ret : 0x%x", ret);
6070 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6072 int ret = CAMERA_ERROR_NONE;
6073 camera_cli_s *pc = (camera_cli_s *)camera;
6074 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6076 if (!pc || !pc->cb_info || !enabled) {
6077 LOGE("NULL pointer %p %p", pc, enabled);
6078 return CAMERA_ERROR_INVALID_PARAMETER;
6083 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6085 if (ret == CAMERA_ERROR_NONE)
6086 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6088 LOGD("ret : 0x%x", ret);
6094 bool camera_attr_is_supported_anti_shake(camera_h camera)
6096 int ret = CAMERA_ERROR_NONE;
6097 camera_cli_s *pc = (camera_cli_s *)camera;
6098 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6100 if (!pc || !pc->cb_info) {
6101 LOGE("NULL handle");
6102 return CAMERA_ERROR_INVALID_PARAMETER;
6107 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6110 LOGE("error is occurred 0x%x", ret);
6114 LOGD("ret : %d", ret);
6120 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6122 int ret = CAMERA_ERROR_NONE;
6123 camera_cli_s *pc = (camera_cli_s *)camera;
6124 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6125 camera_msg_param param;
6126 int set_enable = (int)enable;
6128 if (!pc || !pc->cb_info) {
6129 LOGE("NULL handle");
6130 return CAMERA_ERROR_INVALID_PARAMETER;
6135 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6137 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6139 LOGD("ret : 0x%x", ret);
6145 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6147 int ret = CAMERA_ERROR_NONE;
6148 camera_cli_s *pc = (camera_cli_s *)camera;
6149 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6151 if (!pc || !pc->cb_info || !enabled) {
6152 LOGE("NULL pointer %p %p", pc, enabled);
6153 return CAMERA_ERROR_INVALID_PARAMETER;
6158 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6160 if (ret == CAMERA_ERROR_NONE)
6161 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6163 LOGD("ret : 0x%x", ret);
6169 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6171 int ret = CAMERA_ERROR_NONE;
6172 camera_cli_s *pc = (camera_cli_s *)camera;
6173 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6175 if (!pc || !pc->cb_info) {
6176 LOGE("NULL handle");
6177 return CAMERA_ERROR_INVALID_PARAMETER;
6182 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6185 LOGE("error is occurred 0x%x", ret);
6189 LOGD("ret : %d", ret);
6195 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
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_ENABLE_AUTO_CONTRAST;
6200 camera_msg_param param;
6201 int set_enable = (int)enable;
6203 if (!pc || !pc->cb_info) {
6204 LOGE("NULL handle");
6205 return CAMERA_ERROR_INVALID_PARAMETER;
6210 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6212 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6214 LOGD("ret : 0x%x", ret);
6220 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6222 int ret = CAMERA_ERROR_NONE;
6223 camera_cli_s *pc = (camera_cli_s *)camera;
6224 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6226 if (!pc || !pc->cb_info || !enabled) {
6227 LOGE("NULL pointer %p %p", pc, enabled);
6228 return CAMERA_ERROR_INVALID_PARAMETER;
6233 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6235 if (ret == CAMERA_ERROR_NONE)
6236 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6238 LOGD("ret : 0x%x", ret);
6244 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6246 int ret = CAMERA_ERROR_NONE;
6247 camera_cli_s *pc = (camera_cli_s *)camera;
6248 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6250 if (!pc || !pc->cb_info) {
6251 LOGE("NULL handle");
6252 return CAMERA_ERROR_INVALID_PARAMETER;
6257 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6260 LOGE("error is occurred 0x%x", ret);
6264 LOGD("ret : %d", ret);
6270 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6272 int ret = CAMERA_ERROR_NONE;
6273 camera_cli_s *pc = (camera_cli_s *)camera;
6274 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6275 camera_msg_param param;
6276 int set_disable = (int)disable;
6278 if (!pc || !pc->cb_info) {
6279 LOGE("NULL handle");
6280 return CAMERA_ERROR_INVALID_PARAMETER;
6285 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6287 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6289 LOGD("ret : 0x%x", ret);
6295 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6297 int ret = CAMERA_ERROR_NONE;
6298 camera_cli_s *pc = (camera_cli_s *)camera;
6299 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6300 camera_msg_param param;
6301 int set_move_type = (int)move_type;
6304 if (!pc || !pc->cb_info) {
6305 LOGE("NULL handle");
6306 return CAMERA_ERROR_INVALID_PARAMETER;
6311 value = (set_move_type << 16) | pan_step;
6312 CAMERA_MSG_PARAM_SET(param, INT, value);
6314 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6316 LOGD("ret : 0x%x", ret);
6322 int camera_attr_get_pan(camera_h camera, int *pan_step)
6324 int ret = CAMERA_ERROR_NONE;
6325 camera_cli_s *pc = (camera_cli_s *)camera;
6326 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6328 if (!pc || !pc->cb_info || !pan_step) {
6329 LOGE("NULL pointer %p %p", pc, pan_step);
6330 return CAMERA_ERROR_INVALID_PARAMETER;
6335 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6337 if (ret == CAMERA_ERROR_NONE)
6338 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6340 LOGD("ret : 0x%x", ret);
6346 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6348 int ret = CAMERA_ERROR_NONE;
6349 camera_cli_s *pc = (camera_cli_s *)camera;
6350 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6352 if (!pc || !pc->cb_info || !min || !max) {
6353 LOGE("NULL pointer %p %p %p", pc, min, max);
6354 return CAMERA_ERROR_INVALID_PARAMETER;
6359 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6361 if (ret == CAMERA_ERROR_NONE) {
6362 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6363 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6366 LOGD("ret : 0x%x", ret);
6372 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6374 int ret = CAMERA_ERROR_NONE;
6375 camera_cli_s *pc = (camera_cli_s *)camera;
6376 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6377 camera_msg_param param;
6378 int set_move_type = (int)move_type;
6381 if (!pc || !pc->cb_info) {
6382 LOGE("NULL handle");
6383 return CAMERA_ERROR_INVALID_PARAMETER;
6388 value = (set_move_type << 16) | tilt_step;
6389 CAMERA_MSG_PARAM_SET(param, INT, value);
6391 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6393 LOGD("ret : 0x%x", ret);
6399 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6401 int ret = CAMERA_ERROR_NONE;
6402 camera_cli_s *pc = (camera_cli_s *)camera;
6403 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6405 if (!pc || !pc->cb_info || !tilt_step) {
6406 LOGE("NULL pointer %p %p", pc, tilt_step);
6407 return CAMERA_ERROR_INVALID_PARAMETER;
6412 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6414 if (ret == CAMERA_ERROR_NONE)
6415 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6417 LOGD("ret : 0x%x", ret);
6423 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6425 int ret = CAMERA_ERROR_NONE;
6426 camera_cli_s *pc = (camera_cli_s *)camera;
6427 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6429 if (!pc || !pc->cb_info || !min || !max) {
6430 LOGE("NULL pointer %p %p %p", pc, min, max);
6431 return CAMERA_ERROR_INVALID_PARAMETER;
6436 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6438 if (ret == CAMERA_ERROR_NONE) {
6439 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6440 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6443 LOGD("ret : 0x%x", ret);
6449 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6451 int ret = CAMERA_ERROR_NONE;
6452 camera_cli_s *pc = (camera_cli_s *)camera;
6453 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6454 camera_msg_param param;
6455 int set_ptz_type = (int)ptz_type;
6457 if (!pc || !pc->cb_info) {
6458 LOGE("NULL handle");
6459 return CAMERA_ERROR_INVALID_PARAMETER;
6464 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6466 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6468 LOGD("ret : 0x%x", ret);
6474 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6476 int ret = CAMERA_ERROR_NONE;
6477 camera_cli_s *pc = (camera_cli_s *)camera;
6478 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6480 if (!pc || !pc->cb_info || !foreach_cb) {
6481 LOGE("NULL pointer %p %p", pc, foreach_cb);
6482 return CAMERA_ERROR_INVALID_PARAMETER;
6487 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6488 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6490 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6492 LOGD("ret : 0x%x", ret);
6498 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6500 int ret = CAMERA_ERROR_NONE;
6501 camera_cli_s *pc = (camera_cli_s *)camera;
6502 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6503 int set_display_roi_area[4] = {x, y, width, height};
6508 if (!pc || !pc->cb_info) {
6509 LOGE("NULL handle");
6510 return CAMERA_ERROR_INVALID_PARAMETER;
6515 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6516 ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
6517 if (ret != MM_ERROR_NONE) {
6518 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6519 return CAMERA_ERROR_INVALID_OPERATION;
6523 length = sizeof(set_display_roi_area) / sizeof(int) + \
6524 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6526 msg = muse_core_msg_new(api,
6527 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6530 LOGE("msg creation failed: api %d", api);
6531 return CAMERA_ERROR_OUT_OF_MEMORY;
6534 if (pc->cb_info->is_server_connected) {
6535 __camera_update_api_waiting(pc->cb_info, api, 1);
6537 g_mutex_lock(&pc->cb_info->fd_lock);
6538 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
6539 g_mutex_unlock(&pc->cb_info->fd_lock);
6543 LOGE("message send failed");
6544 ret = CAMERA_ERROR_INVALID_OPERATION;
6546 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6549 __camera_update_api_waiting(pc->cb_info, api, -1);
6551 muse_core_msg_free(msg);
6553 LOGD("ret : 0x%x", ret);
6559 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6561 camera_cli_s *pc = (camera_cli_s *)camera;
6562 int ret = CAMERA_ERROR_NONE;
6563 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6565 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6566 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6567 return CAMERA_ERROR_INVALID_PARAMETER;
6572 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6574 if (ret == CAMERA_ERROR_NONE) {
6575 *x = pc->cb_info->get_display_roi_area[0];
6576 *y = pc->cb_info->get_display_roi_area[1];
6577 *width = pc->cb_info->get_display_roi_area[2];
6578 *height = pc->cb_info->get_display_roi_area[3];
6581 LOGD("ret : 0x%x", ret);
6587 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6589 int ret = CAMERA_ERROR_NONE;
6590 int get_device_state = 0;
6593 LOGE("NULL pointer");
6594 return CAMERA_ERROR_INVALID_PARAMETER;
6597 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6598 (int)device, "get_device_state", &get_device_state);
6600 if (ret == CAMERA_ERROR_NONE) {
6601 *state = (camera_device_state_e)get_device_state;
6602 LOGD("device state %d", *state);
6604 LOGE("failed 0x%x", ret);
6611 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6613 int ret = CAMERA_ERROR_NONE;
6614 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6615 camera_cb_info *info = NULL;
6617 if (!callback || !cb_id) {
6618 LOGE("invalid pointer %p %p", callback, cb_id);
6619 return CAMERA_ERROR_INVALID_PARAMETER;
6622 /* check camera support */
6623 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6624 if (ret != CAMERA_ERROR_NONE) {
6625 LOGE("get device state failed");
6629 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6631 info = g_new0(camera_cb_info, 1);
6633 LOGE("info failed");
6634 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6638 info->id = ++g_cam_dev_state_changed_cb_id;
6639 info->callback = (void *)callback;
6640 info->user_data = user_data;
6644 /* subscribe dbus signal for camera state change */
6645 if (!g_cam_dev_state_changed_cb_conn) {
6646 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6647 if (!g_cam_dev_state_changed_cb_conn) {
6648 LOGE("failed to get gdbus connection");
6649 ret = CAMERA_ERROR_INVALID_OPERATION;
6653 LOGD("subscribe signal %s - %s - %s",
6654 MM_CAMCORDER_DBUS_OBJECT,
6655 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6656 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6658 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6659 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6660 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6661 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6662 LOGE("failed to get gdbus connection");
6663 ret = CAMERA_ERROR_INVALID_OPERATION;
6667 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6670 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6672 LOGD("callback id %d", info->id);
6675 if (ret != CAMERA_ERROR_NONE) {
6681 if (g_cam_dev_state_changed_cb_conn) {
6682 g_object_unref(g_cam_dev_state_changed_cb_conn);
6683 g_cam_dev_state_changed_cb_conn = NULL;
6687 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6693 int camera_remove_device_state_changed_cb(int cb_id)
6695 int ret = CAMERA_ERROR_NONE;
6696 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6697 GList *tmp_list = NULL;
6698 camera_cb_info *info = NULL;
6700 /* check camera support */
6701 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6702 if (ret != CAMERA_ERROR_NONE) {
6703 LOGE("get device state failed");
6707 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6709 if (!g_cam_dev_state_changed_cb_list) {
6710 LOGE("there is no callback info");
6711 ret = CAMERA_ERROR_INVALID_OPERATION;
6715 tmp_list = g_cam_dev_state_changed_cb_list;
6718 info = tmp_list->data;
6719 tmp_list = tmp_list->next;
6726 if (info->id == cb_id) {
6727 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6732 if (!g_cam_dev_state_changed_cb_list) {
6733 /* no remained callback */
6734 if (g_cam_dev_state_changed_cb_conn) {
6735 /* unsubscribe signal */
6736 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6737 g_cam_dev_state_changed_cb_subscribe_id = 0;
6739 /* unref connection */
6740 g_object_unref(g_cam_dev_state_changed_cb_conn);
6741 g_cam_dev_state_changed_cb_conn = NULL;
6745 LOGD("id %d callback removed", cb_id);
6746 ret = CAMERA_ERROR_NONE;
6752 LOGE("id %d callback not found", cb_id);
6753 ret = CAMERA_ERROR_INVALID_PARAMETER;
6756 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);