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;
744 case MM_PIXEL_FORMAT_NV16:
745 *out_format = TBM_FORMAT_NV16;
747 case MM_PIXEL_FORMAT_NV21:
748 *out_format = TBM_FORMAT_NV21;
750 case MM_PIXEL_FORMAT_YUYV:
751 *out_format = TBM_FORMAT_YUYV;
753 case MM_PIXEL_FORMAT_UYVY:
754 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
755 *out_format = TBM_FORMAT_UYVY;
757 case MM_PIXEL_FORMAT_422P:
758 *out_format = TBM_FORMAT_YUV422;
760 case MM_PIXEL_FORMAT_I420:
761 *out_format = TBM_FORMAT_YUV420;
763 case MM_PIXEL_FORMAT_YV12:
764 *out_format = TBM_FORMAT_YVU420;
766 case MM_PIXEL_FORMAT_RGB565:
767 *out_format = TBM_FORMAT_RGB565;
769 case MM_PIXEL_FORMAT_RGB888:
770 *out_format = TBM_FORMAT_RGB888;
772 case MM_PIXEL_FORMAT_RGBA:
773 *out_format = TBM_FORMAT_RGBA8888;
775 case MM_PIXEL_FORMAT_ARGB:
776 *out_format = TBM_FORMAT_ARGB8888;
779 LOGE("invalid in_format %d", in_format);
780 return CAMERA_ERROR_INVALID_PARAMETER;
783 return CAMERA_ERROR_NONE;
787 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
789 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
790 in_format >= MM_PIXEL_FORMAT_NUM ||
792 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
793 return CAMERA_ERROR_INVALID_PARAMETER;
797 case MM_PIXEL_FORMAT_NV12:
798 case MM_PIXEL_FORMAT_NV12T:
799 *mimetype = MEDIA_FORMAT_NV12;
801 case MM_PIXEL_FORMAT_NV16:
802 *mimetype = MEDIA_FORMAT_NV16;
804 case MM_PIXEL_FORMAT_NV21:
805 *mimetype = MEDIA_FORMAT_NV21;
807 case MM_PIXEL_FORMAT_YUYV:
808 *mimetype = MEDIA_FORMAT_YUYV;
810 case MM_PIXEL_FORMAT_UYVY:
811 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
812 *mimetype = MEDIA_FORMAT_UYVY;
814 case MM_PIXEL_FORMAT_422P:
815 *mimetype = MEDIA_FORMAT_422P;
817 case MM_PIXEL_FORMAT_I420:
818 *mimetype = MEDIA_FORMAT_I420;
820 case MM_PIXEL_FORMAT_YV12:
821 *mimetype = MEDIA_FORMAT_YV12;
823 case MM_PIXEL_FORMAT_RGB565:
824 *mimetype = MEDIA_FORMAT_RGB565;
826 case MM_PIXEL_FORMAT_RGB888:
827 *mimetype = MEDIA_FORMAT_RGB888;
829 case MM_PIXEL_FORMAT_RGBA:
830 *mimetype = MEDIA_FORMAT_RGBA;
832 case MM_PIXEL_FORMAT_ARGB:
833 *mimetype = MEDIA_FORMAT_ARGB;
836 LOGE("invalid in_format %d", in_format);
837 return CAMERA_ERROR_INVALID_PARAMETER;
840 return CAMERA_ERROR_NONE;
843 static void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_key,
844 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame)
847 unsigned char *buf_pos = NULL;
849 if (stream == NULL || buffer_bo_handle == NULL || frame == NULL) {
850 LOGE("invalid parameter - stream:%p, buffer_bo_handle:%p", stream, buffer_bo_handle);
855 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
856 frame->format = MM_PIXEL_FORMAT_UYVY;
858 frame->format = stream->format;
860 frame->width = stream->width;
861 frame->height = stream->height;
862 frame->timestamp = stream->timestamp;
863 frame->num_of_planes = stream->num_planes;
865 if (num_buffer_key == 0) {
867 if (!data_bo_handle || !data_bo_handle->ptr) {
868 LOGE("NULL pointer");
872 buf_pos = data_bo_handle->ptr;
874 if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) {
875 frame->data.encoded_plane.data = buf_pos;
876 frame->data.encoded_plane.size = stream->data.encoded.length_data;
877 total_size = stream->data.encoded.length_data;
878 } else if (stream->format == MM_PIXEL_FORMAT_INVZ) {
879 frame->data.depth_plane.data = buf_pos;
880 frame->data.depth_plane.size = stream->data.depth.length_data;
881 total_size = stream->data.depth.length_data;
883 switch (stream->num_planes) {
885 frame->data.single_plane.yuv = buf_pos;
886 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
887 total_size = stream->data.yuv420.length_yuv;
890 frame->data.double_plane.y = buf_pos;
891 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
892 buf_pos += stream->data.yuv420sp.length_y;
893 frame->data.double_plane.uv = buf_pos;
894 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
895 total_size = stream->data.yuv420sp.length_y + \
896 stream->data.yuv420sp.length_uv;
899 frame->data.triple_plane.y = buf_pos;
900 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
901 buf_pos += stream->data.yuv420p.length_y;
902 frame->data.triple_plane.u = buf_pos;
903 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
904 buf_pos += stream->data.yuv420p.length_u;
905 frame->data.triple_plane.v = buf_pos;
906 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
907 total_size = stream->data.yuv420p.length_y + \
908 stream->data.yuv420p.length_u + \
909 stream->data.yuv420p.length_v;
917 switch (stream->num_planes) {
919 frame->data.single_plane.yuv = buffer_bo_handle[0].ptr;
920 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
921 total_size = stream->data.yuv420.length_yuv;
924 frame->data.double_plane.y = buffer_bo_handle[0].ptr;
925 if (stream->num_planes == (unsigned int)num_buffer_key)
926 frame->data.double_plane.uv = buffer_bo_handle[1].ptr;
928 frame->data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
929 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
930 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
931 total_size = stream->data.yuv420sp.length_y + \
932 stream->data.yuv420sp.length_uv;
935 frame->data.triple_plane.y = buffer_bo_handle[0].ptr;
936 if (stream->num_planes == (unsigned int)num_buffer_key) {
937 frame->data.triple_plane.u = buffer_bo_handle[1].ptr;
938 frame->data.triple_plane.v = buffer_bo_handle[2].ptr;
940 frame->data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y;
941 frame->data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u;
943 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
944 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
945 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
946 total_size = stream->data.yuv420p.length_y + \
947 stream->data.yuv420p.length_u + \
948 stream->data.yuv420p.length_v;
956 LOGD("format %d, %dx%d, size %d plane num %d",
957 frame.format, frame.width, frame.height, total_size, frame.num_of_planes);
963 static int _camera_media_packet_data_create(int tbm_key, int num_buffer_key, tbm_bo bo,
964 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
967 int ret = CAMERA_ERROR_NONE;
968 camera_media_packet_data *tmp_mp_data = NULL;
970 if (*mp_data == NULL) {
971 tmp_mp_data = g_new0(camera_media_packet_data, 1);
973 tmp_mp_data->tbm_key = tbm_key;
974 tmp_mp_data->num_buffer_key = num_buffer_key;
975 tmp_mp_data->bo = bo;
976 tmp_mp_data->data_bo = data_bo;
977 tmp_mp_data->ref_cnt++;
979 for (i = 0 ; i < num_buffer_key ; i++)
980 tmp_mp_data->buffer_bo[i] = buffer_bo[i];
982 *mp_data = tmp_mp_data;
983 /*LOGD("mp_data %p", tmp_mp_data);*/
985 ret = CAMERA_ERROR_OUT_OF_MEMORY;
986 LOGE("failed to alloc media packet data");
989 ((camera_media_packet_data *)*mp_data)->ref_cnt++;
995 static void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
999 camera_msg_param param;
1001 if (!mp_data || !cb_info) {
1002 LOGE("NULL pointer %p %p", mp_data, cb_info);
1006 if (mp_data->ref_cnt > 1) {
1008 LOGD("ref count %d", mp_data->ref_cnt);
1010 /* release imported bo */
1011 for (i = 0 ; i < mp_data->num_buffer_key ; i++) {
1012 tbm_bo_unref(mp_data->buffer_bo[i]);
1013 mp_data->buffer_bo[i] = NULL;
1017 _camera_release_imported_bo(&mp_data->bo);
1018 _camera_release_imported_bo(&mp_data->data_bo);
1021 tbm_key = mp_data->tbm_key;
1023 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1025 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1034 static int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
1035 camera_media_packet_data *mp_data, media_packet_h *packet)
1037 media_packet_h pkt = NULL;
1038 bool make_pkt_fmt = false;
1039 tbm_surface_h tsurf = NULL;
1040 tbm_surface_info_s tsurf_info;
1041 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
1042 uint32_t bo_format = 0;
1045 int num_buffer_key = 0;
1046 tbm_bo *buffer_bo = NULL;
1048 if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) {
1049 LOGE("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p",
1050 cb_info, stream, mp_data, packet);
1051 return CAMERA_ERROR_INVALID_PARAMETER;
1054 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
1055 buffer_bo = mp_data->buffer_bo;
1056 num_buffer_key = mp_data->num_buffer_key;
1058 /* create tbm surface */
1059 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
1060 tsurf_info.planes[i].stride = stream->stride[i];
1062 /* get tbm surface format */
1063 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
1064 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
1066 if (ret == CAMERA_ERROR_NONE) {
1067 tsurf_info.width = stream->width;
1068 tsurf_info.height = stream->height;
1069 tsurf_info.format = bo_format;
1070 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
1071 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
1073 if (num_buffer_key > 0) {
1074 switch (bo_format) {
1075 case TBM_FORMAT_NV12:
1076 case TBM_FORMAT_NV21:
1077 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1078 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1079 tsurf_info.planes[0].offset = 0;
1080 if (num_buffer_key == 1)
1081 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1082 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1084 case TBM_FORMAT_YUV420:
1085 case TBM_FORMAT_YVU420:
1086 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1087 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1088 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
1089 tsurf_info.planes[0].offset = 0;
1090 if (num_buffer_key == 1) {
1091 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1092 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1094 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1096 case TBM_FORMAT_UYVY:
1097 case TBM_FORMAT_YUYV:
1098 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
1099 tsurf_info.planes[0].offset = 0;
1100 tsurf_info.size = tsurf_info.planes[0].size;
1106 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_key);
1107 } else if (mp_data->data_bo) {
1108 switch (bo_format) {
1109 case TBM_FORMAT_NV12:
1110 case TBM_FORMAT_NV21:
1111 tsurf_info.planes[0].size = stream->width * stream->height;
1112 tsurf_info.planes[1].size = (tsurf_info.planes[0].size) >> 1;
1113 tsurf_info.planes[0].offset = 0;
1114 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1115 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1117 case TBM_FORMAT_YUV420:
1118 case TBM_FORMAT_YVU420:
1119 tsurf_info.planes[0].size = stream->width * stream->height;
1120 tsurf_info.planes[1].size = (stream->width >> 1) * (stream->height >> 1);
1121 tsurf_info.planes[2].size = tsurf_info.planes[1].size;
1122 tsurf_info.planes[0].offset = 0;
1123 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1124 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1125 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1127 case TBM_FORMAT_UYVY:
1128 case TBM_FORMAT_YUYV:
1129 tsurf_info.planes[0].size = (stream->width * stream->height) << 1;
1130 tsurf_info.planes[0].offset = 0;
1131 tsurf_info.size = tsurf_info.planes[0].size;
1137 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1);
1139 /*LOGD("tbm surface %p", tsurf);*/
1143 /* check media packet format */
1144 if (cb_info->pkt_fmt) {
1145 int pkt_fmt_width = 0;
1146 int pkt_fmt_height = 0;
1147 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
1149 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
1150 if (pkt_fmt_mimetype != mimetype ||
1151 pkt_fmt_width != stream->width ||
1152 pkt_fmt_height != stream->height) {
1153 LOGW("change fmt: current 0x%x, %dx%d",
1154 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
1155 media_format_unref(cb_info->pkt_fmt);
1156 cb_info->pkt_fmt = NULL;
1157 make_pkt_fmt = true;
1160 make_pkt_fmt = true;
1163 /* create packet format */
1165 LOGW("make new pkt_fmt - 0x%x, %dx%d", mimetype, stream->width, stream->height);
1166 ret = media_format_create(&cb_info->pkt_fmt);
1167 if (ret == MEDIA_FORMAT_ERROR_NONE) {
1168 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
1169 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
1170 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
1171 LOGW("media_format_set : 0x%x", ret);
1173 LOGW("media_format_create failed 0x%x", ret);
1177 /* create media packet */
1178 ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt,
1179 tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
1180 (void *)cb_info, &pkt);
1181 if (ret != MEDIA_PACKET_ERROR_NONE) {
1182 LOGE("media_packet_create failed 0x%x", ret);
1183 tbm_surface_destroy(tsurf);
1187 LOGE("tbm surface failed. %dx%d, format %d, num_buffer_key %d, data_bo %p",
1188 stream->width, stream->height, stream->format, num_buffer_key, mp_data->data_bo);
1192 /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
1193 /* set media packet data */
1194 ret = media_packet_set_extra(pkt, (void *)mp_data);
1195 if (ret != MEDIA_PACKET_ERROR_NONE) {
1196 LOGE("media_packet_set_extra failed");
1198 _camera_media_packet_data_release(mp_data, cb_info);
1201 media_packet_destroy(pkt);
1204 /* set timestamp : msec -> nsec */
1205 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
1206 LOGW("media_packet_set_pts failed");
1215 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
1218 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1219 camera_media_packet_data *mp_data = NULL;
1220 tbm_surface_h tsurf = NULL;
1222 if (!pkt || !cb_info) {
1223 LOGE("NULL pointer %p %p", pkt, cb_info);
1224 return MEDIA_PACKET_FINALIZE;
1227 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1228 if (ret != MEDIA_PACKET_ERROR_NONE) {
1229 LOGE("media_packet_get_extra failed 0x%x", ret);
1230 return MEDIA_PACKET_FINALIZE;
1233 /*LOGD("mp_data %p", mp_data);*/
1235 g_mutex_lock(&cb_info->mp_data_mutex);
1237 _camera_media_packet_data_release(mp_data, cb_info);
1240 g_mutex_unlock(&cb_info->mp_data_mutex);
1242 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1243 if (ret != MEDIA_PACKET_ERROR_NONE)
1244 LOGE("get tbm_surface failed 0x%x", ret);
1247 tbm_surface_destroy(tsurf);
1251 return MEDIA_PACKET_FINALIZE;
1254 static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event)
1259 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1260 LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event);
1264 /*LOGD("get camera msg %s, event %d", recv_msg, event);*/
1266 g_mutex_lock(&cb_info->user_cb_mutex[event]);
1268 if (cb_info->user_cb[event] == NULL) {
1269 if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
1270 event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
1271 event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
1272 event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1273 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1274 LOGW("NULL callback for event %d, return here", event);
1278 /* return buffer message should be sent for some events.
1279 - MUSE_CAMERA_EVENT_TYPE_PREVIEW
1280 - MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW
1281 - MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION
1282 - MUSE_CAMERA_EVENT_TYPE_CAPTURE
1287 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1293 muse_camera_msg_get(previous, recv_msg);
1294 muse_camera_msg_get(current, recv_msg);
1295 muse_camera_msg_get(by_policy, recv_msg);
1297 LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
1298 previous, current, by_policy);
1300 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1301 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1304 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1308 muse_camera_msg_get(state, recv_msg);
1310 LOGD("FOCUS state - %d", state);
1312 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1315 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1316 LOGD("CAPTURE_COMPLETED");
1317 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1319 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1320 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1321 __camera_event_handler_preview(cb_info, recv_msg);
1323 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1327 muse_camera_msg_get(percent, recv_msg);
1329 LOGD("HDR progress - %d %%", percent);
1331 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1334 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1340 muse_camera_msg_get(policy, recv_msg);
1341 muse_camera_msg_get(previous, recv_msg);
1342 muse_camera_msg_get(current, recv_msg);
1344 LOGW("INTERRUPTED - policy %d, state %d -> %d", policy, previous, current);
1346 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1347 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1350 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1355 muse_camera_msg_get(policy, recv_msg);
1356 muse_camera_msg_get(state, recv_msg);
1358 LOGW("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1360 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1361 (camera_state_e)state, cb_info->user_data[event]);
1364 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1365 __camera_event_handler_face_detection(cb_info, recv_msg);
1367 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1370 int current_state = 0;
1372 muse_camera_msg_get(error, recv_msg);
1373 muse_camera_msg_get(current_state, recv_msg);
1375 LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
1377 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1378 (camera_state_e)current_state, cb_info->user_data[event]);
1381 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1383 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1384 muse_camera_msg_get(param1, recv_msg);
1385 muse_camera_msg_get(param2, recv_msg);
1387 /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/
1389 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1390 cb_info->user_cb[event] = NULL;
1391 cb_info->user_data[event] = NULL;
1392 LOGW("stop foreach callback for event %d", event);
1395 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1397 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1399 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1401 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1403 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1405 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1407 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1409 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1411 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1413 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1415 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1417 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1419 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1421 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1423 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1424 muse_camera_msg_get(param1, recv_msg);
1426 /*LOGD("event %d SUPPORTED %d ", event, param1);*/
1428 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1429 cb_info->user_cb[event] = NULL;
1430 cb_info->user_data[event] = NULL;
1431 LOGW("stop foreach callback for event %d", event);
1434 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1435 __camera_event_handler_capture(cb_info, recv_msg);
1438 LOGW("unhandled event %d", event);
1442 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1447 static bool _camera_idle_event_callback(void *data)
1449 camera_cb_info_s *cb_info = NULL;
1450 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1452 if (cam_idle_event == NULL) {
1453 LOGE("cam_idle_event is NULL");
1458 g_mutex_lock(&cam_idle_event->event_mutex);
1460 cb_info = cam_idle_event->cb_info;
1461 if (cb_info == NULL) {
1462 LOGW("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1463 goto IDLE_EVENT_CALLBACK_DONE;
1466 /* remove event from list */
1467 g_mutex_lock(&cb_info->idle_event_mutex);
1469 if (cb_info->idle_event_list)
1470 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1472 /*LOGD("remove camera idle event %p, %p", cam_idle_event, cb_info->idle_event_list);*/
1473 g_mutex_unlock(&cb_info->idle_event_mutex);
1476 _camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
1478 /* send signal for waiting thread */
1479 g_cond_signal(&cb_info->idle_event_cond);
1481 IDLE_EVENT_CALLBACK_DONE:
1482 /* unlock and release event */
1483 g_mutex_unlock(&cam_idle_event->event_mutex);
1484 g_mutex_clear(&cam_idle_event->event_mutex);
1486 g_free(cam_idle_event);
1487 cam_idle_event = NULL;
1492 static void *_camera_msg_handler_func(gpointer data)
1496 camera_message_s *cam_msg = NULL;
1497 camera_idle_event_s *cam_idle_event = NULL;
1498 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1499 camera_cb_info_s *cb_info = NULL;
1501 if (!handler_info || !handler_info->cb_info) {
1502 LOGE("NULL handler %p", handler_info);
1506 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1507 type = handler_info->type;
1509 LOGD("t:%d start", type);
1511 g_mutex_lock(&handler_info->mutex);
1513 while (g_atomic_int_get(&handler_info->running)) {
1514 if (g_queue_is_empty(handler_info->queue)) {
1515 /*LOGD("t:%d signal wait...", type);*/
1516 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1517 /*LOGD("t:%d signal received", type);*/
1519 if (g_atomic_int_get(&handler_info->running) == 0) {
1520 LOGD("t:%d stop event thread", type);
1525 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1527 g_mutex_unlock(&handler_info->mutex);
1529 if (cam_msg == NULL) {
1530 LOGE("t:%d NULL message", type);
1531 g_mutex_lock(&handler_info->mutex);
1537 if (api < MUSE_CAMERA_API_MAX) {
1540 g_mutex_lock(&cb_info->api_mutex[api]);
1542 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1543 if (cb_info->api_waiting[api] > 0) {
1544 cb_info->api_ret[api] = ret;
1545 cb_info->api_activating[api] = 1;
1547 /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
1549 g_cond_signal(&cb_info->api_cond[api]);
1551 LOGW("no waiting for this api [%d]", api);
1554 LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1557 g_mutex_unlock(&cb_info->api_mutex[api]);
1558 } else if (api == MUSE_CAMERA_CB_EVENT) {
1559 switch (cam_msg->event_class) {
1560 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1561 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event);
1563 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1564 cam_idle_event = g_new0(camera_idle_event_s, 1);
1565 if (cam_idle_event == NULL) {
1566 LOGE("t:%d cam_idle_event alloc failed", type);
1570 cam_idle_event->event = cam_msg->event;
1571 cam_idle_event->cb_info = cb_info;
1572 g_mutex_init(&cam_idle_event->event_mutex);
1573 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg) - 1);
1575 /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, cam_msg->event, cam_idle_event);*/
1577 g_mutex_lock(&cb_info->idle_event_mutex);
1578 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1579 g_mutex_unlock(&cb_info->idle_event_mutex);
1581 g_idle_add_full(G_PRIORITY_DEFAULT,
1582 (GSourceFunc)_camera_idle_event_callback,
1583 (gpointer)cam_idle_event,
1587 LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
1591 LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1597 g_mutex_lock(&handler_info->mutex);
1600 /* remove remained event */
1601 while (!g_queue_is_empty(handler_info->queue)) {
1602 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1604 LOGD("t:%d remove camera message %p", type, cam_msg);
1608 LOGW("t:%d NULL camera message", type);
1612 g_mutex_unlock(&handler_info->mutex);
1614 LOGD("t:%d return", type);
1620 static void _camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1622 camera_idle_event_s *cam_idle_event = NULL;
1624 gint64 end_time = 0;
1626 if (cb_info == NULL) {
1627 LOGE("cb_info is NULL");
1631 g_mutex_lock(&cb_info->idle_event_mutex);
1633 if (cb_info->idle_event_list == NULL) {
1634 LOGD("No remained idle event");
1635 g_mutex_unlock(&cb_info->idle_event_mutex);
1639 list = cb_info->idle_event_list;
1642 cam_idle_event = list->data;
1643 list = g_list_next(list);
1645 if (!cam_idle_event) {
1646 LOGW("Fail to remove idle event. The event is NULL");
1650 if (g_idle_remove_by_data(cam_idle_event)) {
1651 LOGW("remove idle event %p done", cam_idle_event);
1653 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1655 g_mutex_clear(&cam_idle_event->event_mutex);
1656 g_free(cam_idle_event);
1657 cam_idle_event = NULL;
1662 LOGW("remove idle event %p failed", cam_idle_event);
1664 if (!g_mutex_trylock(&cam_idle_event->event_mutex)) {
1665 LOGW("lock failed, %p event is calling now", cam_idle_event);
1667 end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
1669 if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
1670 LOGW("signal received");
1677 LOGW("set NULL cb_info for event %p %d, it will be freed on idle callback",
1678 cam_idle_event, cam_idle_event->event);
1680 cam_idle_event->cb_info = NULL;
1682 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1684 g_mutex_unlock(&cam_idle_event->event_mutex);
1687 g_list_free(cb_info->idle_event_list);
1688 cb_info->idle_event_list = NULL;
1690 g_mutex_unlock(&cb_info->idle_event_mutex);
1696 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg)
1698 camera_message_s *cam_msg = NULL;
1700 if (!cb_info || !msg) {
1701 LOGE("NULL pointer %p %p", cb_info, msg);
1705 cam_msg = g_new0(camera_message_s, 1);
1707 LOGE("failed to alloc cam_msg for [%s]", msg);
1712 cam_msg->event = event;
1713 cam_msg->event_class = event_class;
1715 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1717 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1719 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1720 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1721 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1722 g_cond_signal(&cb_info->preview_cb_info.cond);
1723 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1724 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1725 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1726 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1727 g_cond_signal(&cb_info->capture_cb_info.cond);
1728 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1730 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1731 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1732 g_cond_signal(&cb_info->msg_handler_info.cond);
1733 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1742 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg)
1744 int ret = CAMERA_ERROR_NONE;
1748 int event_class = -1;
1752 if (!cb_info || !msg) {
1753 LOGE("invalid ptr %p %p", cb_info, msg);
1757 /*LOGD("msg [%s]", msg);*/
1759 if (!muse_camera_msg_get(api, msg)) {
1760 LOGE("failed to get camera api");
1764 if (api == MUSE_CAMERA_CB_EVENT) {
1765 if (!muse_camera_msg_get(event, msg) ||
1766 !muse_camera_msg_get(event_class, msg)) {
1767 LOGE("failed to get camera event or event_class [%s]", msg);
1771 if (!muse_camera_msg_get(api_class, msg)) {
1772 LOGE("failed to get camera api_class [%s]", msg);
1777 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1778 if (api >= MUSE_CAMERA_API_MAX) {
1779 LOGE("invalid api %d", api);
1783 if (!muse_camera_msg_get(ret, msg)) {
1784 LOGE("failed to get camera ret");
1788 g_mutex_lock(&cb_info->api_mutex[api]);
1791 case MUSE_CAMERA_API_CREATE:
1792 if (ret != CAMERA_ERROR_NONE) {
1793 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1794 LOGE("camera create error 0x%x. close client cb handler", ret);
1797 case MUSE_CAMERA_API_DESTROY:
1798 if (ret == CAMERA_ERROR_NONE) {
1799 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1800 LOGD("camera destroy done. close client cb handler");
1804 muse_camera_msg_get(get_type, msg);
1805 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1806 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1807 muse_camera_msg_get(get_index, msg);
1810 case MUSE_CAMERA_GET_TYPE_INT:
1811 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
1813 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1814 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
1815 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
1817 case MUSE_CAMERA_GET_TYPE_ARRAY:
1818 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
1819 muse_core_msg_deserialize("get_value",
1820 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
1821 LOGD("get display roi %d,%d,%dx%d",
1822 cb_info->get_display_roi_area[0],
1823 cb_info->get_display_roi_area[1],
1824 cb_info->get_display_roi_area[2],
1825 cb_info->get_display_roi_area[3]);
1827 muse_core_msg_deserialize("get_value",
1828 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
1829 LOGD("get geotag %lf, %lf, %lf",
1830 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
1833 case MUSE_CAMERA_GET_TYPE_STRING:
1834 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
1837 LOGW("unknown type %d", get_type);
1844 if (cb_info->api_waiting[api] > 0) {
1845 cb_info->api_ret[api] = ret;
1846 cb_info->api_activating[api] = 1;
1848 g_cond_signal(&cb_info->api_cond[api]);
1850 LOGW("no waiting for this api [%d]", api);
1853 g_mutex_unlock(&cb_info->api_mutex[api]);
1854 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
1855 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg);
1857 LOGW("unknown camera api %d, class %d", api, api_class);
1864 static void *_camera_msg_recv_func(gpointer data)
1866 int recv_length = 0;
1867 int single_length = 0;
1868 int remained_length = 0;
1869 char *recv_msg = NULL;
1870 char *single_msg = NULL;
1871 char *remained_msg = NULL;
1875 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
1878 LOGE("cb_info NULL");
1882 LOGD("start - fd : %d", cb_info->fd);
1884 single_msg = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
1886 LOGE("single_msg malloc failed");
1890 recv_msg = cb_info->recv_msg;
1892 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
1893 recv_length = muse_core_msg_recv(cb_info->fd, recv_msg);
1894 if (recv_length <= 0) {
1895 cb_info->is_server_connected = FALSE;
1896 LOGE("receive msg failed - server disconnected");
1904 /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
1906 /* Need to split the combined entering msgs */
1907 for (cur_pos = 0 ; cur_pos < recv_length ; cur_pos++) {
1908 if (recv_msg[cur_pos] == '}') {
1909 single_length = cur_pos - prev_pos + 1;
1911 if (single_length < MUSE_CAMERA_MSG_MAX_LENGTH) {
1912 /* check remained msg */
1913 if (remained_length > 0) {
1915 strncpy(single_msg, remained_msg, remained_length);
1916 strncpy(single_msg + remained_length, recv_msg + prev_pos, single_length);
1917 single_msg[remained_length + single_length] = '\0';
1920 remained_msg = NULL;
1922 strncpy(single_msg, recv_msg + prev_pos, single_length);
1923 single_msg[single_length] = '\0';
1924 LOGE("lost msg [%s], skip...", single_msg);
1927 remained_length = 0;
1929 strncpy(single_msg, recv_msg + prev_pos, single_length);
1930 single_msg[single_length] = '\0';
1933 if (single_msg[0] == '{') {
1935 /*LOGD("splitted msg : [%s], Index : %d", single_msg, num_msg);*/
1936 /* process each message */
1937 __camera_process_msg(cb_info, single_msg);
1939 LOGE("invalid msg [%s]", single_msg);
1942 LOGE("too long message [len %d] skip...", single_length);
1945 prev_pos = cur_pos + 1;
1949 /* check incompleted message */
1950 if (recv_msg[recv_length - 1] != '}') {
1951 remained_length = recv_length - prev_pos;
1953 LOGW("incompleted message [len %d]", remained_length);
1957 remained_msg = NULL;
1960 remained_msg = (char *)malloc(remained_length + 1);
1962 strncpy(remained_msg, recv_msg + prev_pos, remained_length);
1963 remained_msg[remained_length] = '\0';
1965 LOGE("failed to alloc for remained msg");
1968 remained_length = 0;
1972 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
1974 if (!cb_info->is_server_connected) {
1975 char *error_msg = NULL;
1977 if (cb_info->fd < 0) {
1978 LOGE("fd is closed in client side");
1979 goto CB_HANDLER_EXIT;
1982 /* send error msg for server disconnection */
1983 error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
1984 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
1985 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
1989 LOGE("error_msg failed");
1990 goto CB_HANDLER_EXIT;
1993 __camera_add_msg_to_queue(cb_info,
1994 MUSE_CAMERA_CB_EVENT,
1995 MUSE_CAMERA_EVENT_TYPE_ERROR,
1996 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
1999 muse_core_msg_free(error_msg);
2002 LOGE("add error msg for service disconnection done");
2013 remained_msg = NULL;
2020 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2021 int type, const char *thread_name, camera_cb_info_s *cb_info)
2023 if (!handler_info || !thread_name || !cb_info) {
2024 LOGE("t:%d NULL %p %p %p",
2025 type, handler_info, thread_name, cb_info);
2031 handler_info->type = type;
2032 handler_info->queue = g_queue_new();
2033 if (handler_info->queue == NULL) {
2034 LOGE("t:%d queue failed", type);
2038 g_mutex_init(&handler_info->mutex);
2039 g_cond_init(&handler_info->cond);
2041 handler_info->cb_info = (void *)cb_info;
2042 g_atomic_int_set(&handler_info->running, 1);
2044 handler_info->thread = g_thread_try_new(thread_name,
2045 _camera_msg_handler_func, (gpointer)handler_info, NULL);
2046 if (handler_info->thread == NULL) {
2047 LOGE("t:%d thread failed", type);
2049 g_mutex_clear(&handler_info->mutex);
2050 g_cond_clear(&handler_info->cond);
2051 g_queue_free(handler_info->queue);
2052 handler_info->queue = NULL;
2057 LOGD("t:%d done", type);
2063 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2067 if (!handler_info) {
2068 LOGE("NULL handler");
2072 if (!handler_info->thread) {
2073 LOGW("thread is not created");
2077 type = handler_info->type;
2079 LOGD("t:%d thread %p", type, handler_info->thread);
2081 g_mutex_lock(&handler_info->mutex);
2082 g_atomic_int_set(&handler_info->running, 0);
2083 g_cond_signal(&handler_info->cond);
2084 g_mutex_unlock(&handler_info->mutex);
2086 g_thread_join(handler_info->thread);
2087 handler_info->thread = NULL;
2089 g_mutex_clear(&handler_info->mutex);
2090 g_cond_clear(&handler_info->cond);
2091 g_queue_free(handler_info->queue);
2092 handler_info->queue = NULL;
2094 LOGD("t:%d done", type);
2100 static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
2102 camera_cb_info_s *cb_info = NULL;
2105 g_return_val_if_fail(sockfd > 0, NULL);
2107 cb_info = g_new0(camera_cb_info_s, 1);
2108 if (cb_info == NULL) {
2109 LOGE("cb_info failed");
2113 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2115 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2116 g_mutex_init(&cb_info->api_mutex[i]);
2117 g_cond_init(&cb_info->api_cond[i]);
2120 g_mutex_init(&cb_info->fd_lock);
2121 g_mutex_init(&cb_info->idle_event_mutex);
2122 g_cond_init(&cb_info->idle_event_cond);
2123 g_mutex_init(&cb_info->mp_data_mutex);
2125 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2126 g_mutex_init(&cb_info->user_cb_mutex[i]);
2128 /* message handler thread */
2129 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2130 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2131 LOGE("msg_handler_info failed");
2135 /* message handler thread for preview callback */
2136 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2137 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2138 LOGE("preview_cb_info failed");
2142 /* message handler thread for capture callback */
2143 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2144 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2145 LOGE("capture_cb_info failed");
2149 cb_info->fd = sockfd;
2150 cb_info->preview_cb_flag = 0;
2152 /* message receive thread */
2153 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2154 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2155 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2156 if (cb_info->msg_recv_thread == NULL) {
2157 LOGE("message receive thread creation failed");
2161 cb_info->is_server_connected = TRUE;
2167 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2168 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2169 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2171 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2172 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2174 g_mutex_clear(&cb_info->fd_lock);
2175 g_mutex_clear(&cb_info->idle_event_mutex);
2176 g_cond_clear(&cb_info->idle_event_cond);
2177 g_mutex_clear(&cb_info->mp_data_mutex);
2179 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2180 g_mutex_clear(&cb_info->api_mutex[i]);
2181 g_cond_clear(&cb_info->api_cond[i]);
2191 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2195 g_return_if_fail(cb_info != NULL);
2197 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2199 g_thread_join(cb_info->msg_recv_thread);
2200 cb_info->msg_recv_thread = NULL;
2202 LOGD("msg_recv thread removed");
2204 /* destroy msg handler threads */
2205 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2206 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2207 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2209 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2210 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2212 g_mutex_clear(&cb_info->fd_lock);
2213 g_mutex_clear(&cb_info->idle_event_mutex);
2214 g_cond_clear(&cb_info->idle_event_cond);
2215 g_mutex_clear(&cb_info->mp_data_mutex);
2217 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2218 g_mutex_clear(&cb_info->api_mutex[i]);
2219 g_cond_clear(&cb_info->api_cond[i]);
2222 if (cb_info->fd > -1) {
2223 muse_client_close(cb_info->fd);
2227 if (cb_info->bufmgr) {
2228 tbm_bufmgr_deinit(cb_info->bufmgr);
2229 cb_info->bufmgr = NULL;
2231 if (cb_info->pkt_fmt) {
2232 media_format_unref(cb_info->pkt_fmt);
2233 cb_info->pkt_fmt = NULL;
2236 if (cb_info->dp_interface) {
2237 mm_display_interface_deinit(cb_info->dp_interface);
2238 cb_info->dp_interface = NULL;
2241 cb_info->preview_cb_flag = 0;
2250 int _camera_start_evas_rendering(camera_h camera)
2252 camera_cli_s *pc = (camera_cli_s *)camera;
2254 if (!pc || !pc->cb_info) {
2255 LOGE("NULL handle");
2256 return CAMERA_ERROR_INVALID_PARAMETER;
2261 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2262 LOGE("EVAS surface is not set");
2263 return CAMERA_ERROR_NONE;
2266 /* set evas render flag as RUN */
2267 pc->cb_info->run_evas_render = true;
2269 return CAMERA_ERROR_NONE;
2273 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2275 int ret = CAMERA_ERROR_NONE;
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;
2283 LOGD("stop - keep screen %d", keep_screen);
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 STOP and release buffers */
2291 pc->cb_info->run_evas_render = false;
2293 ret = mm_display_interface_evas_flush(pc->cb_info->dp_interface, keep_screen);
2294 if (ret == MM_ERROR_NONE) {
2295 ret = CAMERA_ERROR_NONE;
2297 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2298 ret = CAMERA_ERROR_INVALID_OPERATION;
2305 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2307 int ret = CAMERA_ERROR_NONE;
2310 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2312 /* create muse connection */
2313 if (!key || !value) {
2314 LOGE("NULL pointer");
2315 return CAMERA_ERROR_INVALID_PARAMETER;
2318 sock_fd = muse_client_new();
2320 LOGE("muse_client_new failed");
2321 return CAMERA_ERROR_INVALID_OPERATION;
2324 msg = muse_core_msg_new(api,
2325 MUSE_TYPE_INT, "module", MUSE_CAMERA,
2326 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2330 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2334 ret = muse_core_msg_send(sock_fd, msg);
2336 muse_core_msg_free(msg);
2340 LOGE("send msg failed");
2341 ret = CAMERA_ERROR_INVALID_OPERATION;
2345 ret = muse_core_msg_recv(sock_fd, recv_msg);
2347 LOGE("recv msg failed %d", errno);
2348 ret = CAMERA_ERROR_INVALID_OPERATION;
2352 if (!muse_camera_msg_get(ret, recv_msg)) {
2353 LOGE("failed to get return value from msg [%s]", recv_msg);
2354 ret = CAMERA_ERROR_INVALID_OPERATION;
2358 if (ret == CAMERA_ERROR_NONE)
2359 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2361 LOGD("api %d - value %d", api, *value);
2365 muse_client_close(sock_fd);
2373 int camera_create(camera_device_e device, camera_h *camera)
2376 char *send_msg = NULL;
2378 int ret = CAMERA_ERROR_NONE;
2380 camera_cli_s *pc = NULL;
2381 tbm_bufmgr bufmgr = NULL;
2383 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2384 muse_core_api_module_e muse_module = MUSE_CAMERA;
2385 int device_type = (int)device;
2388 LOGE("NULL pointer");
2389 return CAMERA_ERROR_INVALID_PARAMETER;
2392 sock_fd = muse_client_new();
2394 LOGE("muse_client_new failed - returned fd %d", sock_fd);
2395 ret = CAMERA_ERROR_INVALID_OPERATION;
2401 send_msg = muse_core_msg_new(api,
2402 MUSE_TYPE_INT, "module", muse_module,
2403 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2404 MUSE_TYPE_INT, "pid", pid,
2409 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2413 send_ret = muse_core_msg_send(sock_fd, send_msg);
2415 muse_core_msg_free(send_msg);
2419 LOGE("send msg failed %d", errno);
2420 ret = CAMERA_ERROR_INVALID_OPERATION;
2424 pc = g_new0(camera_cli_s, 1);
2426 LOGE("camera_cli_s alloc failed");
2427 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2431 bufmgr = tbm_bufmgr_init(-1);
2432 if (bufmgr == NULL) {
2433 LOGE("get tbm bufmgr failed");
2434 ret = CAMERA_ERROR_INVALID_OPERATION;
2438 pc->cb_info = _camera_client_callback_new(sock_fd);
2439 if (pc->cb_info == NULL) {
2440 LOGE("cb_info alloc failed");
2441 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2447 LOGD("cb info : %d", pc->cb_info->fd);
2449 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2451 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2453 if (ret == CAMERA_ERROR_NONE) {
2454 intptr_t handle = 0;
2456 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2458 LOGE("Receiving Handle Failed!!");
2459 ret = CAMERA_ERROR_INVALID_OPERATION;
2463 pc->remote_handle = handle;
2464 pc->cb_info->bufmgr = bufmgr;
2466 ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL);
2467 if (ret != CAMERA_ERROR_NONE) {
2468 LOGE("init display failed 0x%x", ret);
2472 LOGD("camera create 0x%x", pc->remote_handle);
2474 *camera = (camera_h)pc;
2476 /* get display interface handle */
2477 if (mm_display_interface_init(&pc->cb_info->dp_interface) != MM_ERROR_NONE)
2478 LOGW("display interface init failed");
2480 /* get default preview format */
2481 if (camera_get_preview_format(*camera, &pc->cb_info->preview_format) != CAMERA_ERROR_NONE) {
2482 LOGW("get default preview format failed");
2483 pc->cb_info->preview_format = CAMERA_PIXEL_FORMAT_INVALID;
2493 tbm_bufmgr_deinit(bufmgr);
2498 muse_client_close(sock_fd);
2504 int temp_fd = pc->cb_info->fd;
2506 /* pc->cb_info->fd should be closed,
2507 because g_thread_join for msg_recv_thread is not returned
2508 in _camera_client_callback_destroy. */
2510 pc->cb_info->fd = -1;
2511 muse_client_close(temp_fd);
2514 _camera_client_callback_destroy(pc->cb_info);
2521 LOGE("camera create error : 0x%x", ret);
2527 int camera_change_device(camera_h camera, camera_device_e device)
2530 int ret = CAMERA_ERROR_NONE;
2531 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2532 camera_cli_s *pc = (camera_cli_s *)camera;
2533 camera_msg_param param;
2535 if (!pc || !pc->cb_info) {
2536 LOGE("NULL handle");
2537 return CAMERA_ERROR_INVALID_PARAMETER;
2540 CAMERA_MSG_PARAM_SET(param, INT, device);
2542 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2544 if (ret == CAMERA_ERROR_NONE) {
2545 /* reset callback and user data */
2546 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2547 pc->cb_info->user_cb[i] = NULL;
2548 pc->cb_info->user_data[i] = NULL;
2550 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
2557 int camera_destroy(camera_h camera)
2559 int ret = CAMERA_ERROR_NONE;
2560 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2561 camera_cli_s *pc = (camera_cli_s *)camera;
2563 if (!pc || !pc->cb_info) {
2564 LOGE("NULL handle");
2565 return CAMERA_ERROR_INVALID_PARAMETER;
2570 if (pc->cb_info->is_server_connected)
2571 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2573 LOGW("server disconnected. release resource without send message.");
2575 if (ret == CAMERA_ERROR_NONE) {
2576 _camera_deactivate_idle_event_all(pc->cb_info);
2577 _camera_client_callback_destroy(pc->cb_info);
2584 LOGD("ret : 0x%x", ret);
2589 int camera_start_preview(camera_h camera)
2591 int ret = CAMERA_ERROR_NONE;
2592 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2593 camera_cli_s *pc = (camera_cli_s *)camera;
2595 if (!pc || !pc->cb_info) {
2596 LOGE("NULL handle");
2597 return CAMERA_ERROR_INVALID_PARAMETER;
2600 LOGD("Enter : preview format %d, display type %d",
2601 pc->cb_info->preview_format, pc->cb_info->dp_type);
2603 if (pc->cb_info->preview_format == CAMERA_PIXEL_FORMAT_INVZ &&
2604 pc->cb_info->dp_type != CAMERA_DISPLAY_TYPE_NONE) {
2605 LOGE("CAMERA_DISPLAY_TYPE_NONE[current %d] should be set with INVZ format",
2606 pc->cb_info->dp_type);
2607 return CAMERA_ERROR_INVALID_OPERATION;
2610 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2611 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2612 ret = _camera_start_evas_rendering(camera);
2613 if (ret != CAMERA_ERROR_NONE) {
2614 LOGE("stop preview because of error");
2615 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, pc->cb_info, NULL, 0);
2619 LOGD("ret : 0x%x", ret);
2625 int camera_stop_preview(camera_h camera)
2627 int ret = CAMERA_ERROR_NONE;
2628 camera_cli_s *pc = (camera_cli_s *)camera;
2629 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2630 camera_state_e current_state = CAMERA_STATE_NONE;
2632 if (!pc || !pc->cb_info) {
2633 LOGE("NULL handle");
2634 return CAMERA_ERROR_INVALID_PARAMETER;
2639 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2640 ret = camera_get_state(camera, ¤t_state);
2641 if (ret != CAMERA_ERROR_NONE) {
2642 LOGE("failed to get current state 0x%x", ret);
2646 if (current_state == CAMERA_STATE_PREVIEW) {
2647 ret = _camera_stop_evas_rendering(camera, false);
2648 if (ret != CAMERA_ERROR_NONE)
2653 /* send stop preview message */
2654 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2656 if (ret != CAMERA_ERROR_NONE &&
2657 current_state == CAMERA_STATE_PREVIEW) {
2658 LOGW("restart evas rendering");
2659 _camera_start_evas_rendering(camera);
2662 LOGD("ret : 0x%x", ret);
2668 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2670 int ret = CAMERA_ERROR_NONE;
2671 camera_cli_s *pc = (camera_cli_s *)camera;
2672 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2674 if (!pc || !pc->cb_info) {
2675 LOGE("NULL handle");
2676 return CAMERA_ERROR_INVALID_PARAMETER;
2681 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2682 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2684 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2685 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2687 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2689 LOGD("ret : 0x%x", ret);
2695 bool camera_is_supported_continuous_capture(camera_h camera)
2697 int ret = CAMERA_ERROR_NONE;
2698 camera_cli_s *pc = (camera_cli_s *)camera;
2699 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2701 if (!pc || !pc->cb_info) {
2702 LOGE("NULL handle");
2703 return CAMERA_ERROR_INVALID_PARAMETER;
2708 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2711 LOGE("error is occurred 0x%x", ret);
2715 LOGD("ret : %d", ret);
2721 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)
2723 int ret = CAMERA_ERROR_NONE;
2724 camera_cli_s *pc = (camera_cli_s *)camera;
2725 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2726 camera_msg_param param;
2729 if (!pc || !pc->cb_info) {
2730 LOGE("NULL handle");
2731 return CAMERA_ERROR_INVALID_PARAMETER;
2736 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2737 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2739 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2740 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2742 value = (count << 16) | interval;
2743 CAMERA_MSG_PARAM_SET(param, INT, value);
2745 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2747 LOGD("ret : 0x%x", ret);
2753 int camera_stop_continuous_capture(camera_h camera)
2755 int ret = CAMERA_ERROR_NONE;
2756 camera_cli_s *pc = (camera_cli_s *)camera;
2757 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2759 if (!pc || !pc->cb_info) {
2760 LOGE("NULL handle");
2761 return CAMERA_ERROR_INVALID_PARAMETER;
2766 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2768 LOGD("ret : 0x%x", ret);
2774 bool camera_is_supported_face_detection(camera_h camera)
2776 int ret = CAMERA_ERROR_NONE;
2777 camera_cli_s *pc = (camera_cli_s *)camera;
2778 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2780 if (!pc || !pc->cb_info) {
2781 LOGE("NULL handle");
2782 return CAMERA_ERROR_INVALID_PARAMETER;
2787 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2790 LOGE("error is occurred 0x%x", ret);
2794 LOGD("ret : %d", ret);
2800 bool camera_is_supported_zero_shutter_lag(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_ZERO_SHUTTER_LAG;
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_media_packet_preview_cb(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_MEDIA_PACKET_PREVIEW_CB;
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);
2851 int camera_get_device_count(camera_h camera, int *device_count)
2853 int ret = CAMERA_ERROR_NONE;
2854 camera_cli_s *pc = (camera_cli_s *)camera;
2855 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2857 if (!pc || !pc->cb_info) {
2858 LOGE("NULL handle");
2859 return CAMERA_ERROR_INVALID_PARAMETER;
2864 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2866 if (ret == CAMERA_ERROR_NONE)
2867 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2869 LOGD("ret : 0x%x", ret);
2874 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2876 int ret = CAMERA_ERROR_NONE;
2877 camera_cli_s *pc = (camera_cli_s *)camera;
2878 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2880 if (!pc || !pc->cb_info) {
2881 LOGE("NULL handle");
2882 return CAMERA_ERROR_INVALID_PARAMETER;
2887 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2889 if (ret == CAMERA_ERROR_NONE) {
2890 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2892 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2893 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2895 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2898 LOGD("ret : 0x%x", ret);
2903 int camera_stop_face_detection(camera_h camera)
2905 int ret = CAMERA_ERROR_NONE;
2906 camera_cli_s *pc = (camera_cli_s *)camera;
2907 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
2909 if (!pc || !pc->cb_info) {
2910 LOGE("NULL handle");
2911 return CAMERA_ERROR_INVALID_PARAMETER;
2916 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2918 if (ret == CAMERA_ERROR_NONE) {
2919 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2921 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
2922 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
2924 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2927 LOGD("ret : 0x%x", ret);
2932 int camera_get_state(camera_h camera, camera_state_e *state)
2934 int ret = CAMERA_ERROR_NONE;
2935 camera_cli_s *pc = (camera_cli_s *)camera;
2936 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
2938 if (!pc || !pc->cb_info || !state) {
2939 LOGE("NULL pointer %p %p", pc, state);
2940 return CAMERA_ERROR_INVALID_PARAMETER;
2945 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2947 if (ret == CAMERA_ERROR_NONE)
2948 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
2950 LOGD("ret : 0x%x", ret);
2955 int camera_start_focusing(camera_h camera, bool continuous)
2957 int ret = CAMERA_ERROR_NONE;
2958 camera_cli_s *pc = (camera_cli_s *)camera;
2959 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
2960 camera_msg_param param;
2961 int is_continuous = (int)continuous;
2963 if (!pc || !pc->cb_info) {
2964 LOGE("NULL handle");
2965 return CAMERA_ERROR_INVALID_PARAMETER;
2970 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
2972 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2974 LOGD("ret : 0x%x", ret);
2979 int camera_cancel_focusing(camera_h camera)
2981 int ret = CAMERA_ERROR_NONE;
2982 camera_cli_s *pc = (camera_cli_s *)camera;
2983 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
2985 if (!pc || !pc->cb_info) {
2986 LOGE("NULL handle");
2987 return CAMERA_ERROR_INVALID_PARAMETER;
2990 LOGD("Enter, remote_handle : %x", pc->remote_handle);
2992 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2994 LOGD("ret : 0x%x", ret);
2999 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3001 int ret = CAMERA_ERROR_NONE;
3003 camera_cli_s *pc = (camera_cli_s *)camera;
3004 camera_cb_info_s *cb_info = NULL;
3005 camera_state_e current_state = CAMERA_STATE_NONE;
3006 camera_msg_param param0;
3007 camera_msg_param param1;
3008 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3010 if (!pc || !pc->cb_info) {
3011 LOGE("NULL handle");
3012 return CAMERA_ERROR_INVALID_PARAMETER;
3015 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
3016 LOGE("invalid type %d", type);
3017 return CAMERA_ERROR_INVALID_PARAMETER;
3020 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
3021 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
3022 return CAMERA_ERROR_INVALID_PARAMETER;
3025 cb_info = (camera_cb_info_s *)pc->cb_info;
3027 ret = camera_get_state(camera, ¤t_state);
3028 if (ret != CAMERA_ERROR_NONE) {
3029 LOGE("failed to get current state 0x%x", ret);
3033 if (current_state != CAMERA_STATE_CREATED) {
3034 LOGE("INVALID_STATE : current %d", current_state);
3035 return CAMERA_ERROR_INVALID_STATE;
3038 LOGD("Enter - type : %d, display : %p", type, display);
3040 if (type != CAMERA_DISPLAY_TYPE_NONE) {
3041 /* check display interface handle */
3042 if (!cb_info->dp_interface) {
3043 LOGE("display interface not supported");
3044 return CAMERA_ERROR_NOT_SUPPORTED;
3047 ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &parent_id);
3048 if (ret != MM_ERROR_NONE) {
3049 LOGE("[INVALID_OPERATION] set display failed[0x%x]", ret);
3050 return CAMERA_ERROR_INVALID_OPERATION;
3053 if (type == CAMERA_DISPLAY_TYPE_EVAS) {
3054 camera_flip_e flip = CAMERA_FLIP_NONE;
3055 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3056 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3063 camera_get_display_flip(camera, &flip);
3064 camera_get_display_mode(camera, &mode);
3065 camera_get_display_rotation(camera, &rotation);
3066 camera_is_display_visible(camera, &visible);
3067 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3069 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
3070 flip, mode, rotation, visible, x, y, width, height);
3072 ret = mm_display_interface_evas_set_flip(cb_info->dp_interface, flip);
3073 ret |= mm_display_interface_evas_set_mode(cb_info->dp_interface, mode);
3074 ret |= mm_display_interface_evas_set_rotation(cb_info->dp_interface, rotation);
3075 ret |= mm_display_interface_evas_set_visible(cb_info->dp_interface, visible);
3077 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
3078 ret |= mm_display_interface_evas_set_roi_area(cb_info->dp_interface, x, y, width, height);
3082 CAMERA_MSG_PARAM_SET(param0, INT, type);
3083 CAMERA_MSG_PARAM_SET(param1, INT, parent_id);
3085 _camera_msg_send_param2_int(api, cb_info, &ret,
3086 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
3088 if (ret == CAMERA_ERROR_NONE) {
3089 pc->cb_info->dp_type = type;
3091 if (type == CAMERA_DISPLAY_TYPE_EVAS)
3092 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3099 int camera_set_preview_resolution(camera_h camera, int width, int height)
3101 int ret = CAMERA_ERROR_NONE;
3102 camera_state_e current_state = CAMERA_STATE_NONE;
3103 camera_cli_s *pc = (camera_cli_s *)camera;
3104 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3105 camera_msg_param param;
3108 if (!pc || !pc->cb_info) {
3109 LOGE("NULL handle");
3110 return CAMERA_ERROR_INVALID_PARAMETER;
3113 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3114 ret = camera_get_state(camera, ¤t_state);
3115 if (ret != CAMERA_ERROR_NONE) {
3116 LOGE("failed to get current state 0x%x", ret);
3120 if (current_state == CAMERA_STATE_PREVIEW) {
3121 ret = _camera_stop_evas_rendering(camera, true);
3122 if (ret != CAMERA_ERROR_NONE)
3127 value = (width << 16) | height;
3128 CAMERA_MSG_PARAM_SET(param, INT, value);
3130 LOGD("%dx%d -> 0x%x", width, height, value);
3132 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3134 LOGD("ret : 0x%x", ret);
3136 if (current_state == CAMERA_STATE_PREVIEW) {
3137 LOGW("restart evas rendering");
3138 _camera_start_evas_rendering(camera);
3145 int camera_set_capture_resolution(camera_h camera, int width, int height)
3147 int ret = CAMERA_ERROR_NONE;
3148 camera_cli_s *pc = (camera_cli_s *)camera;
3149 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3150 camera_msg_param param;
3153 if (!pc || !pc->cb_info) {
3154 LOGE("NULL handle");
3155 return CAMERA_ERROR_INVALID_PARAMETER;
3160 value = (width << 16) | height;
3161 CAMERA_MSG_PARAM_SET(param, INT, value);
3163 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3165 LOGD("ret : 0x%x", ret);
3171 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3173 int ret = CAMERA_ERROR_NONE;
3174 int set_format = (int)format;
3175 camera_cli_s *pc = (camera_cli_s *)camera;
3176 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3177 camera_msg_param param;
3179 if (!pc || !pc->cb_info) {
3180 LOGE("NULL handle");
3181 return CAMERA_ERROR_INVALID_PARAMETER;
3184 LOGD("Enter - format %d", set_format);
3186 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3188 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3190 LOGD("ret : 0x%x", ret);
3196 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3198 int ret = CAMERA_ERROR_NONE;
3199 int set_format = (int)format;
3200 camera_msg_param param;
3201 camera_cli_s *pc = (camera_cli_s *)camera;
3202 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3204 if (!pc || !pc->cb_info) {
3205 LOGE("NULL handle");
3206 return CAMERA_ERROR_INVALID_PARAMETER;
3209 LOGD("Enter - capture_format %d", set_format);
3211 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3213 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3215 if (ret == CAMERA_ERROR_NONE)
3216 pc->cb_info->preview_format = set_format;
3218 LOGD("ret : 0x%x", ret);
3224 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3226 int ret = CAMERA_ERROR_NONE;
3227 camera_cli_s *pc = (camera_cli_s *)camera;
3228 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3230 if (!pc || !pc->cb_info || !width || !height) {
3231 LOGE("NULL pointer %p %p %p", pc, width, height);
3232 return CAMERA_ERROR_INVALID_PARAMETER;
3237 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3239 if (ret == CAMERA_ERROR_NONE) {
3240 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3241 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3244 LOGD("ret : 0x%x", ret);
3250 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3252 int ret = CAMERA_ERROR_NONE;
3253 int set_rotation = (int)rotation;
3254 camera_cli_s *pc = (camera_cli_s *)camera;
3255 camera_msg_param param;
3257 if (!pc || !pc->cb_info) {
3258 LOGE("NULL handle");
3259 return CAMERA_ERROR_INVALID_PARAMETER;
3262 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3263 ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
3264 if (ret != MM_ERROR_NONE) {
3265 LOGE("failed to set rotation for evas surface 0x%x", ret);
3266 return CAMERA_ERROR_INVALID_OPERATION;
3270 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3272 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3278 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3280 int ret = CAMERA_ERROR_NONE;
3281 camera_cli_s *pc = (camera_cli_s *)camera;
3283 if (!pc || !pc->cb_info || !rotation) {
3284 LOGE("NULL pointer %p %p", pc, rotation);
3285 return CAMERA_ERROR_INVALID_PARAMETER;
3288 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3290 if (ret == CAMERA_ERROR_NONE)
3291 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3297 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3299 int ret = CAMERA_ERROR_NONE;
3300 int set_flip = (int)flip;
3301 camera_cli_s *pc = (camera_cli_s *)camera;
3302 camera_msg_param param;
3304 if (!pc || !pc->cb_info) {
3305 LOGE("NULL handle");
3306 return CAMERA_ERROR_INVALID_PARAMETER;
3309 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3310 ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
3311 if (ret != MM_ERROR_NONE) {
3312 LOGE("failed to set flip for evas surface 0x%x", ret);
3313 return CAMERA_ERROR_INVALID_OPERATION;
3317 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3319 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3325 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3327 int ret = CAMERA_ERROR_NONE;
3328 camera_cli_s *pc = (camera_cli_s *)camera;
3330 if (!pc || !pc->cb_info || !flip) {
3331 LOGE("NULL pointer %p %p", pc, flip);
3332 return CAMERA_ERROR_INVALID_PARAMETER;
3335 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3337 if (ret == CAMERA_ERROR_NONE)
3338 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3344 int camera_set_display_visible(camera_h camera, bool visible)
3346 int ret = CAMERA_ERROR_NONE;
3347 int set_visible = (int)visible;
3348 camera_cli_s *pc = (camera_cli_s *)camera;
3349 camera_msg_param param;
3351 if (!pc || !pc->cb_info) {
3352 LOGE("NULL handle");
3353 return CAMERA_ERROR_INVALID_PARAMETER;
3356 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3357 ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
3358 if (ret != MM_ERROR_NONE) {
3359 LOGE("failed to set visible for evas surface 0x%x", ret);
3360 return CAMERA_ERROR_INVALID_OPERATION;
3364 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3366 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3372 int camera_is_display_visible(camera_h camera, bool *visible)
3374 int ret = CAMERA_ERROR_NONE;
3375 camera_cli_s *pc = (camera_cli_s *)camera;
3377 if (!pc || !pc->cb_info || !visible) {
3378 LOGE("NULL pointer %p %p", pc, visible);
3379 return CAMERA_ERROR_INVALID_PARAMETER;
3382 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3384 if (ret == CAMERA_ERROR_NONE)
3385 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3391 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3393 int ret = CAMERA_ERROR_NONE;
3394 int set_mode = (int)mode;
3395 camera_cli_s *pc = (camera_cli_s *)camera;
3396 camera_msg_param param;
3398 if (!pc || !pc->cb_info) {
3399 LOGE("NULL handle");
3400 return CAMERA_ERROR_INVALID_PARAMETER;
3403 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3404 ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
3405 if (ret != MM_ERROR_NONE) {
3406 LOGE("failed to set geometry for evas surface 0x%x", ret);
3407 return CAMERA_ERROR_INVALID_OPERATION;
3411 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3413 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3419 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3421 int ret = CAMERA_ERROR_NONE;
3422 camera_cli_s *pc = (camera_cli_s *)camera;
3424 if (!pc || !pc->cb_info || !mode) {
3425 LOGE("NULL pointer %p %p", pc, mode);
3426 return CAMERA_ERROR_INVALID_PARAMETER;
3429 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3431 if (ret == CAMERA_ERROR_NONE)
3432 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3438 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3440 int ret = CAMERA_ERROR_NONE;
3441 int set_hint = (int)hint;
3442 camera_cli_s *pc = (camera_cli_s *)camera;
3443 camera_msg_param param;
3445 if (!pc || !pc->cb_info) {
3446 LOGE("NULL handle");
3447 return CAMERA_ERROR_INVALID_PARAMETER;
3450 LOGD("Enter - hint %d", set_hint);
3452 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3454 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3460 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3462 int ret = CAMERA_ERROR_NONE;
3463 camera_cli_s *pc = (camera_cli_s *)camera;
3464 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3466 if (!pc || !pc->cb_info || !hint) {
3467 LOGE("NULL pointer %p %p", pc, hint);
3468 return CAMERA_ERROR_INVALID_PARAMETER;
3471 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3473 if (ret == CAMERA_ERROR_NONE) {
3474 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3475 LOGD("display reuse hint %d", *hint);
3482 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3484 int ret = CAMERA_ERROR_NONE;
3485 camera_cli_s *pc = (camera_cli_s *)camera;
3486 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3488 if (!pc || !pc->cb_info || !width || !height) {
3489 LOGE("NULL pointer %p %p %p", pc, width, height);
3490 return CAMERA_ERROR_INVALID_PARAMETER;
3495 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3497 if (ret == CAMERA_ERROR_NONE) {
3498 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3499 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3502 LOGD("ret : 0x%x", ret);
3508 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3510 int ret = CAMERA_ERROR_NONE;
3511 camera_cli_s *pc = (camera_cli_s *)camera;
3512 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3514 if (!pc || !pc->cb_info || !format) {
3515 LOGE("NULL pointer %p %p", pc, format);
3516 return CAMERA_ERROR_INVALID_PARAMETER;
3521 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3523 if (ret == CAMERA_ERROR_NONE)
3524 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3526 LOGD("ret : 0x%x", ret);
3532 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3534 int ret = CAMERA_ERROR_NONE;
3535 camera_cli_s *pc = (camera_cli_s *)camera;
3536 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3538 if (!pc || !pc->cb_info || !format) {
3539 LOGE("NULL pointer %p %p", pc, format);
3540 return CAMERA_ERROR_INVALID_PARAMETER;
3545 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3547 if (ret == CAMERA_ERROR_NONE)
3548 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3550 LOGD("ret : 0x%x", ret);
3556 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3558 int ret = CAMERA_ERROR_NONE;
3559 camera_cli_s *pc = (camera_cli_s *)camera;
3560 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3562 if (!pc || !pc->cb_info || !facing_direction) {
3563 LOGE("NULL pointer %p %p", pc, facing_direction);
3564 return CAMERA_ERROR_INVALID_PARAMETER;
3569 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3571 if (ret == CAMERA_ERROR_NONE)
3572 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3574 LOGD("ret : 0x%x", ret);
3580 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3582 int ret = CAMERA_ERROR_NONE;
3583 camera_cli_s *pc = (camera_cli_s *)camera;
3584 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3586 if (!pc || !pc->cb_info || !callback) {
3587 LOGE("NULL pointer %p %p", pc, callback);
3588 return CAMERA_ERROR_INVALID_PARAMETER;
3593 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3595 if (ret == CAMERA_ERROR_NONE) {
3596 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3598 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3599 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3601 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3603 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3606 LOGD("ret : 0x%x", ret);
3612 int camera_unset_preview_cb(camera_h camera)
3614 int ret = CAMERA_ERROR_NONE;
3615 camera_cli_s *pc = (camera_cli_s *)camera;
3616 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3618 if (!pc || !pc->cb_info) {
3619 LOGE("NULL handle");
3620 return CAMERA_ERROR_INVALID_PARAMETER;
3625 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3627 if (ret == CAMERA_ERROR_NONE) {
3628 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3630 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3631 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3633 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3635 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3638 LOGD("ret : 0x%x", ret);
3644 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3646 int ret = CAMERA_ERROR_NONE;
3647 camera_cli_s *pc = (camera_cli_s *)camera;
3648 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3650 if (!pc || !pc->cb_info) {
3651 LOGE("NULL handle");
3652 return CAMERA_ERROR_INVALID_PARAMETER;
3655 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3656 LOGE("NOT SUPPORTED");
3657 return CAMERA_ERROR_NOT_SUPPORTED;
3660 if (callback == NULL) {
3661 LOGE("NULL callback");
3662 return CAMERA_ERROR_INVALID_PARAMETER;
3667 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3669 if (ret == CAMERA_ERROR_NONE) {
3670 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3672 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3673 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3675 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3678 LOGD("ret : 0x%x", ret);
3684 int camera_unset_media_packet_preview_cb(camera_h camera)
3686 int ret = CAMERA_ERROR_NONE;
3687 camera_cli_s *pc = (camera_cli_s *)camera;
3688 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3690 if (!pc || !pc->cb_info) {
3691 LOGE("NULL handle");
3692 return CAMERA_ERROR_INVALID_PARAMETER;
3697 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3699 if (ret == CAMERA_ERROR_NONE) {
3700 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3702 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3703 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3705 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3708 LOGD("ret : 0x%x", ret);
3714 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3716 int ret = CAMERA_ERROR_NONE;
3717 camera_cli_s *pc = (camera_cli_s *)camera;
3718 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3720 if (!pc || !pc->cb_info || !callback) {
3721 LOGE("NULL pointer %p %p", pc, callback);
3722 return CAMERA_ERROR_INVALID_PARAMETER;
3727 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3729 if (ret == CAMERA_ERROR_NONE) {
3730 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3732 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3733 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3735 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3738 LOGD("ret : 0x%x", ret);
3744 int camera_unset_state_changed_cb(camera_h camera)
3746 int ret = CAMERA_ERROR_NONE;
3747 camera_cli_s *pc = (camera_cli_s *)camera;
3748 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3750 if (!pc || !pc->cb_info) {
3751 LOGE("NULL handle");
3752 return CAMERA_ERROR_INVALID_PARAMETER;
3757 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3759 if (ret == CAMERA_ERROR_NONE) {
3760 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3762 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3763 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3765 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3768 LOGD("ret : 0x%x", ret);
3774 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3776 int ret = CAMERA_ERROR_NONE;
3777 camera_cli_s *pc = (camera_cli_s *)camera;
3778 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3780 if (!pc || !pc->cb_info || !callback) {
3781 LOGE("NULL pointer %p %p", pc, callback);
3782 return CAMERA_ERROR_INVALID_PARAMETER;
3787 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3789 if (ret == CAMERA_ERROR_NONE) {
3790 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3792 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3793 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3795 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3798 LOGD("ret : 0x%x", ret);
3804 int camera_unset_interrupted_cb(camera_h camera)
3806 int ret = CAMERA_ERROR_NONE;
3807 camera_cli_s *pc = (camera_cli_s *)camera;
3808 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3810 if (!pc || !pc->cb_info) {
3811 LOGE("NULL handle");
3812 return CAMERA_ERROR_INVALID_PARAMETER;
3817 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3819 if (ret == CAMERA_ERROR_NONE) {
3820 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3822 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3823 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3825 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3828 LOGD("ret : 0x%x", ret);
3834 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
3836 int ret = CAMERA_ERROR_NONE;
3837 camera_cli_s *pc = (camera_cli_s *)camera;
3838 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
3840 if (!pc || !pc->cb_info || !callback) {
3841 LOGE("NULL pointer %p %p", pc, callback);
3842 return CAMERA_ERROR_INVALID_PARAMETER;
3847 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3849 if (ret == CAMERA_ERROR_NONE) {
3850 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3852 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
3853 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
3855 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3858 LOGD("ret : 0x%x", ret);
3864 int camera_unset_interrupt_started_cb(camera_h camera)
3866 int ret = CAMERA_ERROR_NONE;
3867 camera_cli_s *pc = (camera_cli_s *)camera;
3868 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
3870 if (!pc || !pc->cb_info) {
3871 LOGE("NULL handle");
3872 return CAMERA_ERROR_INVALID_PARAMETER;
3877 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3879 if (ret == CAMERA_ERROR_NONE) {
3880 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3882 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3883 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3885 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3888 LOGD("ret : 0x%x", ret);
3894 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
3896 int ret = CAMERA_ERROR_NONE;
3897 camera_cli_s *pc = (camera_cli_s *)camera;
3898 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3900 if (!pc || !pc->cb_info || !callback) {
3901 LOGE("NULL pointer %p %p", pc, callback);
3902 return CAMERA_ERROR_INVALID_PARAMETER;
3907 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3909 if (ret == CAMERA_ERROR_NONE) {
3910 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3912 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3913 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3915 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3918 LOGD("ret : 0x%x", ret);
3924 int camera_unset_focus_changed_cb(camera_h camera)
3926 int ret = CAMERA_ERROR_NONE;
3927 camera_cli_s *pc = (camera_cli_s *)camera;
3928 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
3930 if (!pc || !pc->cb_info) {
3931 LOGE("NULL handle");
3932 return CAMERA_ERROR_INVALID_PARAMETER;
3937 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3939 if (ret == CAMERA_ERROR_NONE) {
3940 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3942 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3943 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3945 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3948 LOGD("ret : 0x%x", ret);
3954 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
3956 int ret = CAMERA_ERROR_NONE;
3957 camera_cli_s *pc = (camera_cli_s *)camera;
3958 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
3960 if (!pc || !pc->cb_info || !callback) {
3961 LOGE("NULL pointer %p %p", pc, callback);
3962 return CAMERA_ERROR_INVALID_PARAMETER;
3967 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3969 if (ret == CAMERA_ERROR_NONE) {
3970 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3972 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
3973 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
3975 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3978 LOGD("ret : 0x%x", ret);
3984 int camera_unset_error_cb(camera_h camera)
3986 int ret = CAMERA_ERROR_NONE;
3987 camera_cli_s *pc = (camera_cli_s *)camera;
3988 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
3990 if (!pc || !pc->cb_info) {
3991 LOGE("NULL handle");
3992 return CAMERA_ERROR_INVALID_PARAMETER;
3997 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3999 if (ret == CAMERA_ERROR_NONE) {
4000 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4002 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4003 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4005 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4008 LOGD("ret : 0x%x", ret);
4014 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4016 int ret = CAMERA_ERROR_NONE;
4017 camera_cli_s *pc = (camera_cli_s *)camera;
4018 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4020 if (!pc || !pc->cb_info || !foreach_cb) {
4021 LOGE("NULL pointer %p %p", pc, foreach_cb);
4022 return CAMERA_ERROR_INVALID_PARAMETER;
4027 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4028 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4030 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4032 LOGD("ret : 0x%x", ret);
4038 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4040 int ret = CAMERA_ERROR_NONE;
4041 camera_cli_s *pc = (camera_cli_s *)camera;
4042 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4044 if (!pc || !pc->cb_info || !foreach_cb) {
4045 LOGE("NULL pointer %p %p", pc, foreach_cb);
4046 return CAMERA_ERROR_INVALID_PARAMETER;
4051 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4052 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4054 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4056 LOGD("ret : 0x%x", ret);
4062 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4064 int ret = CAMERA_ERROR_NONE;
4065 camera_cli_s *pc = (camera_cli_s *)camera;
4066 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4068 if (!pc || !pc->cb_info || !foreach_cb) {
4069 LOGE("NULL pointer %p %p", pc, foreach_cb);
4070 return CAMERA_ERROR_INVALID_PARAMETER;
4075 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4076 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4078 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4080 LOGD("ret : 0x%x", ret);
4086 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4088 int ret = CAMERA_ERROR_NONE;
4089 camera_cli_s *pc = (camera_cli_s *)camera;
4090 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4092 if (!pc || !pc->cb_info || !foreach_cb) {
4093 LOGE("NULL pointer %p %p", pc, foreach_cb);
4094 return CAMERA_ERROR_INVALID_PARAMETER;
4099 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4100 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4102 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4104 LOGD("ret : 0x%x", ret);
4110 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4112 int ret = CAMERA_ERROR_NONE;
4113 camera_cli_s *pc = (camera_cli_s *)camera;
4114 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4116 if (!pc || !pc->cb_info || !width || !height) {
4117 LOGE("NULL pointer %p %p %p", pc, width, height);
4118 return CAMERA_ERROR_INVALID_PARAMETER;
4122 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4124 if (ret == CAMERA_ERROR_NONE) {
4125 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4126 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4129 LOGD("ret : 0x%x", ret);
4135 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4137 int ret = CAMERA_ERROR_NONE;
4138 camera_cli_s *pc = (camera_cli_s *)camera;
4139 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4141 if (!pc || !pc->cb_info || !angle) {
4142 LOGE("NULL pointer %p %p", pc, angle);
4143 return CAMERA_ERROR_INVALID_PARAMETER;
4148 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4150 if (ret == CAMERA_ERROR_NONE)
4151 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4153 LOGD("ret : 0x%x", ret);
4159 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4161 int ret = CAMERA_ERROR_NONE;
4162 camera_cli_s *pc = (camera_cli_s *)camera;
4163 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4164 camera_msg_param param;
4165 int set_mode = (int)mode;
4167 if (!pc || !pc->cb_info) {
4168 LOGE("NULL handle");
4169 return CAMERA_ERROR_INVALID_PARAMETER;
4174 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4176 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4178 LOGD("ret : 0x%x", ret);
4184 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4186 int ret = CAMERA_ERROR_NONE;
4187 camera_cli_s *pc = (camera_cli_s *)camera;
4188 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4190 if (!pc || !pc->cb_info || !mode) {
4191 LOGE("NULL pointer %p %p", pc, mode);
4192 return CAMERA_ERROR_INVALID_PARAMETER;
4197 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4199 if (ret == CAMERA_ERROR_NONE)
4200 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4202 LOGD("ret : 0x%x", ret);
4208 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4210 int ret = CAMERA_ERROR_NONE;
4211 camera_cli_s *pc = (camera_cli_s *)camera;
4212 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4214 if (!pc || !pc->cb_info || !foreach_cb) {
4215 LOGE("NULL pointer %p %p", pc, foreach_cb);
4216 return CAMERA_ERROR_INVALID_PARAMETER;
4221 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4222 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4224 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4226 LOGD("Finish, return :%x", ret);
4232 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4234 int ret = CAMERA_ERROR_NONE;
4235 camera_cli_s *pc = (camera_cli_s *)camera;
4236 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4237 camera_msg_param param;
4238 int set_fps = (int)fps;
4240 if (!pc || !pc->cb_info) {
4241 LOGE("NULL handle");
4242 return CAMERA_ERROR_INVALID_PARAMETER;
4247 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4249 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4251 LOGD("ret : 0x%x", ret);
4257 int camera_attr_set_image_quality(camera_h camera, int quality)
4259 int ret = CAMERA_ERROR_NONE;
4260 camera_cli_s *pc = (camera_cli_s *)camera;
4261 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4262 camera_msg_param param;
4264 if (!pc || !pc->cb_info) {
4265 LOGE("NULL handle");
4266 return CAMERA_ERROR_INVALID_PARAMETER;
4271 CAMERA_MSG_PARAM_SET(param, INT, quality);
4273 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4275 LOGD("ret : 0x%x", ret);
4281 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4283 int ret = CAMERA_ERROR_NONE;
4284 camera_cli_s *pc = (camera_cli_s *)camera;
4285 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4287 if (!pc || !pc->cb_info || !fps) {
4288 LOGE("NULL pointer %p %p", pc, fps);
4289 return CAMERA_ERROR_INVALID_PARAMETER;
4294 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4296 if (ret == CAMERA_ERROR_NONE)
4297 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4299 LOGD("ret : 0x%x", ret);
4305 int camera_attr_get_image_quality(camera_h camera, int *quality)
4307 int ret = CAMERA_ERROR_NONE;
4308 camera_cli_s *pc = (camera_cli_s *)camera;
4309 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4311 if (!pc || !pc->cb_info || !quality) {
4312 LOGE("NULL pointer %p %p", pc, quality);
4313 return CAMERA_ERROR_INVALID_PARAMETER;
4318 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4320 if (ret == CAMERA_ERROR_NONE)
4321 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4323 LOGD("ret : 0x%x", ret);
4329 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4331 int ret = CAMERA_ERROR_NONE;
4332 camera_cli_s *pc = (camera_cli_s *)camera;
4333 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4335 if (!pc || !pc->cb_info || !bitrate) {
4336 LOGE("NULL pointer %p %p", pc, bitrate);
4337 return CAMERA_ERROR_INVALID_PARAMETER;
4342 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4344 if (ret == CAMERA_ERROR_NONE)
4345 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4347 LOGD("ret : 0x%x", ret);
4353 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4355 int ret = CAMERA_ERROR_NONE;
4356 camera_cli_s *pc = (camera_cli_s *)camera;
4357 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4358 camera_msg_param param;
4359 int set_bitrate = bitrate;
4361 if (!pc || !pc->cb_info) {
4362 LOGE("NULL handle");
4363 return CAMERA_ERROR_INVALID_PARAMETER;
4368 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4370 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4372 LOGD("ret : 0x%x", ret);
4378 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4380 int ret = CAMERA_ERROR_NONE;
4381 camera_cli_s *pc = (camera_cli_s *)camera;
4382 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4384 if (!pc || !pc->cb_info || !interval) {
4385 LOGE("NULL pointer %p %p", pc, interval);
4386 return CAMERA_ERROR_INVALID_PARAMETER;
4391 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4393 if (ret == CAMERA_ERROR_NONE)
4394 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4396 LOGD("ret : 0x%x", ret);
4402 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4404 int ret = CAMERA_ERROR_NONE;
4405 camera_cli_s *pc = (camera_cli_s *)camera;
4406 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4407 camera_msg_param param;
4408 int set_gop_interval = interval;
4410 if (!pc || !pc->cb_info) {
4411 LOGE("NULL handle");
4412 return CAMERA_ERROR_INVALID_PARAMETER;
4417 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4419 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4421 LOGD("ret : 0x%x", ret);
4427 int camera_attr_set_zoom(camera_h camera, int zoom)
4429 int ret = CAMERA_ERROR_NONE;
4430 camera_cli_s *pc = (camera_cli_s *)camera;
4431 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4432 camera_msg_param param;
4434 if (!pc || !pc->cb_info) {
4435 LOGE("NULL handle");
4436 return CAMERA_ERROR_INVALID_PARAMETER;
4439 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4441 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4443 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4445 LOGD("ret : 0x%x", ret);
4451 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4453 int ret = CAMERA_ERROR_NONE;
4454 camera_cli_s *pc = (camera_cli_s *)camera;
4455 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4456 camera_msg_param param;
4457 int set_mode = (int)mode;
4459 if (!pc || !pc->cb_info) {
4460 LOGE("NULL handle");
4461 return CAMERA_ERROR_INVALID_PARAMETER;
4464 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4466 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4468 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4474 int camera_attr_set_af_area(camera_h camera, int x, int y)
4476 int ret = CAMERA_ERROR_NONE;
4477 camera_cli_s *pc = (camera_cli_s *)camera;
4478 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4479 camera_msg_param param;
4482 if (!pc || !pc->cb_info) {
4483 LOGE("NULL handle");
4484 return CAMERA_ERROR_INVALID_PARAMETER;
4487 LOGD("Enter - %d,%d", x, y);
4489 value = (x << 16) | y;
4490 CAMERA_MSG_PARAM_SET(param, INT, value);
4492 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4494 LOGD("ret : 0x%x", ret);
4500 int camera_attr_clear_af_area(camera_h camera)
4502 int ret = CAMERA_ERROR_NONE;
4503 camera_cli_s *pc = (camera_cli_s *)camera;
4504 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4506 if (!pc || !pc->cb_info) {
4507 LOGE("NULL handle");
4508 return CAMERA_ERROR_INVALID_PARAMETER;
4513 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4515 LOGD("ret : 0x%x", ret);
4521 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4523 int ret = CAMERA_ERROR_NONE;
4524 camera_cli_s *pc = (camera_cli_s *)camera;
4525 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4526 camera_msg_param param;
4527 int set_mode = (int)mode;
4529 if (!pc || !pc->cb_info) {
4530 LOGE("NULL handle");
4531 return CAMERA_ERROR_INVALID_PARAMETER;
4536 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4538 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4540 LOGD("ret : 0x%x", ret);
4546 int camera_attr_set_exposure(camera_h camera, int value)
4548 int ret = CAMERA_ERROR_NONE;
4549 camera_cli_s *pc = (camera_cli_s *)camera;
4550 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4551 camera_msg_param param;
4553 if (!pc || !pc->cb_info) {
4554 LOGE("NULL handle");
4555 return CAMERA_ERROR_INVALID_PARAMETER;
4560 CAMERA_MSG_PARAM_SET(param, INT, value);
4562 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4564 LOGD("ret : 0x%x", ret);
4570 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4572 int ret = CAMERA_ERROR_NONE;
4573 camera_cli_s *pc = (camera_cli_s *)camera;
4574 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4575 camera_msg_param param;
4576 int set_iso = (int)iso;
4578 if (!pc || !pc->cb_info) {
4579 LOGE("NULL handle");
4580 return CAMERA_ERROR_INVALID_PARAMETER;
4585 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4587 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4589 LOGD("ret : 0x%x", ret);
4595 int camera_attr_set_brightness(camera_h camera, int level)
4597 int ret = CAMERA_ERROR_NONE;
4598 camera_cli_s *pc = (camera_cli_s *)camera;
4599 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4600 camera_msg_param param;
4602 if (!pc || !pc->cb_info) {
4603 LOGE("NULL handle");
4604 return CAMERA_ERROR_INVALID_PARAMETER;
4609 CAMERA_MSG_PARAM_SET(param, INT, level);
4611 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4613 LOGD("ret : 0x%x", ret);
4619 int camera_attr_set_contrast(camera_h camera, int level)
4621 int ret = CAMERA_ERROR_NONE;
4622 camera_cli_s *pc = (camera_cli_s *)camera;
4623 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4624 camera_msg_param param;
4626 if (!pc || !pc->cb_info) {
4627 LOGE("NULL handle");
4628 return CAMERA_ERROR_INVALID_PARAMETER;
4633 CAMERA_MSG_PARAM_SET(param, INT, level);
4635 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4637 LOGD("ret : 0x%x", ret);
4643 int camera_attr_set_hue(camera_h camera, int level)
4645 int ret = CAMERA_ERROR_NONE;
4646 camera_cli_s *pc = (camera_cli_s *)camera;
4647 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HUE;
4648 camera_msg_param param;
4650 if (!pc || !pc->cb_info) {
4651 LOGE("NULL handle");
4652 return CAMERA_ERROR_INVALID_PARAMETER;
4657 CAMERA_MSG_PARAM_SET(param, INT, level);
4659 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4661 LOGD("ret : 0x%x", ret);
4667 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4669 int ret = CAMERA_ERROR_NONE;
4670 camera_cli_s *pc = (camera_cli_s *)camera;
4671 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4672 camera_msg_param param;
4673 int set_whitebalance = (int)wb;
4675 if (!pc || !pc->cb_info) {
4676 LOGE("NULL handle");
4677 return CAMERA_ERROR_INVALID_PARAMETER;
4682 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4684 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4686 LOGD("ret : 0x%x", ret);
4692 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4694 int ret = CAMERA_ERROR_NONE;
4695 camera_cli_s *pc = (camera_cli_s *)camera;
4696 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4697 camera_msg_param param;
4698 int set_effect = (int)effect;
4700 if (!pc || !pc->cb_info) {
4701 LOGE("NULL handle");
4702 return CAMERA_ERROR_INVALID_PARAMETER;
4707 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4709 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4711 LOGD("ret : 0x%x", ret);
4717 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4719 int ret = CAMERA_ERROR_NONE;
4720 camera_cli_s *pc = (camera_cli_s *)camera;
4721 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4722 camera_msg_param param;
4723 int set_mode = (int)mode;
4725 if (!pc || !pc->cb_info) {
4726 LOGE("NULL handle");
4727 return CAMERA_ERROR_INVALID_PARAMETER;
4732 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4734 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4736 LOGD("ret : 0x%x", ret);
4742 int camera_attr_enable_tag(camera_h camera, bool enable)
4744 int ret = CAMERA_ERROR_NONE;
4745 camera_cli_s *pc = (camera_cli_s *)camera;
4746 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4747 camera_msg_param param;
4748 int set_enable = (int)enable;
4750 if (!pc || !pc->cb_info) {
4751 LOGE("NULL handle");
4752 return CAMERA_ERROR_INVALID_PARAMETER;
4757 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4759 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4761 LOGD("ret : 0x%x", ret);
4767 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4769 int ret = CAMERA_ERROR_NONE;
4770 camera_cli_s *pc = (camera_cli_s *)camera;
4771 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4772 camera_msg_param param;
4774 if (!pc || !pc->cb_info || !description) {
4775 LOGE("NULL pointer %p %p", pc, description);
4776 return CAMERA_ERROR_INVALID_PARAMETER;
4781 CAMERA_MSG_PARAM_SET(param, STRING, description);
4783 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4785 LOGD("ret : 0x%x", ret);
4791 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4793 int ret = CAMERA_ERROR_NONE;
4794 camera_cli_s *pc = (camera_cli_s *)camera;
4795 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4796 camera_msg_param param;
4797 int set_orientation = (int)orientation;
4799 if (!pc || !pc->cb_info) {
4800 LOGE("NULL handle");
4801 return CAMERA_ERROR_INVALID_PARAMETER;
4806 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4808 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4810 LOGD("ret : 0x%x", ret);
4816 int camera_attr_set_tag_software(camera_h camera, const char *software)
4818 int ret = CAMERA_ERROR_NONE;
4819 camera_cli_s *pc = (camera_cli_s *)camera;
4820 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4821 camera_msg_param param;
4823 if (!pc || !pc->cb_info || !software) {
4824 LOGE("NULL pointer %p %p", pc, software);
4825 return CAMERA_ERROR_INVALID_PARAMETER;
4828 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4830 CAMERA_MSG_PARAM_SET(param, STRING, software);
4832 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4834 LOGD("ret : 0x%x", ret);
4840 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4842 int ret = CAMERA_ERROR_NONE;
4843 camera_cli_s *pc = (camera_cli_s *)camera;
4844 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4845 double set_geotag[3] = {latitude, longitude, altitude};
4850 if (!pc || !pc->cb_info) {
4851 LOGE("NULL handle");
4852 return CAMERA_ERROR_INVALID_PARAMETER;
4857 length = sizeof(set_geotag) / sizeof(int) + \
4858 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4860 msg = muse_core_msg_new(api,
4861 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4864 LOGE("msg creation failed: api %d", api);
4865 return CAMERA_ERROR_OUT_OF_MEMORY;
4868 if (pc->cb_info->is_server_connected) {
4869 __camera_update_api_waiting(pc->cb_info, api, 1);
4871 g_mutex_lock(&pc->cb_info->fd_lock);
4872 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
4873 g_mutex_unlock(&pc->cb_info->fd_lock);
4877 LOGE("message send failed");
4878 ret = CAMERA_ERROR_INVALID_OPERATION;
4880 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
4883 __camera_update_api_waiting(pc->cb_info, api, -1);
4885 muse_core_msg_free(msg);
4887 LOGD("ret : 0x%x", ret);
4893 int camera_attr_remove_geotag(camera_h camera)
4895 int ret = CAMERA_ERROR_NONE;
4896 camera_cli_s *pc = (camera_cli_s *)camera;
4897 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4899 if (!pc || !pc->cb_info) {
4900 LOGE("NULL handle");
4901 return CAMERA_ERROR_INVALID_PARAMETER;
4906 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4908 LOGD("ret : 0x%x", ret);
4914 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4916 int ret = CAMERA_ERROR_NONE;
4917 camera_cli_s *pc = (camera_cli_s *)camera;
4918 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
4919 camera_msg_param param;
4920 int set_mode = (int)mode;
4922 if (!pc || !pc->cb_info) {
4923 LOGE("NULL handle");
4924 return CAMERA_ERROR_INVALID_PARAMETER;
4929 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4931 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4933 LOGD("ret : 0x%x", ret);
4939 int camera_attr_get_zoom(camera_h camera, int *zoom)
4941 int ret = CAMERA_ERROR_NONE;
4942 camera_cli_s *pc = (camera_cli_s *)camera;
4943 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4945 if (!pc || !pc->cb_info || !zoom) {
4946 LOGE("NULL pointer %p %p", pc, zoom);
4947 return CAMERA_ERROR_INVALID_PARAMETER;
4952 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4954 if (ret == CAMERA_ERROR_NONE)
4955 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
4957 LOGD("ret : 0x%x", ret);
4963 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
4965 int ret = CAMERA_ERROR_NONE;
4966 camera_cli_s *pc = (camera_cli_s *)camera;
4967 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
4969 if (!pc || !pc->cb_info || !min || !max) {
4970 LOGE("NULL pointer %p %p %p", pc, min, max);
4971 return CAMERA_ERROR_INVALID_PARAMETER;
4976 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4978 if (ret == CAMERA_ERROR_NONE) {
4979 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
4980 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
4983 LOGD("ret : 0x%x", ret);
4989 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
4991 int ret = CAMERA_ERROR_NONE;
4992 camera_cli_s *pc = (camera_cli_s *)camera;
4993 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
4995 if (!pc || !pc->cb_info || !mode) {
4996 LOGE("NULL pointer %p %p", pc, mode);
4997 return CAMERA_ERROR_INVALID_PARAMETER;
5002 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5004 if (ret == CAMERA_ERROR_NONE)
5005 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5007 LOGD("ret : 0x%x", ret);
5013 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5015 int ret = CAMERA_ERROR_NONE;
5016 camera_cli_s *pc = (camera_cli_s *)camera;
5017 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5019 if (!pc || !pc->cb_info || !mode) {
5020 LOGE("NULL pointer %p %p", pc, mode);
5021 return CAMERA_ERROR_INVALID_PARAMETER;
5026 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5028 if (ret == CAMERA_ERROR_NONE)
5029 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5031 LOGD("ret : 0x%x", ret);
5037 int camera_attr_get_exposure(camera_h camera, int *value)
5039 int ret = CAMERA_ERROR_NONE;
5040 camera_cli_s *pc = (camera_cli_s *)camera;
5041 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5043 if (!pc || !pc->cb_info || !value) {
5044 LOGE("NULL pointer %p %p", pc, value);
5045 return CAMERA_ERROR_INVALID_PARAMETER;
5050 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5052 if (ret == CAMERA_ERROR_NONE)
5053 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5055 LOGD("ret : 0x%x", ret);
5061 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5063 int ret = CAMERA_ERROR_NONE;
5064 camera_cli_s *pc = (camera_cli_s *)camera;
5065 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5067 if (!pc || !pc->cb_info || !min || !max) {
5068 LOGE("NULL pointer %p %p %p", pc, min, max);
5069 return CAMERA_ERROR_INVALID_PARAMETER;
5074 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5076 if (ret == CAMERA_ERROR_NONE) {
5077 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5078 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5081 LOGD("ret : 0x%x", ret);
5087 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5089 int ret = CAMERA_ERROR_NONE;
5090 camera_cli_s *pc = (camera_cli_s *)camera;
5091 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5093 if (!pc || !pc->cb_info || !iso) {
5094 LOGE("NULL pointer %p %p", pc, iso);
5095 return CAMERA_ERROR_INVALID_PARAMETER;
5100 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5102 if (ret == CAMERA_ERROR_NONE)
5103 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5105 LOGD("ret : 0x%x", ret);
5111 int camera_attr_get_brightness(camera_h camera, int *level)
5113 int ret = CAMERA_ERROR_NONE;
5114 camera_cli_s *pc = (camera_cli_s *)camera;
5115 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5117 if (!pc || !pc->cb_info || !level) {
5118 LOGE("NULL pointer %p %p", pc, level);
5119 return CAMERA_ERROR_INVALID_PARAMETER;
5124 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5126 if (ret == CAMERA_ERROR_NONE)
5127 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5129 LOGD("ret : 0x%x", ret);
5135 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5137 int ret = CAMERA_ERROR_NONE;
5138 camera_cli_s *pc = (camera_cli_s *)camera;
5139 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5141 if (!pc || !pc->cb_info || !min || !max) {
5142 LOGE("NULL pointer %p %p %p", pc, min, max);
5143 return CAMERA_ERROR_INVALID_PARAMETER;
5148 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5150 if (ret == CAMERA_ERROR_NONE) {
5151 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5152 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5155 LOGD("ret : 0x%x", ret);
5161 int camera_attr_get_contrast(camera_h camera, int *level)
5163 int ret = CAMERA_ERROR_NONE;
5164 camera_cli_s *pc = (camera_cli_s *)camera;
5165 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5167 if (!pc || !pc->cb_info || !level) {
5168 LOGE("NULL pointer %p %p", pc, level);
5169 return CAMERA_ERROR_INVALID_PARAMETER;
5174 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5176 if (ret == CAMERA_ERROR_NONE)
5177 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5179 LOGD("ret : 0x%x", ret);
5185 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5187 int ret = CAMERA_ERROR_NONE;
5188 camera_cli_s *pc = (camera_cli_s *)camera;
5189 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5191 if (!pc || !pc->cb_info || !min || !max) {
5192 LOGE("NULL pointer %p %p %p", pc, min, max);
5193 return CAMERA_ERROR_INVALID_PARAMETER;
5198 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5200 if (ret == CAMERA_ERROR_NONE) {
5201 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5202 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5203 LOGD("min %d, max %d", *min, *max);
5206 LOGD("ret : 0x%x", ret);
5212 int camera_attr_get_hue(camera_h camera, int *level)
5214 int ret = CAMERA_ERROR_NONE;
5215 camera_cli_s *pc = (camera_cli_s *)camera;
5216 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE;
5218 if (!pc || !pc->cb_info || !level) {
5219 LOGE("NULL pointer %p %p", pc, level);
5220 return CAMERA_ERROR_INVALID_PARAMETER;
5225 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5227 if (ret == CAMERA_ERROR_NONE)
5228 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HUE];
5230 LOGD("ret : 0x%x", ret);
5236 int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
5238 int ret = CAMERA_ERROR_NONE;
5239 camera_cli_s *pc = (camera_cli_s *)camera;
5240 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE_RANGE;
5242 if (!pc || !pc->cb_info || !min || !max) {
5243 LOGE("NULL pointer %p %p %p", pc, min, max);
5244 return CAMERA_ERROR_INVALID_PARAMETER;
5249 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5251 if (ret == CAMERA_ERROR_NONE) {
5252 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][0];
5253 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][1];
5254 LOGD("min %d, max %d", *min, *max);
5257 LOGD("ret : 0x%x", ret);
5263 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5265 int ret = CAMERA_ERROR_NONE;
5266 camera_cli_s *pc = (camera_cli_s *)camera;
5267 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5269 if (!pc || !pc->cb_info || !wb) {
5270 LOGE("NULL pointer %p %p", pc, wb);
5271 return CAMERA_ERROR_INVALID_PARAMETER;
5276 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5278 if (ret == CAMERA_ERROR_NONE)
5279 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5281 LOGD("ret : 0x%x", ret);
5287 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5289 int ret = CAMERA_ERROR_NONE;
5290 camera_cli_s *pc = (camera_cli_s *)camera;
5291 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5293 if (!pc || !pc->cb_info || !effect) {
5294 LOGE("NULL pointer %p %p", pc, effect);
5295 return CAMERA_ERROR_INVALID_PARAMETER;
5300 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5302 if (ret == CAMERA_ERROR_NONE)
5303 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5305 LOGD("ret : 0x%x", ret);
5311 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5313 int ret = CAMERA_ERROR_NONE;
5314 camera_cli_s *pc = (camera_cli_s *)camera;
5315 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5317 if (!pc || !pc->cb_info || !mode) {
5318 LOGE("NULL pointer %p %p", pc, mode);
5319 return CAMERA_ERROR_INVALID_PARAMETER;
5324 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5326 if (ret == CAMERA_ERROR_NONE)
5327 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5329 LOGD("ret : 0x%x", ret);
5335 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5337 int ret = CAMERA_ERROR_NONE;
5338 camera_cli_s *pc = (camera_cli_s *)camera;
5339 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5341 if (!pc || !pc->cb_info || !enable) {
5342 LOGE("NULL pointer %p %p", pc, enable);
5343 return CAMERA_ERROR_INVALID_PARAMETER;
5348 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5350 if (ret == CAMERA_ERROR_NONE)
5351 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5353 LOGD("ret : 0x%x", ret);
5359 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5361 int ret = CAMERA_ERROR_NONE;
5362 camera_cli_s *pc = (camera_cli_s *)camera;
5363 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5365 if (!pc || !pc->cb_info || !description) {
5366 LOGE("NULL pointer %p %p", pc, description);
5367 return CAMERA_ERROR_INVALID_PARAMETER;
5372 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5374 if (ret == CAMERA_ERROR_NONE)
5375 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5377 LOGD("ret : 0x%x", ret);
5383 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5385 int ret = CAMERA_ERROR_NONE;
5386 camera_cli_s *pc = (camera_cli_s *)camera;
5387 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5389 if (!pc || !pc->cb_info || !orientation) {
5390 LOGE("NULL pointer %p %p", pc, orientation);
5391 return CAMERA_ERROR_INVALID_PARAMETER;
5396 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5398 if (ret == CAMERA_ERROR_NONE)
5399 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5401 LOGD("ret : 0x%x", ret);
5407 int camera_attr_get_tag_software(camera_h camera, char **software)
5409 int ret = CAMERA_ERROR_NONE;
5410 camera_cli_s *pc = (camera_cli_s *)camera;
5411 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5413 if (!pc || !pc->cb_info || !software) {
5414 LOGE("NULL pointer %p %p", pc, software);
5415 return CAMERA_ERROR_INVALID_PARAMETER;
5420 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5422 if (ret == CAMERA_ERROR_NONE)
5423 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5425 LOGD("ret : 0x%x", ret);
5431 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5433 int ret = CAMERA_ERROR_NONE;
5434 camera_cli_s *pc = (camera_cli_s *)camera;
5435 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5437 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5438 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5439 return CAMERA_ERROR_INVALID_PARAMETER;
5444 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5446 if (ret == CAMERA_ERROR_NONE) {
5447 *latitude = pc->cb_info->get_geotag[0];
5448 *longitude = pc->cb_info->get_geotag[1];
5449 *altitude = pc->cb_info->get_geotag[2];
5452 LOGD("ret : 0x%x", ret);
5458 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5460 int ret = CAMERA_ERROR_NONE;
5461 camera_cli_s *pc = (camera_cli_s *)camera;
5462 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5464 if (!pc || !pc->cb_info || !mode) {
5465 LOGE("NULL pointer %p %p", pc, mode);
5466 return CAMERA_ERROR_INVALID_PARAMETER;
5471 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5473 if (ret == CAMERA_ERROR_NONE)
5474 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5476 LOGD("ret : 0x%x", ret);
5482 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5484 int ret = CAMERA_ERROR_NONE;
5485 int get_flash_state = 0;
5488 LOGE("NULL pointer");
5489 return CAMERA_ERROR_INVALID_PARAMETER;
5492 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5493 (int)device, "get_flash_state", &get_flash_state);
5495 if (ret == CAMERA_ERROR_NONE) {
5496 *state = (camera_flash_state_e)get_flash_state;
5497 LOGD("flash state %d", *state);
5499 LOGE("failed 0x%x", ret);
5506 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5508 int ret = CAMERA_ERROR_NONE;
5509 camera_cli_s *pc = (camera_cli_s *)camera;
5510 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5512 if (!pc || !pc->cb_info || !foreach_cb) {
5513 LOGE("NULL pointer %p %p", pc, foreach_cb);
5514 return CAMERA_ERROR_INVALID_PARAMETER;
5519 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5520 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5522 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5524 LOGD("ret : 0x%x", ret);
5530 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5532 int ret = CAMERA_ERROR_NONE;
5533 camera_cli_s *pc = (camera_cli_s *)camera;
5534 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5536 if (!pc || !pc->cb_info || !foreach_cb) {
5537 LOGE("NULL pointer %p %p", pc, foreach_cb);
5538 return CAMERA_ERROR_INVALID_PARAMETER;
5543 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5544 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5546 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5548 LOGD("ret : 0x%x", ret);
5554 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5556 int ret = CAMERA_ERROR_NONE;
5557 camera_cli_s *pc = (camera_cli_s *)camera;
5558 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5560 if (!pc || !pc->cb_info || !foreach_cb) {
5561 LOGE("NULL pointer %p %p", pc, foreach_cb);
5562 return CAMERA_ERROR_INVALID_PARAMETER;
5567 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5568 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5570 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5572 LOGD("ret : 0x%x", ret);
5578 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5580 int ret = CAMERA_ERROR_NONE;
5581 camera_cli_s *pc = (camera_cli_s *)camera;
5582 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5584 if (!pc || !pc->cb_info || !foreach_cb) {
5585 LOGE("NULL pointer %p %p", pc, foreach_cb);
5586 return CAMERA_ERROR_INVALID_PARAMETER;
5591 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5592 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5594 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5596 LOGD("ret : 0x%x", ret);
5602 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5604 int ret = CAMERA_ERROR_NONE;
5605 camera_cli_s *pc = (camera_cli_s *)camera;
5606 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5608 if (!pc || !pc->cb_info || !foreach_cb) {
5609 LOGE("NULL pointer %p %p", pc, foreach_cb);
5610 return CAMERA_ERROR_INVALID_PARAMETER;
5615 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5616 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5618 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5620 LOGD("ret : 0x%x", ret);
5626 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5628 int ret = CAMERA_ERROR_NONE;
5629 camera_cli_s *pc = (camera_cli_s *)camera;
5630 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5632 if (!pc || !pc->cb_info || !foreach_cb) {
5633 LOGE("NULL pointer %p %p", pc, foreach_cb);
5634 return CAMERA_ERROR_INVALID_PARAMETER;
5639 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5640 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5642 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5644 LOGD("ret : 0x%x", ret);
5650 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5652 int ret = CAMERA_ERROR_NONE;
5653 camera_cli_s *pc = (camera_cli_s *)camera;
5654 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5656 if (!pc || !pc->cb_info || !foreach_cb) {
5657 LOGE("NULL pointer %p %p", pc, foreach_cb);
5658 return CAMERA_ERROR_INVALID_PARAMETER;
5663 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5664 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5666 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5668 LOGD("ret : 0x%x", ret);
5674 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5676 int ret = CAMERA_ERROR_NONE;
5677 camera_cli_s *pc = (camera_cli_s *)camera;
5678 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5680 if (!pc || !pc->cb_info || !foreach_cb) {
5681 LOGE("NULL pointer %p %p", pc, foreach_cb);
5682 return CAMERA_ERROR_INVALID_PARAMETER;
5687 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5688 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5690 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5692 LOGD("Enter, handle :%x", pc->remote_handle);
5698 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)
5700 int ret = CAMERA_ERROR_NONE;
5701 camera_cli_s *pc = (camera_cli_s *)camera;
5702 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5703 camera_msg_param param;
5706 if (!pc || !pc->cb_info || !foreach_cb) {
5707 LOGE("NULL pointer %p %p", pc, foreach_cb);
5708 return CAMERA_ERROR_INVALID_PARAMETER;
5713 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5714 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5716 value = (width << 16) | height;
5717 CAMERA_MSG_PARAM_SET(param, INT, value);
5719 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5721 LOGD("ret : 0x%x", ret);
5727 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5729 int ret = CAMERA_ERROR_NONE;
5730 camera_cli_s *pc = (camera_cli_s *)camera;
5731 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5733 if (!pc || !pc->cb_info || !foreach_cb) {
5734 LOGE("NULL pointer %p %p", pc, foreach_cb);
5735 return CAMERA_ERROR_INVALID_PARAMETER;
5740 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5741 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5743 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5745 LOGD("ret : 0x%x", ret);
5751 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5753 int ret = CAMERA_ERROR_NONE;
5754 camera_cli_s *pc = (camera_cli_s *)camera;
5755 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5757 if (!pc || !pc->cb_info || !foreach_cb) {
5758 LOGE("NULL pointer %p %p", pc, foreach_cb);
5759 return CAMERA_ERROR_INVALID_PARAMETER;
5764 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5765 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5767 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5769 LOGD("ret : 0x%x", ret);
5775 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5777 int ret = CAMERA_ERROR_NONE;
5778 camera_cli_s *pc = (camera_cli_s *)camera;
5779 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5780 camera_msg_param param;
5781 int set_rotation = (int)rotation;
5783 if (!pc || !pc->cb_info) {
5784 LOGE("NULL handle");
5785 return CAMERA_ERROR_INVALID_PARAMETER;
5790 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5792 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5794 LOGD("ret : 0x%x", ret);
5800 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5802 int ret = CAMERA_ERROR_NONE;
5803 camera_cli_s *pc = (camera_cli_s *)camera;
5804 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5806 if (!pc || !pc->cb_info || !rotation) {
5807 LOGE("NULL pointer %p %p", pc, rotation);
5808 return CAMERA_ERROR_INVALID_PARAMETER;
5813 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5815 if (ret == CAMERA_ERROR_NONE)
5816 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5818 LOGD("ret : 0x%x", ret);
5824 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5826 int ret = CAMERA_ERROR_NONE;
5827 camera_cli_s *pc = (camera_cli_s *)camera;
5828 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5829 camera_msg_param param;
5830 int set_flip = (int)flip;
5832 if (!pc || !pc->cb_info) {
5833 LOGE("NULL handle");
5834 return CAMERA_ERROR_INVALID_PARAMETER;
5839 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5841 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5843 LOGD("ret : 0x%x", ret);
5849 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5851 int ret = CAMERA_ERROR_NONE;
5852 camera_cli_s *pc = (camera_cli_s *)camera;
5853 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5855 if (!pc || !pc->cb_info || !flip) {
5856 LOGE("NULL pointer %p %p", pc, flip);
5857 return CAMERA_ERROR_INVALID_PARAMETER;
5862 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5864 if (ret == CAMERA_ERROR_NONE)
5865 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5867 LOGD("ret : 0x%x", ret);
5872 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5874 int ret = CAMERA_ERROR_NONE;
5875 camera_cli_s *pc = (camera_cli_s *)camera;
5876 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5877 camera_msg_param param;
5878 int set_mode = (int)mode;
5880 if (!pc || !pc->cb_info) {
5881 LOGE("NULL handle");
5882 return CAMERA_ERROR_INVALID_PARAMETER;
5887 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5889 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5891 LOGD("ret : 0x%x", ret);
5897 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5899 int ret = CAMERA_ERROR_NONE;
5900 camera_cli_s *pc = (camera_cli_s *)camera;
5901 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5903 if (!pc || !pc->cb_info || !mode) {
5904 LOGE("NULL pointer %p %p", pc, mode);
5905 return CAMERA_ERROR_INVALID_PARAMETER;
5910 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5912 if (ret == CAMERA_ERROR_NONE)
5913 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
5915 LOGD("ret : 0x%x", ret);
5921 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5923 int ret = CAMERA_ERROR_NONE;
5924 camera_cli_s *pc = (camera_cli_s *)camera;
5925 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
5927 if (!pc || !pc->cb_info) {
5928 LOGE("NULL handle");
5929 return CAMERA_ERROR_INVALID_PARAMETER;
5934 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5937 LOGE("error is occurred 0x%x", ret);
5941 LOGD("ret : %d", ret);
5947 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5949 int ret = CAMERA_ERROR_NONE;
5950 camera_cli_s *pc = (camera_cli_s *)camera;
5951 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5953 if (!pc || !pc->cb_info) {
5954 LOGE("NULL handle");
5955 return CAMERA_ERROR_INVALID_PARAMETER;
5960 if (!camera_attr_is_supported_hdr_capture(camera)) {
5961 LOGE("HDR not supported");
5962 return CAMERA_ERROR_NOT_SUPPORTED;
5966 LOGE("NULL callback");
5967 return CAMERA_ERROR_INVALID_PARAMETER;
5970 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5972 if (ret == CAMERA_ERROR_NONE) {
5973 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5975 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5976 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5978 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5981 LOGD("ret : 0x%x", ret);
5987 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5989 int ret = CAMERA_ERROR_NONE;
5990 camera_cli_s *pc = (camera_cli_s *)camera;
5991 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5993 if (!pc || !pc->cb_info) {
5994 LOGE("NULL handle");
5995 return CAMERA_ERROR_INVALID_PARAMETER;
6000 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6002 if (ret == CAMERA_ERROR_NONE) {
6003 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6005 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6006 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6008 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6011 LOGD("ret : 0x%x", ret);
6017 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6019 int ret = CAMERA_ERROR_NONE;
6020 camera_cli_s *pc = (camera_cli_s *)camera;
6021 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
6022 camera_msg_param param;
6023 int set_enable = (int)enable;
6025 if (!pc || !pc->cb_info) {
6026 LOGE("NULL handle");
6027 return CAMERA_ERROR_INVALID_PARAMETER;
6032 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6034 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6036 LOGD("ret : 0x%x", ret);
6042 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6044 int ret = CAMERA_ERROR_NONE;
6045 camera_cli_s *pc = (camera_cli_s *)camera;
6046 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6048 if (!pc || !pc->cb_info || !enabled) {
6049 LOGE("NULL pointer %p %p", pc, enabled);
6050 return CAMERA_ERROR_INVALID_PARAMETER;
6055 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6057 if (ret == CAMERA_ERROR_NONE)
6058 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6060 LOGD("ret : 0x%x", ret);
6066 bool camera_attr_is_supported_anti_shake(camera_h camera)
6068 int ret = CAMERA_ERROR_NONE;
6069 camera_cli_s *pc = (camera_cli_s *)camera;
6070 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6072 if (!pc || !pc->cb_info) {
6073 LOGE("NULL handle");
6074 return CAMERA_ERROR_INVALID_PARAMETER;
6079 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6082 LOGE("error is occurred 0x%x", ret);
6086 LOGD("ret : %d", ret);
6092 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6094 int ret = CAMERA_ERROR_NONE;
6095 camera_cli_s *pc = (camera_cli_s *)camera;
6096 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6097 camera_msg_param param;
6098 int set_enable = (int)enable;
6100 if (!pc || !pc->cb_info) {
6101 LOGE("NULL handle");
6102 return CAMERA_ERROR_INVALID_PARAMETER;
6107 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6109 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6111 LOGD("ret : 0x%x", ret);
6117 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6119 int ret = CAMERA_ERROR_NONE;
6120 camera_cli_s *pc = (camera_cli_s *)camera;
6121 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6123 if (!pc || !pc->cb_info || !enabled) {
6124 LOGE("NULL pointer %p %p", pc, enabled);
6125 return CAMERA_ERROR_INVALID_PARAMETER;
6130 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6132 if (ret == CAMERA_ERROR_NONE)
6133 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6135 LOGD("ret : 0x%x", ret);
6141 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6143 int ret = CAMERA_ERROR_NONE;
6144 camera_cli_s *pc = (camera_cli_s *)camera;
6145 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6147 if (!pc || !pc->cb_info) {
6148 LOGE("NULL handle");
6149 return CAMERA_ERROR_INVALID_PARAMETER;
6154 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6157 LOGE("error is occurred 0x%x", ret);
6161 LOGD("ret : %d", ret);
6167 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6169 int ret = CAMERA_ERROR_NONE;
6170 camera_cli_s *pc = (camera_cli_s *)camera;
6171 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6172 camera_msg_param param;
6173 int set_enable = (int)enable;
6175 if (!pc || !pc->cb_info) {
6176 LOGE("NULL handle");
6177 return CAMERA_ERROR_INVALID_PARAMETER;
6182 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6184 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6186 LOGD("ret : 0x%x", ret);
6192 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6194 int ret = CAMERA_ERROR_NONE;
6195 camera_cli_s *pc = (camera_cli_s *)camera;
6196 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6198 if (!pc || !pc->cb_info || !enabled) {
6199 LOGE("NULL pointer %p %p", pc, enabled);
6200 return CAMERA_ERROR_INVALID_PARAMETER;
6205 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6207 if (ret == CAMERA_ERROR_NONE)
6208 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6210 LOGD("ret : 0x%x", ret);
6216 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6218 int ret = CAMERA_ERROR_NONE;
6219 camera_cli_s *pc = (camera_cli_s *)camera;
6220 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6222 if (!pc || !pc->cb_info) {
6223 LOGE("NULL handle");
6224 return CAMERA_ERROR_INVALID_PARAMETER;
6229 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6232 LOGE("error is occurred 0x%x", ret);
6236 LOGD("ret : %d", ret);
6242 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6244 int ret = CAMERA_ERROR_NONE;
6245 camera_cli_s *pc = (camera_cli_s *)camera;
6246 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6247 camera_msg_param param;
6248 int set_disable = (int)disable;
6250 if (!pc || !pc->cb_info) {
6251 LOGE("NULL handle");
6252 return CAMERA_ERROR_INVALID_PARAMETER;
6257 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6259 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6261 LOGD("ret : 0x%x", ret);
6267 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6269 int ret = CAMERA_ERROR_NONE;
6270 camera_cli_s *pc = (camera_cli_s *)camera;
6271 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6272 camera_msg_param param;
6273 int set_move_type = (int)move_type;
6276 if (!pc || !pc->cb_info) {
6277 LOGE("NULL handle");
6278 return CAMERA_ERROR_INVALID_PARAMETER;
6283 value = (set_move_type << 16) | pan_step;
6284 CAMERA_MSG_PARAM_SET(param, INT, value);
6286 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6288 LOGD("ret : 0x%x", ret);
6294 int camera_attr_get_pan(camera_h camera, int *pan_step)
6296 int ret = CAMERA_ERROR_NONE;
6297 camera_cli_s *pc = (camera_cli_s *)camera;
6298 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6300 if (!pc || !pc->cb_info || !pan_step) {
6301 LOGE("NULL pointer %p %p", pc, pan_step);
6302 return CAMERA_ERROR_INVALID_PARAMETER;
6307 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6309 if (ret == CAMERA_ERROR_NONE)
6310 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6312 LOGD("ret : 0x%x", ret);
6318 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6320 int ret = CAMERA_ERROR_NONE;
6321 camera_cli_s *pc = (camera_cli_s *)camera;
6322 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6324 if (!pc || !pc->cb_info || !min || !max) {
6325 LOGE("NULL pointer %p %p %p", pc, min, max);
6326 return CAMERA_ERROR_INVALID_PARAMETER;
6331 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6333 if (ret == CAMERA_ERROR_NONE) {
6334 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6335 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6338 LOGD("ret : 0x%x", ret);
6344 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6346 int ret = CAMERA_ERROR_NONE;
6347 camera_cli_s *pc = (camera_cli_s *)camera;
6348 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6349 camera_msg_param param;
6350 int set_move_type = (int)move_type;
6353 if (!pc || !pc->cb_info) {
6354 LOGE("NULL handle");
6355 return CAMERA_ERROR_INVALID_PARAMETER;
6360 value = (set_move_type << 16) | tilt_step;
6361 CAMERA_MSG_PARAM_SET(param, INT, value);
6363 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6365 LOGD("ret : 0x%x", ret);
6371 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6373 int ret = CAMERA_ERROR_NONE;
6374 camera_cli_s *pc = (camera_cli_s *)camera;
6375 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6377 if (!pc || !pc->cb_info || !tilt_step) {
6378 LOGE("NULL pointer %p %p", pc, tilt_step);
6379 return CAMERA_ERROR_INVALID_PARAMETER;
6384 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6386 if (ret == CAMERA_ERROR_NONE)
6387 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6389 LOGD("ret : 0x%x", ret);
6395 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6397 int ret = CAMERA_ERROR_NONE;
6398 camera_cli_s *pc = (camera_cli_s *)camera;
6399 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6401 if (!pc || !pc->cb_info || !min || !max) {
6402 LOGE("NULL pointer %p %p %p", pc, min, max);
6403 return CAMERA_ERROR_INVALID_PARAMETER;
6408 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6410 if (ret == CAMERA_ERROR_NONE) {
6411 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6412 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6415 LOGD("ret : 0x%x", ret);
6421 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6423 int ret = CAMERA_ERROR_NONE;
6424 camera_cli_s *pc = (camera_cli_s *)camera;
6425 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6426 camera_msg_param param;
6427 int set_ptz_type = (int)ptz_type;
6429 if (!pc || !pc->cb_info) {
6430 LOGE("NULL handle");
6431 return CAMERA_ERROR_INVALID_PARAMETER;
6436 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6438 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6440 LOGD("ret : 0x%x", ret);
6446 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6448 int ret = CAMERA_ERROR_NONE;
6449 camera_cli_s *pc = (camera_cli_s *)camera;
6450 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6452 if (!pc || !pc->cb_info || !foreach_cb) {
6453 LOGE("NULL pointer %p %p", pc, foreach_cb);
6454 return CAMERA_ERROR_INVALID_PARAMETER;
6459 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6460 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6462 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6464 LOGD("ret : 0x%x", ret);
6470 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6472 int ret = CAMERA_ERROR_NONE;
6473 camera_cli_s *pc = (camera_cli_s *)camera;
6474 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6475 int set_display_roi_area[4] = {x, y, width, height};
6480 if (!pc || !pc->cb_info) {
6481 LOGE("NULL handle");
6482 return CAMERA_ERROR_INVALID_PARAMETER;
6487 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6488 ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
6489 if (ret != MM_ERROR_NONE) {
6490 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6491 return CAMERA_ERROR_INVALID_OPERATION;
6495 length = sizeof(set_display_roi_area) / sizeof(int) + \
6496 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6498 msg = muse_core_msg_new(api,
6499 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6502 LOGE("msg creation failed: api %d", api);
6503 return CAMERA_ERROR_OUT_OF_MEMORY;
6506 if (pc->cb_info->is_server_connected) {
6507 __camera_update_api_waiting(pc->cb_info, api, 1);
6509 g_mutex_lock(&pc->cb_info->fd_lock);
6510 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
6511 g_mutex_unlock(&pc->cb_info->fd_lock);
6515 LOGE("message send failed");
6516 ret = CAMERA_ERROR_INVALID_OPERATION;
6518 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6521 __camera_update_api_waiting(pc->cb_info, api, -1);
6523 muse_core_msg_free(msg);
6525 LOGD("ret : 0x%x", ret);
6531 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6533 camera_cli_s *pc = (camera_cli_s *)camera;
6534 int ret = CAMERA_ERROR_NONE;
6535 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6537 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6538 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6539 return CAMERA_ERROR_INVALID_PARAMETER;
6544 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6546 if (ret == CAMERA_ERROR_NONE) {
6547 *x = pc->cb_info->get_display_roi_area[0];
6548 *y = pc->cb_info->get_display_roi_area[1];
6549 *width = pc->cb_info->get_display_roi_area[2];
6550 *height = pc->cb_info->get_display_roi_area[3];
6553 LOGD("ret : 0x%x", ret);
6559 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6561 int ret = CAMERA_ERROR_NONE;
6562 int get_device_state = 0;
6565 LOGE("NULL pointer");
6566 return CAMERA_ERROR_INVALID_PARAMETER;
6569 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6570 (int)device, "get_device_state", &get_device_state);
6572 if (ret == CAMERA_ERROR_NONE) {
6573 *state = (camera_device_state_e)get_device_state;
6574 LOGD("device state %d", *state);
6576 LOGE("failed 0x%x", ret);
6583 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6585 int ret = CAMERA_ERROR_NONE;
6586 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6587 camera_cb_info *info = NULL;
6589 if (!callback || !cb_id) {
6590 LOGE("invalid pointer %p %p", callback, cb_id);
6591 return CAMERA_ERROR_INVALID_PARAMETER;
6594 /* check camera support */
6595 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6596 if (ret != CAMERA_ERROR_NONE) {
6597 LOGE("get device state failed");
6601 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6603 info = g_new0(camera_cb_info, 1);
6605 LOGE("info failed");
6606 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6610 info->id = ++g_cam_dev_state_changed_cb_id;
6611 info->callback = (void *)callback;
6612 info->user_data = user_data;
6616 /* subscribe dbus signal for camera state change */
6617 if (!g_cam_dev_state_changed_cb_conn) {
6618 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6619 if (!g_cam_dev_state_changed_cb_conn) {
6620 LOGE("failed to get gdbus connection");
6621 ret = CAMERA_ERROR_INVALID_OPERATION;
6625 LOGD("subscribe signal %s - %s - %s",
6626 MM_CAMCORDER_DBUS_OBJECT,
6627 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6628 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6630 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6631 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6632 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6633 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6634 LOGE("failed to get gdbus connection");
6635 ret = CAMERA_ERROR_INVALID_OPERATION;
6639 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6642 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6644 LOGD("callback id %d", info->id);
6647 if (ret != CAMERA_ERROR_NONE) {
6653 if (g_cam_dev_state_changed_cb_conn) {
6654 g_object_unref(g_cam_dev_state_changed_cb_conn);
6655 g_cam_dev_state_changed_cb_conn = NULL;
6659 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6665 int camera_remove_device_state_changed_cb(int cb_id)
6667 int ret = CAMERA_ERROR_NONE;
6668 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6669 GList *tmp_list = NULL;
6670 camera_cb_info *info = NULL;
6672 /* check camera support */
6673 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6674 if (ret != CAMERA_ERROR_NONE) {
6675 LOGE("get device state failed");
6679 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6681 if (!g_cam_dev_state_changed_cb_list) {
6682 LOGE("there is no callback info");
6683 ret = CAMERA_ERROR_INVALID_OPERATION;
6687 tmp_list = g_cam_dev_state_changed_cb_list;
6690 info = tmp_list->data;
6691 tmp_list = tmp_list->next;
6698 if (info->id == cb_id) {
6699 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6704 if (!g_cam_dev_state_changed_cb_list) {
6705 /* no remained callback */
6706 if (g_cam_dev_state_changed_cb_conn) {
6707 /* unsubscribe signal */
6708 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6709 g_cam_dev_state_changed_cb_subscribe_id = 0;
6711 /* unref connection */
6712 g_object_unref(g_cam_dev_state_changed_cb_conn);
6713 g_cam_dev_state_changed_cb_conn = NULL;
6717 LOGD("id %d callback removed", cb_id);
6718 ret = CAMERA_ERROR_NONE;
6724 LOGE("id %d callback not found", cb_id);
6725 ret = CAMERA_ERROR_INVALID_PARAMETER;
6728 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);