2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
24 #include <muse_camera.h>
25 #include <muse_camera_msg.h>
26 #include <camera_private.h>
27 #include <muse_core.h>
28 #include <muse_client.h>
30 #include <tbm_surface_internal.h>
36 #define LOG_TAG "TIZEN_N_CAMERA"
38 /* for device changed callback */
39 static GMutex g_cam_dev_state_changed_cb_lock;
40 static GList *g_cam_dev_state_changed_cb_list;
41 static int g_cam_dev_state_changed_cb_id;
42 static GDBusConnection *g_cam_dev_state_changed_cb_conn;
43 static guint g_cam_dev_state_changed_cb_subscribe_id;
45 static void _camera_msg_send(int api, camera_cb_info_s *cb_info,
46 int *ret, int timeout);
47 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
48 int *ret, camera_msg_param *param, int timeout);
49 static void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
50 int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout);
51 static int _camera_import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle);
52 static void _camera_release_imported_bo(tbm_bo *bo);
53 static void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_key,
54 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame);
55 static int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
56 camera_media_packet_data *mp_data, media_packet_h *packet);
57 static int _camera_media_packet_data_create(int tbm_key, int num_buffer_key, tbm_bo bo,
58 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data);
59 static void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info);
62 static void __camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value)
65 api < 0 || api >= MUSE_CAMERA_API_MAX) {
66 LOGE("invalid param %p %d", cb_info, api);
70 g_mutex_lock(&(cb_info->api_mutex[api]));
71 cb_info->api_waiting[api] += value;
72 g_mutex_unlock(&(cb_info->api_mutex[api]));
74 /*LOGD("api %d, value %d, waiting %d",
75 api, value, cb_info->api_waiting[api]);*/
81 static void __camera_device_state_changed_cb(GDBusConnection *connection,
82 const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
83 const gchar *signal_name, GVariant *param, gpointer user_data)
86 camera_device_e device = CAMERA_DEVICE_CAMERA0;
87 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
88 GList *tmp_list = NULL;
89 camera_cb_info *info = NULL;
91 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
93 if (!g_cam_dev_state_changed_cb_list || !param) {
94 LOGW("no callback or NULL param %p", param);
98 /* get device and state */
99 g_variant_get(param, "(i)", &value);
101 device = value >> 16;
102 state = 0x0000ffff & value;
104 LOGD("device %d, state %d", device, state);
106 tmp_list = g_cam_dev_state_changed_cb_list;
109 info = (camera_cb_info *)tmp_list->data;
112 if (info->callback) {
113 LOGD("start id[%d] callback", info->id);
114 ((camera_device_state_changed_cb)info->callback)(device, state, info->user_data);
115 LOGD("returned id[%d] callback", info->id);
117 LOGW("NULL callback for id %d", info->id);
121 tmp_list = tmp_list->next;
125 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
131 static void __camera_event_handler_preview(camera_cb_info_s *cb_info, char *recv_msg)
135 int num_buffer_key = 0;
136 int buffer_key[BUFFER_MAX_PLANE_NUM] = {0, };
139 unsigned char *buf_pos = NULL;
140 camera_msg_param param;
143 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
144 tbm_bo_handle bo_handle = {.ptr = NULL};
145 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
146 tbm_bo data_bo = NULL;
147 tbm_bo_handle data_bo_handle = {.ptr = NULL};
149 camera_preview_data_s frame;
150 camera_stream_data_s *stream = NULL;
151 camera_media_packet_data *mp_data = NULL;
152 media_packet_h pkt = NULL;
153 media_packet_h pkt_evas = NULL;
155 if (!cb_info || !recv_msg) {
156 LOGE("invalid param %p %p", cb_info, recv_msg);
160 muse_camera_msg_get(tbm_key, recv_msg);
161 muse_camera_msg_get(num_buffer_key, recv_msg);
162 muse_camera_msg_get_array(buffer_key, recv_msg);
163 muse_camera_msg_get(data_key, recv_msg);
165 memset(&frame, 0x0, sizeof(camera_preview_data_s));
168 LOGE("invalid key %d", tbm_key);
172 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
174 if (num_buffer_key < 0 || num_buffer_key > BUFFER_MAX_PLANE_NUM) {
175 LOGE("invalid num buffer key %d", num_buffer_key);
176 goto _PREVIEW_CB_HANDLER_DONE;
180 /* import tbm data_bo and get virtual address */
181 if (!_camera_import_tbm_key(cb_info->bufmgr, data_key, &data_bo, &data_bo_handle)) {
182 LOGE("failed to import data key %d", data_key);
183 goto _PREVIEW_CB_HANDLER_DONE;
187 /* import tbm bo and get virtual address */
188 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
189 LOGE("failed to import key %d", tbm_key);
190 goto _PREVIEW_CB_HANDLER_DONE;
193 buf_pos = (unsigned char *)bo_handle.ptr;
195 /* get stream info */
196 stream = (camera_stream_data_s *)buf_pos;
198 for (i = 0 ; i < num_buffer_key ; i++) {
199 /* import buffer bo and get virtual address */
200 if (!_camera_import_tbm_key(cb_info->bufmgr, buffer_key[i], &buffer_bo[i], &buffer_bo_handle[i])) {
201 LOGE("failed to import buffer key %d", buffer_key[i]);
202 goto _PREVIEW_CB_HANDLER_DONE;
206 /* call preview callback */
207 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
208 _camera_preview_frame_create(stream, num_buffer_key, buffer_bo_handle, &data_bo_handle, &frame);
210 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
211 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
214 if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
215 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
217 if (ret == CAMERA_ERROR_NONE) {
218 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt_evas);
219 if (ret != CAMERA_ERROR_NONE) {
220 LOGE("create pkt for evas failed");
221 _camera_media_packet_data_release(mp_data, cb_info);
227 /* call media packet callback */
228 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
229 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
231 if (ret == CAMERA_ERROR_NONE) {
232 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt);
234 if (ret == CAMERA_ERROR_NONE) {
235 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
236 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
238 _camera_media_packet_data_release(mp_data, cb_info);
244 /* call evas renderer */
246 if (cb_info->run_evas_render) {
247 mm_display_interface_evas_render(cb_info->dp_interface, pkt_evas);
249 LOGW("evas renderer is stopped, skip this buffer...");
250 media_packet_destroy(pkt_evas);
255 /* send message for preview callback return */
256 if (!CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS))
257 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info, NULL, 0);
259 _PREVIEW_CB_HANDLER_DONE:
260 if (mp_data == NULL) {
261 /* release imported bo */
262 for (i = 0 ; i < num_buffer_key && i < BUFFER_MAX_PLANE_NUM ; i++)
263 _camera_release_imported_bo(&buffer_bo[i]);
265 /* unmap and unref tbm bo */
266 _camera_release_imported_bo(&data_bo);
267 _camera_release_imported_bo(&bo);
270 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
272 /*LOGD("return buffer Done");*/
279 static void __camera_event_handler_capture(camera_cb_info_s *cb_info, char *recv_msg)
282 int tbm_key_main = 0;
283 int tbm_key_post = 0;
284 int tbm_key_thumb = 0;
285 unsigned char *buf_pos = NULL;
287 camera_msg_param param;
288 camera_image_data_s *rImage = NULL;
289 camera_image_data_s *rPostview = NULL;
290 camera_image_data_s *rThumbnail = NULL;
292 tbm_bo bo_main = NULL;
293 tbm_bo bo_post = NULL;
294 tbm_bo bo_thumb = NULL;
295 tbm_bo_handle bo_main_handle = {.ptr = NULL};
296 tbm_bo_handle bo_post_handle = {.ptr = NULL};
297 tbm_bo_handle bo_thumb_handle = {.ptr = NULL};
299 if (!cb_info || !recv_msg) {
300 LOGE("invalid param %p %p", cb_info, recv_msg);
304 muse_camera_msg_get(tbm_key_main, recv_msg);
305 muse_camera_msg_get(tbm_key_post, recv_msg);
306 muse_camera_msg_get(tbm_key_thumb, recv_msg);
309 LOGD("camera capture callback came in. tbm_key_main %d, tbm_key_post %d, tbm_key_thumb %d",
310 tbm_key_main, tbm_key_post, tbm_key_thumb);
313 if (tbm_key_main <= 0) {
314 LOGE("invalid key %d", tbm_key_main);
315 goto _CAPTURE_CB_HANDLER_DONE;
318 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] == NULL) {
319 LOGW("NULL callback");
320 goto _CAPTURE_CB_HANDLER_DONE;
323 /* import tbm bo and get virtual address */
324 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_main, &bo_main, &bo_main_handle)) {
325 LOGE("failed to import key [%d] for main", tbm_key_main);
326 goto _CAPTURE_CB_HANDLER_DONE;
329 buf_pos = (unsigned char *)bo_main_handle.ptr;
330 rImage = (camera_image_data_s *)buf_pos;
331 rImage->data = buf_pos + sizeof(camera_image_data_s);
332 if (rImage->exif && rImage->exif_size > 0) {
333 rImage->exif = rImage->data + rImage->size;
336 rImage->exif_size = 0;
339 LOGD("image info %dx%d, size %d, EXIF info %p, size %d",
340 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
342 if (tbm_key_post > 0) {
343 /* import tbm bo and get virtual address */
344 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key_post, &bo_post, &bo_post_handle)) {
345 buf_pos = (unsigned char *)bo_post_handle.ptr;
346 rPostview = (camera_image_data_s *)buf_pos;
347 LOGD("rPostview->size : %d", rPostview->size);
348 rPostview->data = buf_pos + sizeof(camera_image_data_s);
350 LOGE("failed to import key [%d] for postview", tbm_key_post);
354 if (tbm_key_thumb > 0) {
355 /* import tbm bo and get virtual address */
356 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key_thumb, &bo_thumb, &bo_thumb_handle)) {
357 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
358 rThumbnail = (camera_image_data_s *)buf_pos;
359 LOGD("rThumbnail->size : %d", rThumbnail->size);
360 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
362 LOGE("failed to import key [%d] for thumbnail", tbm_key_thumb);
366 ((camera_capturing_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE])(rImage,
367 rPostview, rThumbnail, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE]);
369 _CAPTURE_CB_HANDLER_DONE:
371 if (tbm_key_main > 0) {
372 _camera_release_imported_bo(&bo_main);
374 tbm_key = tbm_key_main;
375 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
377 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
380 if (tbm_key_post > 0) {
381 _camera_release_imported_bo(&bo_post);
383 tbm_key = tbm_key_post;
384 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
386 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
389 if (tbm_key_thumb > 0) {
390 _camera_release_imported_bo(&bo_thumb);
392 tbm_key = tbm_key_thumb;
393 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
395 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
398 LOGD("return buffer done");
404 static void __camera_event_handler_face_detection(camera_cb_info_s *cb_info, char *recv_msg)
408 camera_detected_face_s *faces = NULL;
409 camera_msg_param param;
412 tbm_bo_handle bo_handle = {.ptr = NULL};
414 if (!cb_info || !recv_msg) {
415 LOGE("invalid param %p %p", cb_info, recv_msg);
419 muse_camera_msg_get(count, recv_msg);
420 muse_camera_msg_get(tbm_key, recv_msg);
422 if (count >= 0 && cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]) {
423 LOGD("FACE_DETECTION - count %d, tbm_key %d", count, tbm_key);
427 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
429 faces = bo_handle.ptr;
433 ((camera_face_detected_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION])(faces,
434 count, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
437 _camera_release_imported_bo(&bo);
439 LOGW("skip face detection message [count %d, key %d, cb %p",
440 count, tbm_key, cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
445 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
446 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
447 /*LOGD("return buffer done");*/
454 static int _camera_import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle)
456 tbm_bo tmp_bo = NULL;
457 tbm_bo_handle tmp_bo_handle = {NULL, };
459 if (!bufmgr || !bo || !bo_handle || !tbm_key) {
460 LOGE("invalid parameter - %p %p %p, key %d",
461 bufmgr, bo, bo_handle, tbm_key);
465 tmp_bo = tbm_bo_import(bufmgr, tbm_key);
466 if (tmp_bo == NULL) {
467 LOGE("import failed - key %d", tbm_key);
471 tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
472 if (tmp_bo_handle.ptr == NULL) {
473 LOGE("map failed %p", tmp_bo);
474 tbm_bo_unref(tmp_bo);
479 tbm_bo_unmap(tmp_bo);
481 /* set bo and bo_handle */
483 *bo_handle = tmp_bo_handle;
488 static void _camera_release_imported_bo(tbm_bo *bo)
501 static int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
503 int ret = CAMERA_ERROR_NONE;
506 /*LOGD("Enter api : %d", api);*/
508 if (!cb_info->is_server_connected) {
509 LOGE("server is disconnected");
510 return CAMERA_ERROR_SERVICE_DISCONNECTED;
513 g_mutex_lock(&(cb_info->api_mutex[api]));
515 if (cb_info->api_activating[api] == 0) {
516 if (time_out == CAMERA_CB_NO_TIMEOUT) {
517 LOGW("wait for api %d", api);
518 g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
519 ret = cb_info->api_ret[api];
520 cb_info->api_activating[api] = 0;
521 LOGW("api %d returned 0x%x", api, ret);
523 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
524 if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
525 ret = cb_info->api_ret[api];
526 cb_info->api_activating[api] = 0;
527 /*LOGD("return value : 0x%x", ret);*/
529 ret = CAMERA_ERROR_INVALID_OPERATION;
530 LOGE("api %d was TIMED OUT!", api);
534 ret = cb_info->api_ret[api];
535 cb_info->api_activating[api] = 0;
537 /*LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);*/
540 g_mutex_unlock(&(cb_info->api_mutex[api]));
542 if (ret != CAMERA_ERROR_NONE)
543 LOGE("api %d : error 0x%x", api, ret);
549 static void _camera_msg_send(int api, camera_cb_info_s *cb_info,
550 int *ret, int timeout)
556 LOGE("NULL info - api %d", api);
559 *ret = CAMERA_ERROR_INVALID_PARAMETER;
564 msg = muse_core_msg_new(api, NULL);
566 LOGE("msg failed: api %d", api);
569 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
574 /*LOGD("send msg %s", msg);*/
576 if (cb_info->is_server_connected) {
577 __camera_update_api_waiting(cb_info, api, 1);
579 g_mutex_lock(&cb_info->fd_lock);
580 send_ret = muse_core_msg_send(cb_info->fd, msg);
581 g_mutex_unlock(&cb_info->fd_lock);
585 LOGE("msg send failed");
587 *ret = CAMERA_ERROR_INVALID_OPERATION;
590 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
593 __camera_update_api_waiting(cb_info, api, -1);
595 muse_core_msg_free(msg);
601 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
602 int *ret, camera_msg_param *param, int timeout)
607 if (!cb_info || !param) {
608 LOGE("invalid pointer : api %d - %p %p", api, cb_info, param);
611 *ret = CAMERA_ERROR_INVALID_PARAMETER;
616 /*LOGD("type %d, name %s", param->type, param->name);*/
618 switch (param->type) {
620 msg = muse_core_msg_new(api,
621 param->type, param->name, param->value.value_INT,
624 case MUSE_TYPE_STRING:
625 msg = muse_core_msg_new(api,
626 param->type, param->name, param->value.value_STRING,
630 LOGE("unknown type %d", param->type);
635 LOGE("msg failed: api %d", api);
638 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
643 /*LOGD("send msg %s", msg);*/
645 if (cb_info->is_server_connected) {
646 __camera_update_api_waiting(cb_info, api, 1);
648 g_mutex_lock(&cb_info->fd_lock);
649 send_ret = muse_core_msg_send(cb_info->fd, msg);
650 g_mutex_unlock(&cb_info->fd_lock);
654 LOGE("msg send failed");
657 *ret = CAMERA_ERROR_INVALID_OPERATION;
660 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
663 __camera_update_api_waiting(cb_info, api, -1);
665 muse_core_msg_free(msg);
671 static void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
672 int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout)
674 int func_ret = CAMERA_ERROR_NONE;
678 if (!cb_info || !param0 || !param1) {
679 LOGE("invalid ptr %p %p %p : api %d",
680 cb_info, param0, param1, api);
681 func_ret = CAMERA_ERROR_INVALID_PARAMETER;
682 goto _SEND_PARAM2_INT_DONE;
685 /*LOGD("api %d, param0 [%s:%d], param1 [%s:%d]",
687 param0->name, param0->value.value_INT,
688 param1->name, param1->value.value_INT);*/
690 msg = muse_core_msg_new(api,
691 param0->type, param0->name, param0->value.value_INT,
692 param1->type, param1->name, param1->value.value_INT,
695 LOGE("msg failed: api %d", api);
696 func_ret = CAMERA_ERROR_OUT_OF_MEMORY;
697 goto _SEND_PARAM2_INT_DONE;
700 /*LOGD("send msg [%s]", msg);*/
702 if (cb_info->is_server_connected) {
703 __camera_update_api_waiting(cb_info, api, 1);
705 g_mutex_lock(&cb_info->fd_lock);
706 send_ret = muse_core_msg_send(cb_info->fd, msg);
707 g_mutex_unlock(&cb_info->fd_lock);
711 LOGE("msg send failed");
713 func_ret = CAMERA_ERROR_INVALID_OPERATION;
715 func_ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
718 __camera_update_api_waiting(cb_info, api, -1);
720 muse_core_msg_free(msg);
722 _SEND_PARAM2_INT_DONE:
730 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
732 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
733 in_format >= MM_PIXEL_FORMAT_NUM ||
734 out_format == NULL) {
735 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
736 return CAMERA_ERROR_INVALID_PARAMETER;
740 case MM_PIXEL_FORMAT_NV12:
741 case MM_PIXEL_FORMAT_NV12T:
742 *out_format = TBM_FORMAT_NV12;
745 case MM_PIXEL_FORMAT_NV16:
746 *out_format = TBM_FORMAT_NV16;
748 case MM_PIXEL_FORMAT_NV21:
749 *out_format = TBM_FORMAT_NV21;
751 case MM_PIXEL_FORMAT_YUYV:
752 *out_format = TBM_FORMAT_YUYV;
754 case MM_PIXEL_FORMAT_UYVY:
755 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
756 *out_format = TBM_FORMAT_UYVY;
758 case MM_PIXEL_FORMAT_422P:
759 *out_format = TBM_FORMAT_YUV422;
761 case MM_PIXEL_FORMAT_I420:
762 *out_format = TBM_FORMAT_YUV420;
764 case MM_PIXEL_FORMAT_YV12:
765 *out_format = TBM_FORMAT_YVU420;
767 case MM_PIXEL_FORMAT_RGB565:
768 *out_format = TBM_FORMAT_RGB565;
770 case MM_PIXEL_FORMAT_RGB888:
771 *out_format = TBM_FORMAT_RGB888;
773 case MM_PIXEL_FORMAT_RGBA:
774 *out_format = TBM_FORMAT_RGBA8888;
776 case MM_PIXEL_FORMAT_ARGB:
777 *out_format = TBM_FORMAT_ARGB8888;
780 LOGE("invalid in_format %d", in_format);
781 return CAMERA_ERROR_INVALID_PARAMETER;
785 return CAMERA_ERROR_NONE;
789 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
791 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
792 in_format >= MM_PIXEL_FORMAT_NUM ||
794 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
795 return CAMERA_ERROR_INVALID_PARAMETER;
799 case MM_PIXEL_FORMAT_NV12:
800 case MM_PIXEL_FORMAT_NV12T:
801 *mimetype = MEDIA_FORMAT_NV12;
804 case MM_PIXEL_FORMAT_NV16:
805 *mimetype = MEDIA_FORMAT_NV16;
807 case MM_PIXEL_FORMAT_NV21:
808 *mimetype = MEDIA_FORMAT_NV21;
810 case MM_PIXEL_FORMAT_YUYV:
811 *mimetype = MEDIA_FORMAT_YUYV;
813 case MM_PIXEL_FORMAT_UYVY:
814 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
815 *mimetype = MEDIA_FORMAT_UYVY;
817 case MM_PIXEL_FORMAT_422P:
818 *mimetype = MEDIA_FORMAT_422P;
820 case MM_PIXEL_FORMAT_I420:
821 *mimetype = MEDIA_FORMAT_I420;
823 case MM_PIXEL_FORMAT_YV12:
824 *mimetype = MEDIA_FORMAT_YV12;
826 case MM_PIXEL_FORMAT_RGB565:
827 *mimetype = MEDIA_FORMAT_RGB565;
829 case MM_PIXEL_FORMAT_RGB888:
830 *mimetype = MEDIA_FORMAT_RGB888;
832 case MM_PIXEL_FORMAT_RGBA:
833 *mimetype = MEDIA_FORMAT_RGBA;
835 case MM_PIXEL_FORMAT_ARGB:
836 *mimetype = MEDIA_FORMAT_ARGB;
839 LOGE("invalid in_format %d", in_format);
840 return CAMERA_ERROR_INVALID_PARAMETER;
844 return CAMERA_ERROR_NONE;
847 static void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_key,
848 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame)
851 unsigned char *buf_pos = NULL;
853 if (stream == NULL || buffer_bo_handle == NULL || frame == NULL) {
854 LOGE("invalid parameter - stream:%p, buffer_bo_handle:%p", stream, buffer_bo_handle);
859 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
860 frame->format = MM_PIXEL_FORMAT_UYVY;
862 frame->format = stream->format;
864 frame->width = stream->width;
865 frame->height = stream->height;
866 frame->timestamp = stream->timestamp;
867 frame->num_of_planes = stream->num_planes;
869 if (num_buffer_key == 0) {
872 if (!data_bo_handle || !data_bo_handle->ptr) {
873 LOGE("NULL pointer");
877 buf_pos = data_bo_handle->ptr;
879 if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) {
880 frame->data.encoded_plane.data = buf_pos;
881 frame->data.encoded_plane.size = stream->data.encoded.length_data;
882 total_size = stream->data.encoded.length_data;
883 } else if (stream->format == MM_PIXEL_FORMAT_INVZ) {
884 frame->data.depth_plane.data = buf_pos;
885 frame->data.depth_plane.size = stream->data.depth.length_data;
886 total_size = stream->data.depth.length_data;
888 switch (stream->num_planes) {
890 frame->data.single_plane.yuv = buf_pos;
891 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
892 total_size = stream->data.yuv420.length_yuv;
895 frame->data.double_plane.y = buf_pos;
896 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
897 buf_pos += stream->data.yuv420sp.length_y;
898 frame->data.double_plane.uv = buf_pos;
899 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
900 total_size = stream->data.yuv420sp.length_y + \
901 stream->data.yuv420sp.length_uv;
904 frame->data.triple_plane.y = buf_pos;
905 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
906 buf_pos += stream->data.yuv420p.length_y;
907 frame->data.triple_plane.u = buf_pos;
908 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
909 buf_pos += stream->data.yuv420p.length_u;
910 frame->data.triple_plane.v = buf_pos;
911 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
912 total_size = stream->data.yuv420p.length_y + \
913 stream->data.yuv420p.length_u + \
914 stream->data.yuv420p.length_v;
923 switch (stream->num_planes) {
926 frame->data.single_plane.yuv = buffer_bo_handle[0].ptr;
927 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
928 total_size = stream->data.yuv420.length_yuv;
932 frame->data.double_plane.y = buffer_bo_handle[0].ptr;
933 if (stream->num_planes == (unsigned int)num_buffer_key)
934 frame->data.double_plane.uv = buffer_bo_handle[1].ptr;
936 frame->data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
937 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
938 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
939 total_size = stream->data.yuv420sp.length_y + \
940 stream->data.yuv420sp.length_uv;
944 frame->data.triple_plane.y = buffer_bo_handle[0].ptr;
945 if (stream->num_planes == (unsigned int)num_buffer_key) {
946 frame->data.triple_plane.u = buffer_bo_handle[1].ptr;
947 frame->data.triple_plane.v = buffer_bo_handle[2].ptr;
949 frame->data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y;
950 frame->data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u;
952 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
953 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
954 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
955 total_size = stream->data.yuv420p.length_y + \
956 stream->data.yuv420p.length_u + \
957 stream->data.yuv420p.length_v;
966 LOGD("format %d, %dx%d, size %d plane num %d",
967 frame.format, frame.width, frame.height, total_size, frame.num_of_planes);
973 static int _camera_media_packet_data_create(int tbm_key, int num_buffer_key, tbm_bo bo,
974 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
977 int ret = CAMERA_ERROR_NONE;
978 camera_media_packet_data *tmp_mp_data = NULL;
980 if (*mp_data == NULL) {
981 tmp_mp_data = g_new0(camera_media_packet_data, 1);
983 tmp_mp_data->tbm_key = tbm_key;
984 tmp_mp_data->num_buffer_key = num_buffer_key;
985 tmp_mp_data->bo = bo;
986 tmp_mp_data->data_bo = data_bo;
987 tmp_mp_data->ref_cnt++;
989 for (i = 0 ; i < num_buffer_key ; i++)
990 tmp_mp_data->buffer_bo[i] = buffer_bo[i];
992 *mp_data = tmp_mp_data;
993 /*LOGD("mp_data %p", tmp_mp_data);*/
995 ret = CAMERA_ERROR_OUT_OF_MEMORY;
996 LOGE("failed to alloc media packet data");
999 ((camera_media_packet_data *)*mp_data)->ref_cnt++;
1005 static void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
1009 camera_msg_param param;
1011 if (!mp_data || !cb_info) {
1012 LOGE("NULL pointer %p %p", mp_data, cb_info);
1016 if (mp_data->ref_cnt > 1) {
1018 LOGD("ref count %d", mp_data->ref_cnt);
1020 /* release imported bo */
1021 for (i = 0 ; i < mp_data->num_buffer_key ; i++) {
1022 tbm_bo_unref(mp_data->buffer_bo[i]);
1023 mp_data->buffer_bo[i] = NULL;
1027 _camera_release_imported_bo(&mp_data->bo);
1028 _camera_release_imported_bo(&mp_data->data_bo);
1031 tbm_key = mp_data->tbm_key;
1033 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1035 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1044 static int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
1045 camera_media_packet_data *mp_data, media_packet_h *packet)
1047 media_packet_h pkt = NULL;
1048 bool make_pkt_fmt = false;
1049 tbm_surface_h tsurf = NULL;
1050 tbm_surface_info_s tsurf_info;
1051 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
1052 uint32_t bo_format = 0;
1055 int num_buffer_key = 0;
1056 tbm_bo *buffer_bo = NULL;
1058 if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) {
1059 LOGE("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p",
1060 cb_info, stream, mp_data, packet);
1061 return CAMERA_ERROR_INVALID_PARAMETER;
1064 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
1065 buffer_bo = mp_data->buffer_bo;
1066 num_buffer_key = mp_data->num_buffer_key;
1068 /* create tbm surface */
1069 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
1070 tsurf_info.planes[i].stride = stream->stride[i];
1072 /* get tbm surface format */
1073 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
1074 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
1076 if (ret == CAMERA_ERROR_NONE) {
1077 tsurf_info.width = stream->width;
1078 tsurf_info.height = stream->height;
1079 tsurf_info.format = bo_format;
1080 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
1081 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
1083 if (num_buffer_key > 0) {
1084 switch (bo_format) {
1085 case TBM_FORMAT_NV12:
1086 case TBM_FORMAT_NV21:
1087 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1088 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
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.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1095 case TBM_FORMAT_YUV420:
1096 case TBM_FORMAT_YVU420:
1097 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1098 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1099 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
1100 tsurf_info.planes[0].offset = 0;
1101 if (num_buffer_key == 1) {
1102 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1103 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1105 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1107 case TBM_FORMAT_UYVY:
1108 case TBM_FORMAT_YUYV:
1109 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
1110 tsurf_info.planes[0].offset = 0;
1111 tsurf_info.size = tsurf_info.planes[0].size;
1118 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_key);
1119 } else if (mp_data->data_bo) {
1121 switch (bo_format) {
1122 case TBM_FORMAT_NV12:
1123 case TBM_FORMAT_NV21:
1124 tsurf_info.planes[0].size = stream->width * stream->height;
1125 tsurf_info.planes[1].size = (tsurf_info.planes[0].size) >> 1;
1126 tsurf_info.planes[0].offset = 0;
1127 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1128 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1130 case TBM_FORMAT_YUV420:
1131 case TBM_FORMAT_YVU420:
1132 tsurf_info.planes[0].size = stream->width * stream->height;
1133 tsurf_info.planes[1].size = (stream->width >> 1) * (stream->height >> 1);
1134 tsurf_info.planes[2].size = tsurf_info.planes[1].size;
1135 tsurf_info.planes[0].offset = 0;
1136 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1137 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1138 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1140 case TBM_FORMAT_UYVY:
1141 case TBM_FORMAT_YUYV:
1142 tsurf_info.planes[0].size = (stream->width * stream->height) << 1;
1143 tsurf_info.planes[0].offset = 0;
1144 tsurf_info.size = tsurf_info.planes[0].size;
1150 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1);
1153 /*LOGD("tbm surface %p", tsurf);*/
1157 /* check media packet format */
1158 if (cb_info->pkt_fmt) {
1159 int pkt_fmt_width = 0;
1160 int pkt_fmt_height = 0;
1161 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
1163 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
1164 if (pkt_fmt_mimetype != mimetype ||
1165 pkt_fmt_width != stream->width ||
1166 pkt_fmt_height != stream->height) {
1167 LOGW("change fmt: current 0x%x, %dx%d",
1168 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
1169 media_format_unref(cb_info->pkt_fmt);
1170 cb_info->pkt_fmt = NULL;
1171 make_pkt_fmt = true;
1174 make_pkt_fmt = true;
1177 /* create packet format */
1179 LOGW("make new pkt_fmt - 0x%x, %dx%d", mimetype, stream->width, stream->height);
1180 ret = media_format_create(&cb_info->pkt_fmt);
1181 if (ret == MEDIA_FORMAT_ERROR_NONE) {
1182 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
1183 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
1184 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
1185 LOGW("media_format_set : 0x%x", ret);
1187 LOGW("media_format_create failed 0x%x", ret);
1191 /* create media packet */
1192 ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt,
1193 tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
1194 (void *)cb_info, &pkt);
1195 if (ret != MEDIA_PACKET_ERROR_NONE) {
1196 LOGE("media_packet_create failed 0x%x", ret);
1197 tbm_surface_destroy(tsurf);
1201 LOGE("tbm surface failed. %dx%d, format %d, num_buffer_key %d, data_bo %p",
1202 stream->width, stream->height, stream->format, num_buffer_key, mp_data->data_bo);
1206 /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
1207 /* set media packet data */
1208 ret = media_packet_set_extra(pkt, (void *)mp_data);
1209 if (ret != MEDIA_PACKET_ERROR_NONE) {
1210 LOGE("media_packet_set_extra failed");
1212 _camera_media_packet_data_release(mp_data, cb_info);
1215 media_packet_destroy(pkt);
1218 /* set timestamp : msec -> nsec */
1219 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
1220 LOGW("media_packet_set_pts failed");
1229 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
1232 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1233 camera_media_packet_data *mp_data = NULL;
1234 tbm_surface_h tsurf = NULL;
1236 if (!pkt || !cb_info) {
1237 LOGE("NULL pointer %p %p", pkt, cb_info);
1238 return MEDIA_PACKET_FINALIZE;
1241 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1242 if (ret != MEDIA_PACKET_ERROR_NONE) {
1243 LOGE("media_packet_get_extra failed 0x%x", ret);
1244 return MEDIA_PACKET_FINALIZE;
1247 /*LOGD("mp_data %p", mp_data);*/
1249 g_mutex_lock(&cb_info->mp_data_mutex);
1251 _camera_media_packet_data_release(mp_data, cb_info);
1254 g_mutex_unlock(&cb_info->mp_data_mutex);
1256 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1257 if (ret != MEDIA_PACKET_ERROR_NONE)
1258 LOGE("get tbm_surface failed 0x%x", ret);
1261 tbm_surface_destroy(tsurf);
1265 return MEDIA_PACKET_FINALIZE;
1268 static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event)
1273 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1274 LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event);
1278 /*LOGD("get camera msg %s, event %d", recv_msg, event);*/
1280 g_mutex_lock(&cb_info->user_cb_mutex[event]);
1282 if (cb_info->user_cb[event] == NULL) {
1283 if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
1284 event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
1285 event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
1286 event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1287 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1288 LOGW("NULL callback for event %d, return here", event);
1292 /* return buffer message should be sent for some events.
1293 - MUSE_CAMERA_EVENT_TYPE_PREVIEW
1294 - MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW
1295 - MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION
1296 - MUSE_CAMERA_EVENT_TYPE_CAPTURE
1301 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1307 muse_camera_msg_get(previous, recv_msg);
1308 muse_camera_msg_get(current, recv_msg);
1309 muse_camera_msg_get(by_policy, recv_msg);
1311 LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
1312 previous, current, by_policy);
1314 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1315 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1318 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1322 muse_camera_msg_get(state, recv_msg);
1324 LOGD("FOCUS state - %d", state);
1326 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1329 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1330 LOGD("CAPTURE_COMPLETED");
1331 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1333 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1334 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1335 __camera_event_handler_preview(cb_info, recv_msg);
1338 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1342 muse_camera_msg_get(percent, recv_msg);
1344 LOGD("HDR progress - %d %%", percent);
1346 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1349 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1355 muse_camera_msg_get(policy, recv_msg);
1356 muse_camera_msg_get(previous, recv_msg);
1357 muse_camera_msg_get(current, recv_msg);
1359 LOGW("INTERRUPTED - policy %d, state %d -> %d", policy, previous, current);
1361 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1362 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1365 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1370 muse_camera_msg_get(policy, recv_msg);
1371 muse_camera_msg_get(state, recv_msg);
1373 LOGW("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1375 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1376 (camera_state_e)state, cb_info->user_data[event]);
1379 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1380 __camera_event_handler_face_detection(cb_info, recv_msg);
1382 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1385 int current_state = 0;
1387 muse_camera_msg_get(error, recv_msg);
1388 muse_camera_msg_get(current_state, recv_msg);
1390 LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
1392 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1393 (camera_state_e)current_state, cb_info->user_data[event]);
1397 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1399 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1400 muse_camera_msg_get(param1, recv_msg);
1401 muse_camera_msg_get(param2, recv_msg);
1403 /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/
1405 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1406 cb_info->user_cb[event] = NULL;
1407 cb_info->user_data[event] = NULL;
1408 LOGW("stop foreach callback for event %d", event);
1411 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1413 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1415 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1417 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1419 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1421 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1423 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1425 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1427 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1429 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1431 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1433 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1435 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1438 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1440 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1441 muse_camera_msg_get(param1, recv_msg);
1443 /*LOGD("event %d SUPPORTED %d ", event, param1);*/
1445 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1446 cb_info->user_cb[event] = NULL;
1447 cb_info->user_data[event] = NULL;
1448 LOGW("stop foreach callback for event %d", event);
1452 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1453 __camera_event_handler_capture(cb_info, recv_msg);
1456 LOGW("unhandled event %d", event);
1460 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1465 static bool _camera_idle_event_callback(void *data)
1467 camera_cb_info_s *cb_info = NULL;
1468 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1470 if (cam_idle_event == NULL) {
1471 LOGE("cam_idle_event is NULL");
1476 g_mutex_lock(&cam_idle_event->event_mutex);
1478 cb_info = cam_idle_event->cb_info;
1479 if (cb_info == NULL) {
1480 LOGW("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1481 goto IDLE_EVENT_CALLBACK_DONE;
1484 /* remove event from list */
1485 g_mutex_lock(&cb_info->idle_event_mutex);
1487 if (cb_info->idle_event_list)
1488 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1490 /*LOGD("remove camera idle event %p, %p", cam_idle_event, cb_info->idle_event_list);*/
1491 g_mutex_unlock(&cb_info->idle_event_mutex);
1494 _camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
1496 /* send signal for waiting thread */
1497 g_cond_signal(&cb_info->idle_event_cond);
1499 IDLE_EVENT_CALLBACK_DONE:
1500 /* unlock and release event */
1501 g_mutex_unlock(&cam_idle_event->event_mutex);
1502 g_mutex_clear(&cam_idle_event->event_mutex);
1504 g_free(cam_idle_event);
1505 cam_idle_event = NULL;
1510 static void *_camera_msg_handler_func(gpointer data)
1514 camera_message_s *cam_msg = NULL;
1515 camera_idle_event_s *cam_idle_event = NULL;
1516 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1517 camera_cb_info_s *cb_info = NULL;
1519 if (!handler_info || !handler_info->cb_info) {
1520 LOGE("NULL handler %p", handler_info);
1524 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1525 type = handler_info->type;
1527 LOGD("t:%d start", type);
1529 g_mutex_lock(&handler_info->mutex);
1531 while (g_atomic_int_get(&handler_info->running)) {
1532 if (g_queue_is_empty(handler_info->queue)) {
1533 /*LOGD("t:%d signal wait...", type);*/
1534 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1535 /*LOGD("t:%d signal received", type);*/
1537 if (g_atomic_int_get(&handler_info->running) == 0) {
1538 LOGD("t:%d stop event thread", type);
1543 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1545 g_mutex_unlock(&handler_info->mutex);
1547 if (cam_msg == NULL) {
1548 LOGE("t:%d NULL message", type);
1549 g_mutex_lock(&handler_info->mutex);
1555 if (api < MUSE_CAMERA_API_MAX) {
1558 g_mutex_lock(&cb_info->api_mutex[api]);
1560 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1561 if (cb_info->api_waiting[api] > 0) {
1562 cb_info->api_ret[api] = ret;
1563 cb_info->api_activating[api] = 1;
1565 /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
1567 g_cond_signal(&cb_info->api_cond[api]);
1569 LOGW("no waiting for this api [%d]", api);
1572 LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1575 g_mutex_unlock(&cb_info->api_mutex[api]);
1576 } else if (api == MUSE_CAMERA_CB_EVENT) {
1577 switch (cam_msg->event_class) {
1578 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1579 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event);
1581 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1582 cam_idle_event = g_new0(camera_idle_event_s, 1);
1583 if (cam_idle_event == NULL) {
1584 LOGE("t:%d cam_idle_event alloc failed", type);
1588 cam_idle_event->event = cam_msg->event;
1589 cam_idle_event->cb_info = cb_info;
1590 g_mutex_init(&cam_idle_event->event_mutex);
1591 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg) - 1);
1593 /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, cam_msg->event, cam_idle_event);*/
1595 g_mutex_lock(&cb_info->idle_event_mutex);
1596 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1597 g_mutex_unlock(&cb_info->idle_event_mutex);
1599 g_idle_add_full(G_PRIORITY_DEFAULT,
1600 (GSourceFunc)_camera_idle_event_callback,
1601 (gpointer)cam_idle_event,
1605 LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
1609 LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1615 g_mutex_lock(&handler_info->mutex);
1618 /* remove remained event */
1619 while (!g_queue_is_empty(handler_info->queue)) {
1620 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1622 LOGD("t:%d remove camera message %p", type, cam_msg);
1626 LOGW("t:%d NULL camera message", type);
1630 g_mutex_unlock(&handler_info->mutex);
1632 LOGD("t:%d return", type);
1638 static void _camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1640 camera_idle_event_s *cam_idle_event = NULL;
1642 gint64 end_time = 0;
1644 if (cb_info == NULL) {
1645 LOGE("cb_info is NULL");
1649 g_mutex_lock(&cb_info->idle_event_mutex);
1651 if (cb_info->idle_event_list == NULL) {
1652 LOGD("No remained idle event");
1653 g_mutex_unlock(&cb_info->idle_event_mutex);
1657 list = cb_info->idle_event_list;
1660 cam_idle_event = list->data;
1661 list = g_list_next(list);
1663 if (!cam_idle_event) {
1664 LOGW("Fail to remove idle event. The event is NULL");
1668 if (g_idle_remove_by_data(cam_idle_event)) {
1669 LOGW("remove idle event %p done", cam_idle_event);
1671 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1673 g_mutex_clear(&cam_idle_event->event_mutex);
1674 g_free(cam_idle_event);
1675 cam_idle_event = NULL;
1680 LOGW("remove idle event %p failed", cam_idle_event);
1682 if (!g_mutex_trylock(&cam_idle_event->event_mutex)) {
1683 LOGW("lock failed, %p event is calling now", cam_idle_event);
1685 end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
1687 if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
1688 LOGW("signal received");
1695 LOGW("set NULL cb_info for event %p %d, it will be freed on idle callback",
1696 cam_idle_event, cam_idle_event->event);
1698 cam_idle_event->cb_info = NULL;
1700 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1702 g_mutex_unlock(&cam_idle_event->event_mutex);
1705 g_list_free(cb_info->idle_event_list);
1706 cb_info->idle_event_list = NULL;
1708 g_mutex_unlock(&cb_info->idle_event_mutex);
1714 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg)
1716 camera_message_s *cam_msg = NULL;
1718 if (!cb_info || !msg) {
1719 LOGE("NULL pointer %p %p", cb_info, msg);
1723 cam_msg = g_new0(camera_message_s, 1);
1725 LOGE("failed to alloc cam_msg for [%s]", msg);
1730 cam_msg->event = event;
1731 cam_msg->event_class = event_class;
1733 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1735 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1737 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1738 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1739 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1740 g_cond_signal(&cb_info->preview_cb_info.cond);
1741 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1742 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1743 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1744 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1745 g_cond_signal(&cb_info->capture_cb_info.cond);
1746 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1748 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1749 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1750 g_cond_signal(&cb_info->msg_handler_info.cond);
1751 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1760 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg)
1762 int ret = CAMERA_ERROR_NONE;
1766 int event_class = -1;
1770 if (!cb_info || !msg) {
1771 LOGE("invalid ptr %p %p", cb_info, msg);
1775 /*LOGD("msg [%s]", msg);*/
1777 if (!muse_camera_msg_get(api, msg)) {
1778 LOGE("failed to get camera api");
1782 if (api == MUSE_CAMERA_CB_EVENT) {
1783 if (!muse_camera_msg_get(event, msg) ||
1784 !muse_camera_msg_get(event_class, msg)) {
1785 LOGE("failed to get camera event or event_class [%s]", msg);
1789 if (!muse_camera_msg_get(api_class, msg)) {
1790 LOGE("failed to get camera api_class [%s]", msg);
1795 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1796 if (api >= MUSE_CAMERA_API_MAX) {
1797 LOGE("invalid api %d", api);
1801 if (!muse_camera_msg_get(ret, msg)) {
1802 LOGE("failed to get camera ret");
1806 g_mutex_lock(&cb_info->api_mutex[api]);
1809 case MUSE_CAMERA_API_CREATE:
1810 if (ret != CAMERA_ERROR_NONE) {
1811 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1812 LOGE("camera create error 0x%x. close client cb handler", ret);
1815 case MUSE_CAMERA_API_DESTROY:
1816 if (ret == CAMERA_ERROR_NONE) {
1817 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1818 LOGD("camera destroy done. close client cb handler");
1822 muse_camera_msg_get(get_type, msg);
1823 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1824 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1825 muse_camera_msg_get(get_index, msg);
1828 case MUSE_CAMERA_GET_TYPE_INT:
1829 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
1831 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1832 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
1833 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
1835 case MUSE_CAMERA_GET_TYPE_ARRAY:
1836 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
1837 muse_core_msg_deserialize("get_value",
1838 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
1839 LOGD("get display roi %d,%d,%dx%d",
1840 cb_info->get_display_roi_area[0],
1841 cb_info->get_display_roi_area[1],
1842 cb_info->get_display_roi_area[2],
1843 cb_info->get_display_roi_area[3]);
1845 muse_core_msg_deserialize("get_value",
1846 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
1847 LOGD("get geotag %lf, %lf, %lf",
1848 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
1851 case MUSE_CAMERA_GET_TYPE_STRING:
1852 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
1855 LOGW("unknown type %d", get_type);
1862 if (cb_info->api_waiting[api] > 0) {
1863 cb_info->api_ret[api] = ret;
1864 cb_info->api_activating[api] = 1;
1866 g_cond_signal(&cb_info->api_cond[api]);
1868 LOGW("no waiting for this api [%d]", api);
1871 g_mutex_unlock(&cb_info->api_mutex[api]);
1872 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
1873 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg);
1875 LOGW("unknown camera api %d, class %d", api, api_class);
1882 static void *_camera_msg_recv_func(gpointer data)
1884 int recv_length = 0;
1885 int single_length = 0;
1886 int remained_length = 0;
1887 char *recv_msg = NULL;
1888 char *single_msg = NULL;
1889 char *remained_msg = NULL;
1893 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
1896 LOGE("cb_info NULL");
1900 LOGD("start - fd : %d", cb_info->fd);
1902 single_msg = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
1904 LOGE("single_msg malloc failed");
1908 recv_msg = cb_info->recv_msg;
1910 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
1911 recv_length = muse_core_msg_recv(cb_info->fd, recv_msg, MUSE_MSG_MAX_LENGTH);
1912 if (recv_length <= 0) {
1913 cb_info->is_server_connected = FALSE;
1914 LOGE("receive msg failed - server disconnected");
1922 /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
1924 /* Need to split the combined entering msgs */
1925 for (cur_pos = 0 ; cur_pos < recv_length ; cur_pos++) {
1926 if (recv_msg[cur_pos] == '}') {
1927 single_length = cur_pos - prev_pos + 1;
1929 if (single_length < MUSE_CAMERA_MSG_MAX_LENGTH) {
1930 /* check remained msg */
1931 if (remained_length > 0) {
1933 strncpy(single_msg, remained_msg, remained_length);
1934 strncpy(single_msg + remained_length, recv_msg + prev_pos, single_length);
1935 single_msg[remained_length + single_length] = '\0';
1938 remained_msg = NULL;
1940 strncpy(single_msg, recv_msg + prev_pos, single_length);
1941 single_msg[single_length] = '\0';
1942 LOGE("lost msg [%s], skip...", single_msg);
1945 remained_length = 0;
1947 strncpy(single_msg, recv_msg + prev_pos, single_length);
1948 single_msg[single_length] = '\0';
1951 if (single_msg[0] == '{') {
1953 /*LOGD("splitted msg : [%s], Index : %d", single_msg, num_msg);*/
1954 /* process each message */
1955 __camera_process_msg(cb_info, single_msg);
1957 LOGE("invalid msg [%s]", single_msg);
1960 LOGE("too long message [len %d] skip...", single_length);
1963 prev_pos = cur_pos + 1;
1967 /* check incompleted message */
1968 if (recv_msg[recv_length - 1] != '}') {
1969 remained_length = recv_length - prev_pos;
1971 LOGW("incompleted message [len %d]", remained_length);
1975 remained_msg = NULL;
1978 remained_msg = (char *)malloc(remained_length + 1);
1980 strncpy(remained_msg, recv_msg + prev_pos, remained_length);
1981 remained_msg[remained_length] = '\0';
1983 LOGE("failed to alloc for remained msg");
1986 remained_length = 0;
1990 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
1992 if (!cb_info->is_server_connected) {
1993 char *error_msg = NULL;
1995 if (cb_info->fd < 0) {
1996 LOGE("fd is closed in client side");
1997 goto CB_HANDLER_EXIT;
2000 /* send error msg for server disconnection */
2001 error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
2002 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
2003 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
2007 LOGE("error_msg failed");
2008 goto CB_HANDLER_EXIT;
2011 __camera_add_msg_to_queue(cb_info,
2012 MUSE_CAMERA_CB_EVENT,
2013 MUSE_CAMERA_EVENT_TYPE_ERROR,
2014 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
2017 muse_core_msg_free(error_msg);
2020 LOGE("add error msg for service disconnection done");
2031 remained_msg = NULL;
2038 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2039 int type, const char *thread_name, camera_cb_info_s *cb_info)
2041 if (!handler_info || !thread_name || !cb_info) {
2042 LOGE("t:%d NULL %p %p %p",
2043 type, handler_info, thread_name, cb_info);
2049 handler_info->type = type;
2050 handler_info->queue = g_queue_new();
2051 if (handler_info->queue == NULL) {
2052 LOGE("t:%d queue failed", type);
2056 g_mutex_init(&handler_info->mutex);
2057 g_cond_init(&handler_info->cond);
2059 handler_info->cb_info = (void *)cb_info;
2060 g_atomic_int_set(&handler_info->running, 1);
2062 handler_info->thread = g_thread_try_new(thread_name,
2063 _camera_msg_handler_func, (gpointer)handler_info, NULL);
2064 if (handler_info->thread == NULL) {
2065 LOGE("t:%d thread failed", type);
2067 g_mutex_clear(&handler_info->mutex);
2068 g_cond_clear(&handler_info->cond);
2069 g_queue_free(handler_info->queue);
2070 handler_info->queue = NULL;
2075 LOGD("t:%d done", type);
2081 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2085 if (!handler_info) {
2086 LOGE("NULL handler");
2090 if (!handler_info->thread) {
2091 LOGW("thread is not created");
2095 type = handler_info->type;
2097 LOGD("t:%d thread %p", type, handler_info->thread);
2099 g_mutex_lock(&handler_info->mutex);
2100 g_atomic_int_set(&handler_info->running, 0);
2101 g_cond_signal(&handler_info->cond);
2102 g_mutex_unlock(&handler_info->mutex);
2104 g_thread_join(handler_info->thread);
2105 handler_info->thread = NULL;
2107 g_mutex_clear(&handler_info->mutex);
2108 g_cond_clear(&handler_info->cond);
2109 g_queue_free(handler_info->queue);
2110 handler_info->queue = NULL;
2112 LOGD("t:%d done", type);
2118 static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
2120 camera_cb_info_s *cb_info = NULL;
2123 g_return_val_if_fail(sockfd > 0, NULL);
2125 cb_info = g_new0(camera_cb_info_s, 1);
2126 if (cb_info == NULL) {
2127 LOGE("cb_info failed");
2131 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2133 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2134 g_mutex_init(&cb_info->api_mutex[i]);
2135 g_cond_init(&cb_info->api_cond[i]);
2138 g_mutex_init(&cb_info->fd_lock);
2139 g_mutex_init(&cb_info->idle_event_mutex);
2140 g_cond_init(&cb_info->idle_event_cond);
2141 g_mutex_init(&cb_info->mp_data_mutex);
2143 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2144 g_mutex_init(&cb_info->user_cb_mutex[i]);
2146 /* message handler thread */
2147 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2148 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2149 LOGE("msg_handler_info failed");
2153 /* message handler thread for preview callback */
2154 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2155 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2156 LOGE("preview_cb_info failed");
2160 /* message handler thread for capture callback */
2161 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2162 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2163 LOGE("capture_cb_info failed");
2167 cb_info->fd = sockfd;
2168 cb_info->preview_cb_flag = 0;
2170 /* message receive thread */
2171 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2172 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2173 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2174 if (cb_info->msg_recv_thread == NULL) {
2175 LOGE("message receive thread creation failed");
2179 cb_info->is_server_connected = TRUE;
2185 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2186 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2187 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2189 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2190 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2192 g_mutex_clear(&cb_info->fd_lock);
2193 g_mutex_clear(&cb_info->idle_event_mutex);
2194 g_cond_clear(&cb_info->idle_event_cond);
2195 g_mutex_clear(&cb_info->mp_data_mutex);
2197 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2198 g_mutex_clear(&cb_info->api_mutex[i]);
2199 g_cond_clear(&cb_info->api_cond[i]);
2210 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2214 g_return_if_fail(cb_info != NULL);
2216 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2218 g_thread_join(cb_info->msg_recv_thread);
2219 cb_info->msg_recv_thread = NULL;
2221 LOGD("msg_recv thread removed");
2223 /* destroy msg handler threads */
2224 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2225 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2226 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2228 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2229 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2231 g_mutex_clear(&cb_info->fd_lock);
2232 g_mutex_clear(&cb_info->idle_event_mutex);
2233 g_cond_clear(&cb_info->idle_event_cond);
2234 g_mutex_clear(&cb_info->mp_data_mutex);
2236 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2237 g_mutex_clear(&cb_info->api_mutex[i]);
2238 g_cond_clear(&cb_info->api_cond[i]);
2241 if (cb_info->fd > -1) {
2242 muse_client_close(cb_info->fd);
2246 if (cb_info->bufmgr) {
2247 tbm_bufmgr_deinit(cb_info->bufmgr);
2248 cb_info->bufmgr = NULL;
2250 if (cb_info->pkt_fmt) {
2251 media_format_unref(cb_info->pkt_fmt);
2252 cb_info->pkt_fmt = NULL;
2255 if (cb_info->dp_interface) {
2256 mm_display_interface_deinit(cb_info->dp_interface);
2257 cb_info->dp_interface = NULL;
2260 cb_info->preview_cb_flag = 0;
2269 int _camera_start_evas_rendering(camera_h camera)
2271 camera_cli_s *pc = (camera_cli_s *)camera;
2273 if (!pc || !pc->cb_info) {
2274 LOGE("NULL handle");
2275 return CAMERA_ERROR_INVALID_PARAMETER;
2280 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2281 LOGE("EVAS surface is not set");
2282 return CAMERA_ERROR_NONE;
2285 /* set evas render flag as RUN */
2286 pc->cb_info->run_evas_render = true;
2288 return CAMERA_ERROR_NONE;
2292 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2294 int ret = CAMERA_ERROR_NONE;
2295 camera_cli_s *pc = (camera_cli_s *)camera;
2297 if (!pc || !pc->cb_info) {
2298 LOGE("NULL handle");
2299 return CAMERA_ERROR_INVALID_PARAMETER;
2302 LOGD("stop - keep screen %d", keep_screen);
2304 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2305 LOGE("EVAS surface is not set");
2306 return CAMERA_ERROR_NONE;
2309 /* set evas render flag as STOP and release buffers */
2310 pc->cb_info->run_evas_render = false;
2312 ret = mm_display_interface_evas_flush(pc->cb_info->dp_interface, keep_screen);
2313 if (ret == MM_ERROR_NONE) {
2314 ret = CAMERA_ERROR_NONE;
2316 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2317 ret = CAMERA_ERROR_INVALID_OPERATION;
2324 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2326 int ret = CAMERA_ERROR_NONE;
2329 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2331 /* create muse connection */
2332 if (!key || !value) {
2333 LOGE("NULL pointer");
2334 return CAMERA_ERROR_INVALID_PARAMETER;
2337 sock_fd = muse_client_new();
2339 LOGE("muse_client_new failed");
2340 return CAMERA_ERROR_INVALID_OPERATION;
2343 msg = muse_core_msg_new(api,
2344 MUSE_TYPE_INT, "module", MUSE_CAMERA,
2345 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2349 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2353 ret = muse_core_msg_send(sock_fd, msg);
2355 muse_core_msg_free(msg);
2359 LOGE("send msg failed");
2360 ret = CAMERA_ERROR_INVALID_OPERATION;
2364 ret = muse_core_msg_recv(sock_fd, recv_msg, MUSE_CAMERA_MSG_MAX_LENGTH);
2366 LOGE("recv msg failed %d", errno);
2367 ret = CAMERA_ERROR_INVALID_OPERATION;
2371 if (!muse_camera_msg_get(ret, recv_msg)) {
2372 LOGE("failed to get return value from msg [%s]", recv_msg);
2373 ret = CAMERA_ERROR_INVALID_OPERATION;
2377 if (ret == CAMERA_ERROR_NONE)
2378 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2380 LOGD("api %d - value %d", api, *value);
2384 muse_client_close(sock_fd);
2392 int camera_create(camera_device_e device, camera_h *camera)
2395 char *send_msg = NULL;
2397 int ret = CAMERA_ERROR_NONE;
2399 camera_cli_s *pc = NULL;
2400 tbm_bufmgr bufmgr = NULL;
2402 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2403 muse_core_api_module_e muse_module = MUSE_CAMERA;
2404 int device_type = (int)device;
2407 LOGE("NULL pointer");
2408 return CAMERA_ERROR_INVALID_PARAMETER;
2411 sock_fd = muse_client_new();
2413 LOGE("muse_client_new failed - returned fd %d", sock_fd);
2414 ret = CAMERA_ERROR_INVALID_OPERATION;
2420 send_msg = muse_core_msg_new(api,
2421 MUSE_TYPE_INT, "module", muse_module,
2422 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2423 MUSE_TYPE_INT, "pid", pid,
2428 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2432 send_ret = muse_core_msg_send(sock_fd, send_msg);
2434 muse_core_msg_free(send_msg);
2438 LOGE("send msg failed %d", errno);
2439 ret = CAMERA_ERROR_INVALID_OPERATION;
2443 pc = g_new0(camera_cli_s, 1);
2445 LOGE("camera_cli_s alloc failed");
2446 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2450 bufmgr = tbm_bufmgr_init(-1);
2451 if (bufmgr == NULL) {
2452 LOGE("get tbm bufmgr failed");
2453 ret = CAMERA_ERROR_INVALID_OPERATION;
2457 pc->cb_info = _camera_client_callback_new(sock_fd);
2458 if (pc->cb_info == NULL) {
2459 LOGE("cb_info alloc failed");
2460 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2466 LOGD("cb info : %d", pc->cb_info->fd);
2468 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2470 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2472 if (ret == CAMERA_ERROR_NONE) {
2473 intptr_t handle = 0;
2475 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2477 LOGE("Receiving Handle Failed!!");
2478 ret = CAMERA_ERROR_INVALID_OPERATION;
2482 pc->remote_handle = handle;
2483 pc->cb_info->bufmgr = bufmgr;
2485 ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL);
2486 if (ret != CAMERA_ERROR_NONE) {
2487 LOGE("init display failed 0x%x", ret);
2491 LOGD("camera create 0x%x", pc->remote_handle);
2493 *camera = (camera_h)pc;
2495 /* get display interface handle */
2496 if (mm_display_interface_init(&pc->cb_info->dp_interface) != MM_ERROR_NONE)
2497 LOGW("display interface init failed");
2499 /* get default preview format */
2500 if (camera_get_preview_format(*camera, &pc->cb_info->preview_format) != CAMERA_ERROR_NONE) {
2501 LOGW("get default preview format failed");
2502 pc->cb_info->preview_format = CAMERA_PIXEL_FORMAT_INVALID;
2512 tbm_bufmgr_deinit(bufmgr);
2517 muse_client_close(sock_fd);
2523 int temp_fd = pc->cb_info->fd;
2525 /* pc->cb_info->fd should be closed,
2526 because g_thread_join for msg_recv_thread is not returned
2527 in _camera_client_callback_destroy. */
2529 pc->cb_info->fd = -1;
2530 muse_client_close(temp_fd);
2533 _camera_client_callback_destroy(pc->cb_info);
2540 LOGE("camera create error : 0x%x", ret);
2547 int camera_change_device(camera_h camera, camera_device_e device)
2550 int ret = CAMERA_ERROR_NONE;
2551 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2552 camera_cli_s *pc = (camera_cli_s *)camera;
2553 camera_msg_param param;
2555 if (!pc || !pc->cb_info) {
2556 LOGE("NULL handle");
2557 return CAMERA_ERROR_INVALID_PARAMETER;
2560 CAMERA_MSG_PARAM_SET(param, INT, device);
2562 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2564 if (ret == CAMERA_ERROR_NONE) {
2565 /* reset callback and user data */
2566 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2567 pc->cb_info->user_cb[i] = NULL;
2568 pc->cb_info->user_data[i] = NULL;
2570 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
2577 int camera_destroy(camera_h camera)
2579 int ret = CAMERA_ERROR_NONE;
2580 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2581 camera_cli_s *pc = (camera_cli_s *)camera;
2583 if (!pc || !pc->cb_info) {
2584 LOGE("NULL handle");
2585 return CAMERA_ERROR_INVALID_PARAMETER;
2590 if (pc->cb_info->is_server_connected)
2591 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2593 LOGW("server disconnected. release resource without send message.");
2595 if (ret == CAMERA_ERROR_NONE) {
2596 _camera_deactivate_idle_event_all(pc->cb_info);
2597 _camera_client_callback_destroy(pc->cb_info);
2604 LOGD("ret : 0x%x", ret);
2609 int camera_start_preview(camera_h camera)
2611 int ret = CAMERA_ERROR_NONE;
2612 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2613 camera_cli_s *pc = (camera_cli_s *)camera;
2615 if (!pc || !pc->cb_info) {
2616 LOGE("NULL handle");
2617 return CAMERA_ERROR_INVALID_PARAMETER;
2620 LOGD("Enter : preview format %d, display type %d",
2621 pc->cb_info->preview_format, pc->cb_info->dp_type);
2623 if (pc->cb_info->preview_format == CAMERA_PIXEL_FORMAT_INVZ &&
2624 pc->cb_info->dp_type != CAMERA_DISPLAY_TYPE_NONE) {
2625 LOGE("CAMERA_DISPLAY_TYPE_NONE[current %d] should be set with INVZ format",
2626 pc->cb_info->dp_type);
2627 return CAMERA_ERROR_INVALID_OPERATION;
2630 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2631 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2632 ret = _camera_start_evas_rendering(camera);
2633 if (ret != CAMERA_ERROR_NONE) {
2634 LOGE("stop preview because of error");
2635 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, pc->cb_info, NULL, 0);
2639 LOGD("ret : 0x%x", ret);
2645 int camera_stop_preview(camera_h camera)
2647 int ret = CAMERA_ERROR_NONE;
2648 camera_cli_s *pc = (camera_cli_s *)camera;
2649 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2650 camera_state_e current_state = CAMERA_STATE_NONE;
2652 if (!pc || !pc->cb_info) {
2653 LOGE("NULL handle");
2654 return CAMERA_ERROR_INVALID_PARAMETER;
2660 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2661 ret = camera_get_state(camera, ¤t_state);
2662 if (ret != CAMERA_ERROR_NONE) {
2663 LOGE("failed to get current state 0x%x", ret);
2667 if (current_state == CAMERA_STATE_PREVIEW) {
2668 ret = _camera_stop_evas_rendering(camera, false);
2669 if (ret != CAMERA_ERROR_NONE)
2674 /* send stop preview message */
2675 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2677 if (ret != CAMERA_ERROR_NONE &&
2678 current_state == CAMERA_STATE_PREVIEW) {
2679 LOGW("restart evas rendering");
2680 _camera_start_evas_rendering(camera);
2683 LOGD("ret : 0x%x", ret);
2689 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2691 int ret = CAMERA_ERROR_NONE;
2692 camera_cli_s *pc = (camera_cli_s *)camera;
2693 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2695 if (!pc || !pc->cb_info) {
2696 LOGE("NULL handle");
2697 return CAMERA_ERROR_INVALID_PARAMETER;
2702 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2703 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2705 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2706 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2708 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2710 LOGD("ret : 0x%x", ret);
2716 bool camera_is_supported_continuous_capture(camera_h camera)
2718 int ret = CAMERA_ERROR_NONE;
2719 camera_cli_s *pc = (camera_cli_s *)camera;
2720 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2722 if (!pc || !pc->cb_info) {
2723 LOGE("NULL handle");
2724 return CAMERA_ERROR_INVALID_PARAMETER;
2729 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2732 LOGE("error is occurred 0x%x", ret);
2736 LOGD("ret : %d", ret);
2742 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)
2744 int ret = CAMERA_ERROR_NONE;
2745 camera_cli_s *pc = (camera_cli_s *)camera;
2746 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2747 camera_msg_param param;
2750 if (!pc || !pc->cb_info) {
2751 LOGE("NULL handle");
2752 return CAMERA_ERROR_INVALID_PARAMETER;
2757 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2758 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2760 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2761 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2763 value = (count << 16) | interval;
2764 CAMERA_MSG_PARAM_SET(param, INT, value);
2766 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2768 LOGD("ret : 0x%x", ret);
2774 int camera_stop_continuous_capture(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_STOP_CONTINUOUS_CAPTURE;
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);
2789 LOGD("ret : 0x%x", ret);
2795 bool camera_is_supported_face_detection(camera_h camera)
2797 int ret = CAMERA_ERROR_NONE;
2798 camera_cli_s *pc = (camera_cli_s *)camera;
2799 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2801 if (!pc || !pc->cb_info) {
2802 LOGE("NULL handle");
2803 return CAMERA_ERROR_INVALID_PARAMETER;
2808 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2811 LOGE("error is occurred 0x%x", ret);
2815 LOGD("ret : %d", ret);
2821 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2823 int ret = CAMERA_ERROR_NONE;
2824 camera_cli_s *pc = (camera_cli_s *)camera;
2825 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2827 if (!pc || !pc->cb_info) {
2828 LOGE("NULL handle");
2829 return CAMERA_ERROR_INVALID_PARAMETER;
2834 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2837 LOGE("error is occurred 0x%x", ret);
2841 LOGD("ret : %d", ret);
2847 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2849 int ret = CAMERA_ERROR_NONE;
2850 camera_cli_s *pc = (camera_cli_s *)camera;
2851 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2853 if (!pc || !pc->cb_info) {
2854 LOGE("NULL handle");
2855 return CAMERA_ERROR_INVALID_PARAMETER;
2860 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2863 LOGE("error is occurred 0x%x", ret);
2867 LOGD("ret : %d", ret);
2872 int camera_get_device_count(camera_h camera, int *device_count)
2874 int ret = CAMERA_ERROR_NONE;
2875 camera_cli_s *pc = (camera_cli_s *)camera;
2876 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2878 if (!pc || !pc->cb_info) {
2879 LOGE("NULL handle");
2880 return CAMERA_ERROR_INVALID_PARAMETER;
2885 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2887 if (ret == CAMERA_ERROR_NONE)
2888 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2890 LOGD("ret : 0x%x", ret);
2895 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2897 int ret = CAMERA_ERROR_NONE;
2898 camera_cli_s *pc = (camera_cli_s *)camera;
2899 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2901 if (!pc || !pc->cb_info) {
2902 LOGE("NULL handle");
2903 return CAMERA_ERROR_INVALID_PARAMETER;
2908 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2910 if (ret == CAMERA_ERROR_NONE) {
2911 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2913 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2914 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2916 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2919 LOGD("ret : 0x%x", ret);
2924 int camera_stop_face_detection(camera_h camera)
2926 int ret = CAMERA_ERROR_NONE;
2927 camera_cli_s *pc = (camera_cli_s *)camera;
2928 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
2930 if (!pc || !pc->cb_info) {
2931 LOGE("NULL handle");
2932 return CAMERA_ERROR_INVALID_PARAMETER;
2937 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2939 if (ret == CAMERA_ERROR_NONE) {
2940 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2942 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
2943 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
2945 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2948 LOGD("ret : 0x%x", ret);
2953 int camera_get_state(camera_h camera, camera_state_e *state)
2955 int ret = CAMERA_ERROR_NONE;
2956 camera_cli_s *pc = (camera_cli_s *)camera;
2957 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
2959 if (!pc || !pc->cb_info || !state) {
2960 LOGE("NULL pointer %p %p", pc, state);
2961 return CAMERA_ERROR_INVALID_PARAMETER;
2966 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2968 if (ret == CAMERA_ERROR_NONE)
2969 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
2971 LOGD("ret : 0x%x", ret);
2976 int camera_start_focusing(camera_h camera, bool continuous)
2978 int ret = CAMERA_ERROR_NONE;
2979 camera_cli_s *pc = (camera_cli_s *)camera;
2980 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
2981 camera_msg_param param;
2982 int is_continuous = (int)continuous;
2984 if (!pc || !pc->cb_info) {
2985 LOGE("NULL handle");
2986 return CAMERA_ERROR_INVALID_PARAMETER;
2991 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
2993 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2995 LOGD("ret : 0x%x", ret);
3000 int camera_cancel_focusing(camera_h camera)
3002 int ret = CAMERA_ERROR_NONE;
3003 camera_cli_s *pc = (camera_cli_s *)camera;
3004 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
3006 if (!pc || !pc->cb_info) {
3007 LOGE("NULL handle");
3008 return CAMERA_ERROR_INVALID_PARAMETER;
3011 LOGD("Enter, remote_handle : %x", pc->remote_handle);
3013 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3015 LOGD("ret : 0x%x", ret);
3020 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
3022 int ret = CAMERA_ERROR_NONE;
3024 camera_cli_s *pc = (camera_cli_s *)camera;
3025 camera_cb_info_s *cb_info = NULL;
3026 camera_state_e current_state = CAMERA_STATE_NONE;
3027 camera_msg_param param0;
3028 camera_msg_param param1;
3029 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3031 if (!pc || !pc->cb_info) {
3032 LOGE("NULL handle");
3033 return CAMERA_ERROR_INVALID_PARAMETER;
3036 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
3037 LOGE("invalid type %d", type);
3038 return CAMERA_ERROR_INVALID_PARAMETER;
3041 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
3042 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
3043 return CAMERA_ERROR_INVALID_PARAMETER;
3046 cb_info = (camera_cb_info_s *)pc->cb_info;
3048 ret = camera_get_state(camera, ¤t_state);
3049 if (ret != CAMERA_ERROR_NONE) {
3050 LOGE("failed to get current state 0x%x", ret);
3054 if (current_state != CAMERA_STATE_CREATED) {
3055 LOGE("INVALID_STATE : current %d", current_state);
3056 return CAMERA_ERROR_INVALID_STATE;
3059 LOGD("Enter - type : %d, display : %p", type, display);
3061 if (type != CAMERA_DISPLAY_TYPE_NONE) {
3062 /* check display interface handle */
3063 if (!cb_info->dp_interface) {
3064 LOGE("display interface not supported");
3065 return CAMERA_ERROR_NOT_SUPPORTED;
3068 ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &parent_id);
3069 if (ret != MM_ERROR_NONE) {
3070 LOGE("[INVALID_OPERATION] set display failed[0x%x]", ret);
3071 return CAMERA_ERROR_INVALID_OPERATION;
3074 if (type == CAMERA_DISPLAY_TYPE_EVAS) {
3076 camera_flip_e flip = CAMERA_FLIP_NONE;
3077 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3078 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3085 camera_get_display_flip(camera, &flip);
3086 camera_get_display_mode(camera, &mode);
3087 camera_get_display_rotation(camera, &rotation);
3088 camera_is_display_visible(camera, &visible);
3089 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3091 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
3092 flip, mode, rotation, visible, x, y, width, height);
3094 ret = mm_display_interface_evas_set_flip(cb_info->dp_interface, flip);
3095 ret |= mm_display_interface_evas_set_mode(cb_info->dp_interface, mode);
3096 ret |= mm_display_interface_evas_set_rotation(cb_info->dp_interface, rotation);
3097 ret |= mm_display_interface_evas_set_visible(cb_info->dp_interface, visible);
3099 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
3100 ret |= mm_display_interface_evas_set_roi_area(cb_info->dp_interface, x, y, width, height);
3105 CAMERA_MSG_PARAM_SET(param0, INT, type);
3106 CAMERA_MSG_PARAM_SET(param1, INT, parent_id);
3108 _camera_msg_send_param2_int(api, cb_info, &ret,
3109 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
3111 if (ret == CAMERA_ERROR_NONE) {
3112 pc->cb_info->dp_type = type;
3114 if (type == CAMERA_DISPLAY_TYPE_EVAS)
3115 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3122 int camera_set_preview_resolution(camera_h camera, int width, int height)
3124 int ret = CAMERA_ERROR_NONE;
3125 camera_state_e current_state = CAMERA_STATE_NONE;
3126 camera_cli_s *pc = (camera_cli_s *)camera;
3127 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3128 camera_msg_param param;
3131 if (!pc || !pc->cb_info) {
3132 LOGE("NULL handle");
3133 return CAMERA_ERROR_INVALID_PARAMETER;
3136 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3137 ret = camera_get_state(camera, ¤t_state);
3138 if (ret != CAMERA_ERROR_NONE) {
3139 LOGE("failed to get current state 0x%x", ret);
3143 if (current_state == CAMERA_STATE_PREVIEW) {
3144 ret = _camera_stop_evas_rendering(camera, true);
3145 if (ret != CAMERA_ERROR_NONE)
3150 value = (width << 16) | height;
3151 CAMERA_MSG_PARAM_SET(param, INT, value);
3153 LOGD("%dx%d -> 0x%x", width, height, value);
3155 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3157 LOGD("ret : 0x%x", ret);
3159 if (current_state == CAMERA_STATE_PREVIEW) {
3160 LOGW("restart evas rendering");
3161 _camera_start_evas_rendering(camera);
3168 int camera_set_capture_resolution(camera_h camera, int width, int height)
3170 int ret = CAMERA_ERROR_NONE;
3171 camera_cli_s *pc = (camera_cli_s *)camera;
3172 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3173 camera_msg_param param;
3176 if (!pc || !pc->cb_info) {
3177 LOGE("NULL handle");
3178 return CAMERA_ERROR_INVALID_PARAMETER;
3183 value = (width << 16) | height;
3184 CAMERA_MSG_PARAM_SET(param, INT, value);
3186 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3188 LOGD("ret : 0x%x", ret);
3194 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3196 int ret = CAMERA_ERROR_NONE;
3197 int set_format = (int)format;
3198 camera_cli_s *pc = (camera_cli_s *)camera;
3199 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3200 camera_msg_param param;
3202 if (!pc || !pc->cb_info) {
3203 LOGE("NULL handle");
3204 return CAMERA_ERROR_INVALID_PARAMETER;
3207 LOGD("Enter - format %d", set_format);
3209 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3211 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3213 LOGD("ret : 0x%x", ret);
3219 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3221 int ret = CAMERA_ERROR_NONE;
3222 int set_format = (int)format;
3223 camera_msg_param param;
3224 camera_cli_s *pc = (camera_cli_s *)camera;
3225 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3227 if (!pc || !pc->cb_info) {
3228 LOGE("NULL handle");
3229 return CAMERA_ERROR_INVALID_PARAMETER;
3232 LOGD("Enter - capture_format %d", set_format);
3234 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3236 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3238 if (ret == CAMERA_ERROR_NONE)
3239 pc->cb_info->preview_format = set_format;
3241 LOGD("ret : 0x%x", ret);
3247 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3249 int ret = CAMERA_ERROR_NONE;
3250 camera_cli_s *pc = (camera_cli_s *)camera;
3251 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3253 if (!pc || !pc->cb_info || !width || !height) {
3254 LOGE("NULL pointer %p %p %p", pc, width, height);
3255 return CAMERA_ERROR_INVALID_PARAMETER;
3260 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3262 if (ret == CAMERA_ERROR_NONE) {
3263 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3264 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3267 LOGD("ret : 0x%x", ret);
3273 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3275 int ret = CAMERA_ERROR_NONE;
3276 int set_rotation = (int)rotation;
3277 camera_cli_s *pc = (camera_cli_s *)camera;
3278 camera_msg_param param;
3280 if (!pc || !pc->cb_info) {
3281 LOGE("NULL handle");
3282 return CAMERA_ERROR_INVALID_PARAMETER;
3285 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3286 ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
3287 if (ret != MM_ERROR_NONE) {
3288 LOGE("failed to set rotation for evas surface 0x%x", ret);
3289 return CAMERA_ERROR_INVALID_OPERATION;
3293 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3295 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3301 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3303 int ret = CAMERA_ERROR_NONE;
3304 camera_cli_s *pc = (camera_cli_s *)camera;
3306 if (!pc || !pc->cb_info || !rotation) {
3307 LOGE("NULL pointer %p %p", pc, rotation);
3308 return CAMERA_ERROR_INVALID_PARAMETER;
3311 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3313 if (ret == CAMERA_ERROR_NONE)
3314 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3320 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3322 int ret = CAMERA_ERROR_NONE;
3323 int set_flip = (int)flip;
3324 camera_cli_s *pc = (camera_cli_s *)camera;
3325 camera_msg_param param;
3327 if (!pc || !pc->cb_info) {
3328 LOGE("NULL handle");
3329 return CAMERA_ERROR_INVALID_PARAMETER;
3332 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3333 ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
3334 if (ret != MM_ERROR_NONE) {
3335 LOGE("failed to set flip for evas surface 0x%x", ret);
3336 return CAMERA_ERROR_INVALID_OPERATION;
3340 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3342 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3348 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3350 int ret = CAMERA_ERROR_NONE;
3351 camera_cli_s *pc = (camera_cli_s *)camera;
3353 if (!pc || !pc->cb_info || !flip) {
3354 LOGE("NULL pointer %p %p", pc, flip);
3355 return CAMERA_ERROR_INVALID_PARAMETER;
3358 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3360 if (ret == CAMERA_ERROR_NONE)
3361 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3367 int camera_set_display_visible(camera_h camera, bool visible)
3369 int ret = CAMERA_ERROR_NONE;
3370 int set_visible = (int)visible;
3371 camera_cli_s *pc = (camera_cli_s *)camera;
3372 camera_msg_param param;
3374 if (!pc || !pc->cb_info) {
3375 LOGE("NULL handle");
3376 return CAMERA_ERROR_INVALID_PARAMETER;
3379 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3380 ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
3381 if (ret != MM_ERROR_NONE) {
3382 LOGE("failed to set visible for evas surface 0x%x", ret);
3383 return CAMERA_ERROR_INVALID_OPERATION;
3387 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3389 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3395 int camera_is_display_visible(camera_h camera, bool *visible)
3397 int ret = CAMERA_ERROR_NONE;
3398 camera_cli_s *pc = (camera_cli_s *)camera;
3400 if (!pc || !pc->cb_info || !visible) {
3401 LOGE("NULL pointer %p %p", pc, visible);
3402 return CAMERA_ERROR_INVALID_PARAMETER;
3405 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3407 if (ret == CAMERA_ERROR_NONE)
3408 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3414 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3416 int ret = CAMERA_ERROR_NONE;
3417 int set_mode = (int)mode;
3418 camera_cli_s *pc = (camera_cli_s *)camera;
3419 camera_msg_param param;
3421 if (!pc || !pc->cb_info) {
3422 LOGE("NULL handle");
3423 return CAMERA_ERROR_INVALID_PARAMETER;
3426 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3427 ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
3428 if (ret != MM_ERROR_NONE) {
3429 LOGE("failed to set geometry for evas surface 0x%x", ret);
3430 return CAMERA_ERROR_INVALID_OPERATION;
3434 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3436 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3442 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3444 int ret = CAMERA_ERROR_NONE;
3445 camera_cli_s *pc = (camera_cli_s *)camera;
3447 if (!pc || !pc->cb_info || !mode) {
3448 LOGE("NULL pointer %p %p", pc, mode);
3449 return CAMERA_ERROR_INVALID_PARAMETER;
3452 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3454 if (ret == CAMERA_ERROR_NONE)
3455 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3461 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3463 int ret = CAMERA_ERROR_NONE;
3464 int set_hint = (int)hint;
3465 camera_cli_s *pc = (camera_cli_s *)camera;
3466 camera_msg_param param;
3468 if (!pc || !pc->cb_info) {
3469 LOGE("NULL handle");
3470 return CAMERA_ERROR_INVALID_PARAMETER;
3473 LOGD("Enter - hint %d", set_hint);
3475 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3477 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3483 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3485 int ret = CAMERA_ERROR_NONE;
3486 camera_cli_s *pc = (camera_cli_s *)camera;
3487 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3489 if (!pc || !pc->cb_info || !hint) {
3490 LOGE("NULL pointer %p %p", pc, hint);
3491 return CAMERA_ERROR_INVALID_PARAMETER;
3494 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3496 if (ret == CAMERA_ERROR_NONE) {
3497 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3498 LOGD("display reuse hint %d", *hint);
3505 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3507 int ret = CAMERA_ERROR_NONE;
3508 camera_cli_s *pc = (camera_cli_s *)camera;
3509 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3511 if (!pc || !pc->cb_info || !width || !height) {
3512 LOGE("NULL pointer %p %p %p", pc, width, height);
3513 return CAMERA_ERROR_INVALID_PARAMETER;
3518 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3520 if (ret == CAMERA_ERROR_NONE) {
3521 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3522 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3525 LOGD("ret : 0x%x", ret);
3531 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3533 int ret = CAMERA_ERROR_NONE;
3534 camera_cli_s *pc = (camera_cli_s *)camera;
3535 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3537 if (!pc || !pc->cb_info || !format) {
3538 LOGE("NULL pointer %p %p", pc, format);
3539 return CAMERA_ERROR_INVALID_PARAMETER;
3544 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3546 if (ret == CAMERA_ERROR_NONE)
3547 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3549 LOGD("ret : 0x%x", ret);
3555 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3557 int ret = CAMERA_ERROR_NONE;
3558 camera_cli_s *pc = (camera_cli_s *)camera;
3559 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3561 if (!pc || !pc->cb_info || !format) {
3562 LOGE("NULL pointer %p %p", pc, format);
3563 return CAMERA_ERROR_INVALID_PARAMETER;
3568 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3570 if (ret == CAMERA_ERROR_NONE)
3571 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3573 LOGD("ret : 0x%x", ret);
3579 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3581 int ret = CAMERA_ERROR_NONE;
3582 camera_cli_s *pc = (camera_cli_s *)camera;
3583 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3585 if (!pc || !pc->cb_info || !facing_direction) {
3586 LOGE("NULL pointer %p %p", pc, facing_direction);
3587 return CAMERA_ERROR_INVALID_PARAMETER;
3592 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3594 if (ret == CAMERA_ERROR_NONE)
3595 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3597 LOGD("ret : 0x%x", ret);
3603 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3605 int ret = CAMERA_ERROR_NONE;
3606 camera_cli_s *pc = (camera_cli_s *)camera;
3607 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3609 if (!pc || !pc->cb_info || !callback) {
3610 LOGE("NULL pointer %p %p", pc, callback);
3611 return CAMERA_ERROR_INVALID_PARAMETER;
3616 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3618 if (ret == CAMERA_ERROR_NONE) {
3619 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3621 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3622 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3624 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3626 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3629 LOGD("ret : 0x%x", ret);
3635 int camera_unset_preview_cb(camera_h camera)
3637 int ret = CAMERA_ERROR_NONE;
3638 camera_cli_s *pc = (camera_cli_s *)camera;
3639 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3641 if (!pc || !pc->cb_info) {
3642 LOGE("NULL handle");
3643 return CAMERA_ERROR_INVALID_PARAMETER;
3648 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3650 if (ret == CAMERA_ERROR_NONE) {
3651 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3653 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3654 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3656 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3658 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3661 LOGD("ret : 0x%x", ret);
3667 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3669 int ret = CAMERA_ERROR_NONE;
3670 camera_cli_s *pc = (camera_cli_s *)camera;
3671 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3673 if (!pc || !pc->cb_info) {
3674 LOGE("NULL handle");
3675 return CAMERA_ERROR_INVALID_PARAMETER;
3678 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3679 LOGE("NOT SUPPORTED");
3680 return CAMERA_ERROR_NOT_SUPPORTED;
3683 if (callback == NULL) {
3684 LOGE("NULL callback");
3685 return CAMERA_ERROR_INVALID_PARAMETER;
3690 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3692 if (ret == CAMERA_ERROR_NONE) {
3693 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3695 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3696 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3698 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3701 LOGD("ret : 0x%x", ret);
3707 int camera_unset_media_packet_preview_cb(camera_h camera)
3709 int ret = CAMERA_ERROR_NONE;
3710 camera_cli_s *pc = (camera_cli_s *)camera;
3711 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3713 if (!pc || !pc->cb_info) {
3714 LOGE("NULL handle");
3715 return CAMERA_ERROR_INVALID_PARAMETER;
3720 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3722 if (ret == CAMERA_ERROR_NONE) {
3723 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3725 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3726 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3728 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3731 LOGD("ret : 0x%x", ret);
3737 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3739 int ret = CAMERA_ERROR_NONE;
3740 camera_cli_s *pc = (camera_cli_s *)camera;
3741 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3743 if (!pc || !pc->cb_info || !callback) {
3744 LOGE("NULL pointer %p %p", pc, callback);
3745 return CAMERA_ERROR_INVALID_PARAMETER;
3750 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3752 if (ret == CAMERA_ERROR_NONE) {
3753 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3755 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3756 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3758 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3761 LOGD("ret : 0x%x", ret);
3767 int camera_unset_state_changed_cb(camera_h camera)
3769 int ret = CAMERA_ERROR_NONE;
3770 camera_cli_s *pc = (camera_cli_s *)camera;
3771 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3773 if (!pc || !pc->cb_info) {
3774 LOGE("NULL handle");
3775 return CAMERA_ERROR_INVALID_PARAMETER;
3780 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3782 if (ret == CAMERA_ERROR_NONE) {
3783 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3785 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3786 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3788 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3791 LOGD("ret : 0x%x", ret);
3797 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3799 int ret = CAMERA_ERROR_NONE;
3800 camera_cli_s *pc = (camera_cli_s *)camera;
3801 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3803 if (!pc || !pc->cb_info || !callback) {
3804 LOGE("NULL pointer %p %p", pc, callback);
3805 return CAMERA_ERROR_INVALID_PARAMETER;
3810 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3812 if (ret == CAMERA_ERROR_NONE) {
3813 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3815 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3816 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3818 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3821 LOGD("ret : 0x%x", ret);
3827 int camera_unset_interrupted_cb(camera_h camera)
3829 int ret = CAMERA_ERROR_NONE;
3830 camera_cli_s *pc = (camera_cli_s *)camera;
3831 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3833 if (!pc || !pc->cb_info) {
3834 LOGE("NULL handle");
3835 return CAMERA_ERROR_INVALID_PARAMETER;
3840 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3842 if (ret == CAMERA_ERROR_NONE) {
3843 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3845 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3846 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3848 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3851 LOGD("ret : 0x%x", ret);
3857 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
3859 int ret = CAMERA_ERROR_NONE;
3860 camera_cli_s *pc = (camera_cli_s *)camera;
3861 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
3863 if (!pc || !pc->cb_info || !callback) {
3864 LOGE("NULL pointer %p %p", pc, callback);
3865 return CAMERA_ERROR_INVALID_PARAMETER;
3870 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3872 if (ret == CAMERA_ERROR_NONE) {
3873 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3875 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
3876 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
3878 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3881 LOGD("ret : 0x%x", ret);
3887 int camera_unset_interrupt_started_cb(camera_h camera)
3889 int ret = CAMERA_ERROR_NONE;
3890 camera_cli_s *pc = (camera_cli_s *)camera;
3891 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
3893 if (!pc || !pc->cb_info) {
3894 LOGE("NULL handle");
3895 return CAMERA_ERROR_INVALID_PARAMETER;
3900 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3902 if (ret == CAMERA_ERROR_NONE) {
3903 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3905 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3906 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3908 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3911 LOGD("ret : 0x%x", ret);
3917 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
3919 int ret = CAMERA_ERROR_NONE;
3920 camera_cli_s *pc = (camera_cli_s *)camera;
3921 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3923 if (!pc || !pc->cb_info || !callback) {
3924 LOGE("NULL pointer %p %p", pc, callback);
3925 return CAMERA_ERROR_INVALID_PARAMETER;
3930 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3932 if (ret == CAMERA_ERROR_NONE) {
3933 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3935 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3936 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3938 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3941 LOGD("ret : 0x%x", ret);
3947 int camera_unset_focus_changed_cb(camera_h camera)
3949 int ret = CAMERA_ERROR_NONE;
3950 camera_cli_s *pc = (camera_cli_s *)camera;
3951 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
3953 if (!pc || !pc->cb_info) {
3954 LOGE("NULL handle");
3955 return CAMERA_ERROR_INVALID_PARAMETER;
3960 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3962 if (ret == CAMERA_ERROR_NONE) {
3963 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3965 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3966 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3968 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3971 LOGD("ret : 0x%x", ret);
3977 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
3979 int ret = CAMERA_ERROR_NONE;
3980 camera_cli_s *pc = (camera_cli_s *)camera;
3981 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
3983 if (!pc || !pc->cb_info || !callback) {
3984 LOGE("NULL pointer %p %p", pc, callback);
3985 return CAMERA_ERROR_INVALID_PARAMETER;
3990 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3992 if (ret == CAMERA_ERROR_NONE) {
3993 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3995 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
3996 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
3998 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4001 LOGD("ret : 0x%x", ret);
4007 int camera_unset_error_cb(camera_h camera)
4009 int ret = CAMERA_ERROR_NONE;
4010 camera_cli_s *pc = (camera_cli_s *)camera;
4011 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
4013 if (!pc || !pc->cb_info) {
4014 LOGE("NULL handle");
4015 return CAMERA_ERROR_INVALID_PARAMETER;
4020 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4022 if (ret == CAMERA_ERROR_NONE) {
4023 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4025 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4026 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4028 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4031 LOGD("ret : 0x%x", ret);
4037 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4039 int ret = CAMERA_ERROR_NONE;
4040 camera_cli_s *pc = (camera_cli_s *)camera;
4041 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4043 if (!pc || !pc->cb_info || !foreach_cb) {
4044 LOGE("NULL pointer %p %p", pc, foreach_cb);
4045 return CAMERA_ERROR_INVALID_PARAMETER;
4050 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4051 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4053 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4055 LOGD("ret : 0x%x", ret);
4061 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4063 int ret = CAMERA_ERROR_NONE;
4064 camera_cli_s *pc = (camera_cli_s *)camera;
4065 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4067 if (!pc || !pc->cb_info || !foreach_cb) {
4068 LOGE("NULL pointer %p %p", pc, foreach_cb);
4069 return CAMERA_ERROR_INVALID_PARAMETER;
4074 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4075 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4077 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4079 LOGD("ret : 0x%x", ret);
4085 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4087 int ret = CAMERA_ERROR_NONE;
4088 camera_cli_s *pc = (camera_cli_s *)camera;
4089 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4091 if (!pc || !pc->cb_info || !foreach_cb) {
4092 LOGE("NULL pointer %p %p", pc, foreach_cb);
4093 return CAMERA_ERROR_INVALID_PARAMETER;
4098 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4099 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4101 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4103 LOGD("ret : 0x%x", ret);
4109 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4111 int ret = CAMERA_ERROR_NONE;
4112 camera_cli_s *pc = (camera_cli_s *)camera;
4113 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4115 if (!pc || !pc->cb_info || !foreach_cb) {
4116 LOGE("NULL pointer %p %p", pc, foreach_cb);
4117 return CAMERA_ERROR_INVALID_PARAMETER;
4122 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4123 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4125 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4127 LOGD("ret : 0x%x", ret);
4133 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4135 int ret = CAMERA_ERROR_NONE;
4136 camera_cli_s *pc = (camera_cli_s *)camera;
4137 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4139 if (!pc || !pc->cb_info || !width || !height) {
4140 LOGE("NULL pointer %p %p %p", pc, width, height);
4141 return CAMERA_ERROR_INVALID_PARAMETER;
4145 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4147 if (ret == CAMERA_ERROR_NONE) {
4148 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4149 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4152 LOGD("ret : 0x%x", ret);
4158 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4160 int ret = CAMERA_ERROR_NONE;
4161 camera_cli_s *pc = (camera_cli_s *)camera;
4162 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4164 if (!pc || !pc->cb_info || !angle) {
4165 LOGE("NULL pointer %p %p", pc, angle);
4166 return CAMERA_ERROR_INVALID_PARAMETER;
4171 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4173 if (ret == CAMERA_ERROR_NONE)
4174 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4176 LOGD("ret : 0x%x", ret);
4182 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4184 int ret = CAMERA_ERROR_NONE;
4185 camera_cli_s *pc = (camera_cli_s *)camera;
4186 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4187 camera_msg_param param;
4188 int set_mode = (int)mode;
4190 if (!pc || !pc->cb_info) {
4191 LOGE("NULL handle");
4192 return CAMERA_ERROR_INVALID_PARAMETER;
4197 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4199 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4201 LOGD("ret : 0x%x", ret);
4207 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4209 int ret = CAMERA_ERROR_NONE;
4210 camera_cli_s *pc = (camera_cli_s *)camera;
4211 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4213 if (!pc || !pc->cb_info || !mode) {
4214 LOGE("NULL pointer %p %p", pc, mode);
4215 return CAMERA_ERROR_INVALID_PARAMETER;
4220 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4222 if (ret == CAMERA_ERROR_NONE)
4223 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4225 LOGD("ret : 0x%x", ret);
4231 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4233 int ret = CAMERA_ERROR_NONE;
4234 camera_cli_s *pc = (camera_cli_s *)camera;
4235 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4237 if (!pc || !pc->cb_info || !foreach_cb) {
4238 LOGE("NULL pointer %p %p", pc, foreach_cb);
4239 return CAMERA_ERROR_INVALID_PARAMETER;
4244 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4245 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4247 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4249 LOGD("Finish, return :%x", ret);
4255 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4257 int ret = CAMERA_ERROR_NONE;
4258 camera_cli_s *pc = (camera_cli_s *)camera;
4259 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4260 camera_msg_param param;
4261 int set_fps = (int)fps;
4263 if (!pc || !pc->cb_info) {
4264 LOGE("NULL handle");
4265 return CAMERA_ERROR_INVALID_PARAMETER;
4270 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4272 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4274 LOGD("ret : 0x%x", ret);
4280 int camera_attr_set_image_quality(camera_h camera, int quality)
4282 int ret = CAMERA_ERROR_NONE;
4283 camera_cli_s *pc = (camera_cli_s *)camera;
4284 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4285 camera_msg_param param;
4287 if (!pc || !pc->cb_info) {
4288 LOGE("NULL handle");
4289 return CAMERA_ERROR_INVALID_PARAMETER;
4294 CAMERA_MSG_PARAM_SET(param, INT, quality);
4296 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4298 LOGD("ret : 0x%x", ret);
4304 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4306 int ret = CAMERA_ERROR_NONE;
4307 camera_cli_s *pc = (camera_cli_s *)camera;
4308 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4310 if (!pc || !pc->cb_info || !fps) {
4311 LOGE("NULL pointer %p %p", pc, fps);
4312 return CAMERA_ERROR_INVALID_PARAMETER;
4317 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4319 if (ret == CAMERA_ERROR_NONE)
4320 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4322 LOGD("ret : 0x%x", ret);
4328 int camera_attr_get_image_quality(camera_h camera, int *quality)
4330 int ret = CAMERA_ERROR_NONE;
4331 camera_cli_s *pc = (camera_cli_s *)camera;
4332 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4334 if (!pc || !pc->cb_info || !quality) {
4335 LOGE("NULL pointer %p %p", pc, quality);
4336 return CAMERA_ERROR_INVALID_PARAMETER;
4341 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4343 if (ret == CAMERA_ERROR_NONE)
4344 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4346 LOGD("ret : 0x%x", ret);
4352 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4354 int ret = CAMERA_ERROR_NONE;
4355 camera_cli_s *pc = (camera_cli_s *)camera;
4356 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4358 if (!pc || !pc->cb_info || !bitrate) {
4359 LOGE("NULL pointer %p %p", pc, bitrate);
4360 return CAMERA_ERROR_INVALID_PARAMETER;
4365 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4367 if (ret == CAMERA_ERROR_NONE)
4368 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4370 LOGD("ret : 0x%x", ret);
4376 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4378 int ret = CAMERA_ERROR_NONE;
4379 camera_cli_s *pc = (camera_cli_s *)camera;
4380 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4381 camera_msg_param param;
4382 int set_bitrate = bitrate;
4384 if (!pc || !pc->cb_info) {
4385 LOGE("NULL handle");
4386 return CAMERA_ERROR_INVALID_PARAMETER;
4391 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4393 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4395 LOGD("ret : 0x%x", ret);
4401 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4403 int ret = CAMERA_ERROR_NONE;
4404 camera_cli_s *pc = (camera_cli_s *)camera;
4405 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4407 if (!pc || !pc->cb_info || !interval) {
4408 LOGE("NULL pointer %p %p", pc, interval);
4409 return CAMERA_ERROR_INVALID_PARAMETER;
4414 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4416 if (ret == CAMERA_ERROR_NONE)
4417 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4419 LOGD("ret : 0x%x", ret);
4425 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4427 int ret = CAMERA_ERROR_NONE;
4428 camera_cli_s *pc = (camera_cli_s *)camera;
4429 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4430 camera_msg_param param;
4431 int set_gop_interval = interval;
4433 if (!pc || !pc->cb_info) {
4434 LOGE("NULL handle");
4435 return CAMERA_ERROR_INVALID_PARAMETER;
4440 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4442 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4444 LOGD("ret : 0x%x", ret);
4450 int camera_attr_set_zoom(camera_h camera, int zoom)
4452 int ret = CAMERA_ERROR_NONE;
4453 camera_cli_s *pc = (camera_cli_s *)camera;
4454 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4455 camera_msg_param param;
4457 if (!pc || !pc->cb_info) {
4458 LOGE("NULL handle");
4459 return CAMERA_ERROR_INVALID_PARAMETER;
4462 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4464 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4466 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4468 LOGD("ret : 0x%x", ret);
4474 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
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_MODE;
4479 camera_msg_param param;
4480 int set_mode = (int)mode;
4482 if (!pc || !pc->cb_info) {
4483 LOGE("NULL handle");
4484 return CAMERA_ERROR_INVALID_PARAMETER;
4487 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4489 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4491 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4497 int camera_attr_set_af_area(camera_h camera, int x, int y)
4499 int ret = CAMERA_ERROR_NONE;
4500 camera_cli_s *pc = (camera_cli_s *)camera;
4501 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4502 camera_msg_param param;
4505 if (!pc || !pc->cb_info) {
4506 LOGE("NULL handle");
4507 return CAMERA_ERROR_INVALID_PARAMETER;
4510 LOGD("Enter - %d,%d", x, y);
4512 value = (x << 16) | y;
4513 CAMERA_MSG_PARAM_SET(param, INT, value);
4515 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4517 LOGD("ret : 0x%x", ret);
4523 int camera_attr_clear_af_area(camera_h camera)
4525 int ret = CAMERA_ERROR_NONE;
4526 camera_cli_s *pc = (camera_cli_s *)camera;
4527 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4529 if (!pc || !pc->cb_info) {
4530 LOGE("NULL handle");
4531 return CAMERA_ERROR_INVALID_PARAMETER;
4536 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4538 LOGD("ret : 0x%x", ret);
4544 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4546 int ret = CAMERA_ERROR_NONE;
4547 camera_cli_s *pc = (camera_cli_s *)camera;
4548 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4549 camera_msg_param param;
4550 int set_mode = (int)mode;
4552 if (!pc || !pc->cb_info) {
4553 LOGE("NULL handle");
4554 return CAMERA_ERROR_INVALID_PARAMETER;
4559 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4561 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4563 LOGD("ret : 0x%x", ret);
4569 int camera_attr_set_exposure(camera_h camera, int value)
4571 int ret = CAMERA_ERROR_NONE;
4572 camera_cli_s *pc = (camera_cli_s *)camera;
4573 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4574 camera_msg_param param;
4576 if (!pc || !pc->cb_info) {
4577 LOGE("NULL handle");
4578 return CAMERA_ERROR_INVALID_PARAMETER;
4583 CAMERA_MSG_PARAM_SET(param, INT, value);
4585 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4587 LOGD("ret : 0x%x", ret);
4593 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4595 int ret = CAMERA_ERROR_NONE;
4596 camera_cli_s *pc = (camera_cli_s *)camera;
4597 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4598 camera_msg_param param;
4599 int set_iso = (int)iso;
4601 if (!pc || !pc->cb_info) {
4602 LOGE("NULL handle");
4603 return CAMERA_ERROR_INVALID_PARAMETER;
4608 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4610 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4612 LOGD("ret : 0x%x", ret);
4618 int camera_attr_set_brightness(camera_h camera, int level)
4620 int ret = CAMERA_ERROR_NONE;
4621 camera_cli_s *pc = (camera_cli_s *)camera;
4622 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4623 camera_msg_param param;
4625 if (!pc || !pc->cb_info) {
4626 LOGE("NULL handle");
4627 return CAMERA_ERROR_INVALID_PARAMETER;
4632 CAMERA_MSG_PARAM_SET(param, INT, level);
4634 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4636 LOGD("ret : 0x%x", ret);
4642 int camera_attr_set_contrast(camera_h camera, int level)
4644 int ret = CAMERA_ERROR_NONE;
4645 camera_cli_s *pc = (camera_cli_s *)camera;
4646 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4647 camera_msg_param param;
4649 if (!pc || !pc->cb_info) {
4650 LOGE("NULL handle");
4651 return CAMERA_ERROR_INVALID_PARAMETER;
4656 CAMERA_MSG_PARAM_SET(param, INT, level);
4658 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4660 LOGD("ret : 0x%x", ret);
4666 int camera_attr_set_hue(camera_h camera, int level)
4668 int ret = CAMERA_ERROR_NONE;
4669 camera_cli_s *pc = (camera_cli_s *)camera;
4670 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HUE;
4671 camera_msg_param param;
4673 if (!pc || !pc->cb_info) {
4674 LOGE("NULL handle");
4675 return CAMERA_ERROR_INVALID_PARAMETER;
4680 CAMERA_MSG_PARAM_SET(param, INT, level);
4682 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4684 LOGD("ret : 0x%x", ret);
4690 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4692 int ret = CAMERA_ERROR_NONE;
4693 camera_cli_s *pc = (camera_cli_s *)camera;
4694 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4695 camera_msg_param param;
4696 int set_whitebalance = (int)wb;
4698 if (!pc || !pc->cb_info) {
4699 LOGE("NULL handle");
4700 return CAMERA_ERROR_INVALID_PARAMETER;
4705 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4707 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4709 LOGD("ret : 0x%x", ret);
4715 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4717 int ret = CAMERA_ERROR_NONE;
4718 camera_cli_s *pc = (camera_cli_s *)camera;
4719 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4720 camera_msg_param param;
4721 int set_effect = (int)effect;
4723 if (!pc || !pc->cb_info) {
4724 LOGE("NULL handle");
4725 return CAMERA_ERROR_INVALID_PARAMETER;
4730 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4732 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4734 LOGD("ret : 0x%x", ret);
4740 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4742 int ret = CAMERA_ERROR_NONE;
4743 camera_cli_s *pc = (camera_cli_s *)camera;
4744 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4745 camera_msg_param param;
4746 int set_mode = (int)mode;
4748 if (!pc || !pc->cb_info) {
4749 LOGE("NULL handle");
4750 return CAMERA_ERROR_INVALID_PARAMETER;
4755 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4757 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4759 LOGD("ret : 0x%x", ret);
4765 int camera_attr_enable_tag(camera_h camera, bool enable)
4767 int ret = CAMERA_ERROR_NONE;
4768 camera_cli_s *pc = (camera_cli_s *)camera;
4769 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4770 camera_msg_param param;
4771 int set_enable = (int)enable;
4773 if (!pc || !pc->cb_info) {
4774 LOGE("NULL handle");
4775 return CAMERA_ERROR_INVALID_PARAMETER;
4780 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4782 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4784 LOGD("ret : 0x%x", ret);
4790 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4792 int ret = CAMERA_ERROR_NONE;
4793 camera_cli_s *pc = (camera_cli_s *)camera;
4794 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4795 camera_msg_param param;
4797 if (!pc || !pc->cb_info || !description) {
4798 LOGE("NULL pointer %p %p", pc, description);
4799 return CAMERA_ERROR_INVALID_PARAMETER;
4804 CAMERA_MSG_PARAM_SET(param, STRING, description);
4806 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4808 LOGD("ret : 0x%x", ret);
4814 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4816 int ret = CAMERA_ERROR_NONE;
4817 camera_cli_s *pc = (camera_cli_s *)camera;
4818 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4819 camera_msg_param param;
4820 int set_orientation = (int)orientation;
4822 if (!pc || !pc->cb_info) {
4823 LOGE("NULL handle");
4824 return CAMERA_ERROR_INVALID_PARAMETER;
4829 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4831 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4833 LOGD("ret : 0x%x", ret);
4839 int camera_attr_set_tag_software(camera_h camera, const char *software)
4841 int ret = CAMERA_ERROR_NONE;
4842 camera_cli_s *pc = (camera_cli_s *)camera;
4843 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4844 camera_msg_param param;
4846 if (!pc || !pc->cb_info || !software) {
4847 LOGE("NULL pointer %p %p", pc, software);
4848 return CAMERA_ERROR_INVALID_PARAMETER;
4851 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4853 CAMERA_MSG_PARAM_SET(param, STRING, software);
4855 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4857 LOGD("ret : 0x%x", ret);
4863 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4865 int ret = CAMERA_ERROR_NONE;
4866 camera_cli_s *pc = (camera_cli_s *)camera;
4867 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4868 double set_geotag[3] = {latitude, longitude, altitude};
4873 if (!pc || !pc->cb_info) {
4874 LOGE("NULL handle");
4875 return CAMERA_ERROR_INVALID_PARAMETER;
4880 length = sizeof(set_geotag) / sizeof(int) + \
4881 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4883 msg = muse_core_msg_new(api,
4884 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4887 LOGE("msg creation failed: api %d", api);
4888 return CAMERA_ERROR_OUT_OF_MEMORY;
4891 if (pc->cb_info->is_server_connected) {
4892 __camera_update_api_waiting(pc->cb_info, api, 1);
4894 g_mutex_lock(&pc->cb_info->fd_lock);
4895 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
4896 g_mutex_unlock(&pc->cb_info->fd_lock);
4900 LOGE("message send failed");
4901 ret = CAMERA_ERROR_INVALID_OPERATION;
4903 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
4906 __camera_update_api_waiting(pc->cb_info, api, -1);
4908 muse_core_msg_free(msg);
4910 LOGD("ret : 0x%x", ret);
4916 int camera_attr_remove_geotag(camera_h camera)
4918 int ret = CAMERA_ERROR_NONE;
4919 camera_cli_s *pc = (camera_cli_s *)camera;
4920 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4922 if (!pc || !pc->cb_info) {
4923 LOGE("NULL handle");
4924 return CAMERA_ERROR_INVALID_PARAMETER;
4929 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4931 LOGD("ret : 0x%x", ret);
4937 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4939 int ret = CAMERA_ERROR_NONE;
4940 camera_cli_s *pc = (camera_cli_s *)camera;
4941 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
4942 camera_msg_param param;
4943 int set_mode = (int)mode;
4945 if (!pc || !pc->cb_info) {
4946 LOGE("NULL handle");
4947 return CAMERA_ERROR_INVALID_PARAMETER;
4952 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4954 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4956 LOGD("ret : 0x%x", ret);
4962 int camera_attr_get_zoom(camera_h camera, int *zoom)
4964 int ret = CAMERA_ERROR_NONE;
4965 camera_cli_s *pc = (camera_cli_s *)camera;
4966 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4968 if (!pc || !pc->cb_info || !zoom) {
4969 LOGE("NULL pointer %p %p", pc, zoom);
4970 return CAMERA_ERROR_INVALID_PARAMETER;
4975 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4977 if (ret == CAMERA_ERROR_NONE)
4978 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
4980 LOGD("ret : 0x%x", ret);
4986 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
4988 int ret = CAMERA_ERROR_NONE;
4989 camera_cli_s *pc = (camera_cli_s *)camera;
4990 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
4992 if (!pc || !pc->cb_info || !min || !max) {
4993 LOGE("NULL pointer %p %p %p", pc, min, max);
4994 return CAMERA_ERROR_INVALID_PARAMETER;
4999 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5001 if (ret == CAMERA_ERROR_NONE) {
5002 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
5003 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
5006 LOGD("ret : 0x%x", ret);
5012 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
5014 int ret = CAMERA_ERROR_NONE;
5015 camera_cli_s *pc = (camera_cli_s *)camera;
5016 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
5018 if (!pc || !pc->cb_info || !mode) {
5019 LOGE("NULL pointer %p %p", pc, mode);
5020 return CAMERA_ERROR_INVALID_PARAMETER;
5025 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5027 if (ret == CAMERA_ERROR_NONE)
5028 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5030 LOGD("ret : 0x%x", ret);
5036 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5038 int ret = CAMERA_ERROR_NONE;
5039 camera_cli_s *pc = (camera_cli_s *)camera;
5040 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5042 if (!pc || !pc->cb_info || !mode) {
5043 LOGE("NULL pointer %p %p", pc, mode);
5044 return CAMERA_ERROR_INVALID_PARAMETER;
5049 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5051 if (ret == CAMERA_ERROR_NONE)
5052 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5054 LOGD("ret : 0x%x", ret);
5060 int camera_attr_get_exposure(camera_h camera, int *value)
5062 int ret = CAMERA_ERROR_NONE;
5063 camera_cli_s *pc = (camera_cli_s *)camera;
5064 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5066 if (!pc || !pc->cb_info || !value) {
5067 LOGE("NULL pointer %p %p", pc, value);
5068 return CAMERA_ERROR_INVALID_PARAMETER;
5073 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5075 if (ret == CAMERA_ERROR_NONE)
5076 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5078 LOGD("ret : 0x%x", ret);
5084 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5086 int ret = CAMERA_ERROR_NONE;
5087 camera_cli_s *pc = (camera_cli_s *)camera;
5088 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5090 if (!pc || !pc->cb_info || !min || !max) {
5091 LOGE("NULL pointer %p %p %p", pc, min, max);
5092 return CAMERA_ERROR_INVALID_PARAMETER;
5097 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5099 if (ret == CAMERA_ERROR_NONE) {
5100 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5101 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5104 LOGD("ret : 0x%x", ret);
5110 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5112 int ret = CAMERA_ERROR_NONE;
5113 camera_cli_s *pc = (camera_cli_s *)camera;
5114 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5116 if (!pc || !pc->cb_info || !iso) {
5117 LOGE("NULL pointer %p %p", pc, iso);
5118 return CAMERA_ERROR_INVALID_PARAMETER;
5123 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5125 if (ret == CAMERA_ERROR_NONE)
5126 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5128 LOGD("ret : 0x%x", ret);
5134 int camera_attr_get_brightness(camera_h camera, int *level)
5136 int ret = CAMERA_ERROR_NONE;
5137 camera_cli_s *pc = (camera_cli_s *)camera;
5138 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5140 if (!pc || !pc->cb_info || !level) {
5141 LOGE("NULL pointer %p %p", pc, level);
5142 return CAMERA_ERROR_INVALID_PARAMETER;
5147 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5149 if (ret == CAMERA_ERROR_NONE)
5150 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5152 LOGD("ret : 0x%x", ret);
5158 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5160 int ret = CAMERA_ERROR_NONE;
5161 camera_cli_s *pc = (camera_cli_s *)camera;
5162 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5164 if (!pc || !pc->cb_info || !min || !max) {
5165 LOGE("NULL pointer %p %p %p", pc, min, max);
5166 return CAMERA_ERROR_INVALID_PARAMETER;
5171 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5173 if (ret == CAMERA_ERROR_NONE) {
5174 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5175 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5178 LOGD("ret : 0x%x", ret);
5184 int camera_attr_get_contrast(camera_h camera, int *level)
5186 int ret = CAMERA_ERROR_NONE;
5187 camera_cli_s *pc = (camera_cli_s *)camera;
5188 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5190 if (!pc || !pc->cb_info || !level) {
5191 LOGE("NULL pointer %p %p", pc, level);
5192 return CAMERA_ERROR_INVALID_PARAMETER;
5197 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5199 if (ret == CAMERA_ERROR_NONE)
5200 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5202 LOGD("ret : 0x%x", ret);
5208 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5210 int ret = CAMERA_ERROR_NONE;
5211 camera_cli_s *pc = (camera_cli_s *)camera;
5212 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5214 if (!pc || !pc->cb_info || !min || !max) {
5215 LOGE("NULL pointer %p %p %p", pc, min, max);
5216 return CAMERA_ERROR_INVALID_PARAMETER;
5221 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5223 if (ret == CAMERA_ERROR_NONE) {
5224 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5225 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5226 LOGD("min %d, max %d", *min, *max);
5229 LOGD("ret : 0x%x", ret);
5235 int camera_attr_get_hue(camera_h camera, int *level)
5237 int ret = CAMERA_ERROR_NONE;
5238 camera_cli_s *pc = (camera_cli_s *)camera;
5239 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE;
5241 if (!pc || !pc->cb_info || !level) {
5242 LOGE("NULL pointer %p %p", pc, level);
5243 return CAMERA_ERROR_INVALID_PARAMETER;
5248 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5250 if (ret == CAMERA_ERROR_NONE)
5251 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HUE];
5253 LOGD("ret : 0x%x", ret);
5259 int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
5261 int ret = CAMERA_ERROR_NONE;
5262 camera_cli_s *pc = (camera_cli_s *)camera;
5263 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE_RANGE;
5265 if (!pc || !pc->cb_info || !min || !max) {
5266 LOGE("NULL pointer %p %p %p", pc, min, max);
5267 return CAMERA_ERROR_INVALID_PARAMETER;
5272 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5274 if (ret == CAMERA_ERROR_NONE) {
5275 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][0];
5276 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][1];
5277 LOGD("min %d, max %d", *min, *max);
5280 LOGD("ret : 0x%x", ret);
5286 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5288 int ret = CAMERA_ERROR_NONE;
5289 camera_cli_s *pc = (camera_cli_s *)camera;
5290 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5292 if (!pc || !pc->cb_info || !wb) {
5293 LOGE("NULL pointer %p %p", pc, wb);
5294 return CAMERA_ERROR_INVALID_PARAMETER;
5299 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5301 if (ret == CAMERA_ERROR_NONE)
5302 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5304 LOGD("ret : 0x%x", ret);
5310 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5312 int ret = CAMERA_ERROR_NONE;
5313 camera_cli_s *pc = (camera_cli_s *)camera;
5314 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5316 if (!pc || !pc->cb_info || !effect) {
5317 LOGE("NULL pointer %p %p", pc, effect);
5318 return CAMERA_ERROR_INVALID_PARAMETER;
5323 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5325 if (ret == CAMERA_ERROR_NONE)
5326 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5328 LOGD("ret : 0x%x", ret);
5334 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5336 int ret = CAMERA_ERROR_NONE;
5337 camera_cli_s *pc = (camera_cli_s *)camera;
5338 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5340 if (!pc || !pc->cb_info || !mode) {
5341 LOGE("NULL pointer %p %p", pc, mode);
5342 return CAMERA_ERROR_INVALID_PARAMETER;
5347 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5349 if (ret == CAMERA_ERROR_NONE)
5350 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5352 LOGD("ret : 0x%x", ret);
5358 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5360 int ret = CAMERA_ERROR_NONE;
5361 camera_cli_s *pc = (camera_cli_s *)camera;
5362 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5364 if (!pc || !pc->cb_info || !enable) {
5365 LOGE("NULL pointer %p %p", pc, enable);
5366 return CAMERA_ERROR_INVALID_PARAMETER;
5371 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5373 if (ret == CAMERA_ERROR_NONE)
5374 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5376 LOGD("ret : 0x%x", ret);
5382 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5384 int ret = CAMERA_ERROR_NONE;
5385 camera_cli_s *pc = (camera_cli_s *)camera;
5386 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5388 if (!pc || !pc->cb_info || !description) {
5389 LOGE("NULL pointer %p %p", pc, description);
5390 return CAMERA_ERROR_INVALID_PARAMETER;
5395 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5397 if (ret == CAMERA_ERROR_NONE)
5398 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5400 LOGD("ret : 0x%x", ret);
5406 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5408 int ret = CAMERA_ERROR_NONE;
5409 camera_cli_s *pc = (camera_cli_s *)camera;
5410 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5412 if (!pc || !pc->cb_info || !orientation) {
5413 LOGE("NULL pointer %p %p", pc, orientation);
5414 return CAMERA_ERROR_INVALID_PARAMETER;
5419 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5421 if (ret == CAMERA_ERROR_NONE)
5422 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5424 LOGD("ret : 0x%x", ret);
5430 int camera_attr_get_tag_software(camera_h camera, char **software)
5432 int ret = CAMERA_ERROR_NONE;
5433 camera_cli_s *pc = (camera_cli_s *)camera;
5434 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5436 if (!pc || !pc->cb_info || !software) {
5437 LOGE("NULL pointer %p %p", pc, software);
5438 return CAMERA_ERROR_INVALID_PARAMETER;
5443 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5445 if (ret == CAMERA_ERROR_NONE)
5446 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5448 LOGD("ret : 0x%x", ret);
5454 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5456 int ret = CAMERA_ERROR_NONE;
5457 camera_cli_s *pc = (camera_cli_s *)camera;
5458 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5460 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5461 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5462 return CAMERA_ERROR_INVALID_PARAMETER;
5467 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5469 if (ret == CAMERA_ERROR_NONE) {
5470 *latitude = pc->cb_info->get_geotag[0];
5471 *longitude = pc->cb_info->get_geotag[1];
5472 *altitude = pc->cb_info->get_geotag[2];
5475 LOGD("ret : 0x%x", ret);
5481 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5483 int ret = CAMERA_ERROR_NONE;
5484 camera_cli_s *pc = (camera_cli_s *)camera;
5485 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5487 if (!pc || !pc->cb_info || !mode) {
5488 LOGE("NULL pointer %p %p", pc, mode);
5489 return CAMERA_ERROR_INVALID_PARAMETER;
5494 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5496 if (ret == CAMERA_ERROR_NONE)
5497 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5499 LOGD("ret : 0x%x", ret);
5505 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5507 int ret = CAMERA_ERROR_NONE;
5508 int get_flash_state = 0;
5511 LOGE("NULL pointer");
5512 return CAMERA_ERROR_INVALID_PARAMETER;
5515 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5516 (int)device, "get_flash_state", &get_flash_state);
5518 if (ret == CAMERA_ERROR_NONE) {
5519 *state = (camera_flash_state_e)get_flash_state;
5520 LOGD("flash state %d", *state);
5522 LOGE("failed 0x%x", ret);
5529 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5531 int ret = CAMERA_ERROR_NONE;
5532 camera_cli_s *pc = (camera_cli_s *)camera;
5533 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5535 if (!pc || !pc->cb_info || !foreach_cb) {
5536 LOGE("NULL pointer %p %p", pc, foreach_cb);
5537 return CAMERA_ERROR_INVALID_PARAMETER;
5542 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5543 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5545 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5547 LOGD("ret : 0x%x", ret);
5553 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5555 int ret = CAMERA_ERROR_NONE;
5556 camera_cli_s *pc = (camera_cli_s *)camera;
5557 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5559 if (!pc || !pc->cb_info || !foreach_cb) {
5560 LOGE("NULL pointer %p %p", pc, foreach_cb);
5561 return CAMERA_ERROR_INVALID_PARAMETER;
5566 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5567 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5569 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5571 LOGD("ret : 0x%x", ret);
5577 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5579 int ret = CAMERA_ERROR_NONE;
5580 camera_cli_s *pc = (camera_cli_s *)camera;
5581 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5583 if (!pc || !pc->cb_info || !foreach_cb) {
5584 LOGE("NULL pointer %p %p", pc, foreach_cb);
5585 return CAMERA_ERROR_INVALID_PARAMETER;
5590 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5591 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5593 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5595 LOGD("ret : 0x%x", ret);
5601 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5603 int ret = CAMERA_ERROR_NONE;
5604 camera_cli_s *pc = (camera_cli_s *)camera;
5605 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5607 if (!pc || !pc->cb_info || !foreach_cb) {
5608 LOGE("NULL pointer %p %p", pc, foreach_cb);
5609 return CAMERA_ERROR_INVALID_PARAMETER;
5614 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5615 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5617 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5619 LOGD("ret : 0x%x", ret);
5625 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5627 int ret = CAMERA_ERROR_NONE;
5628 camera_cli_s *pc = (camera_cli_s *)camera;
5629 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5631 if (!pc || !pc->cb_info || !foreach_cb) {
5632 LOGE("NULL pointer %p %p", pc, foreach_cb);
5633 return CAMERA_ERROR_INVALID_PARAMETER;
5638 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5639 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5641 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5643 LOGD("ret : 0x%x", ret);
5649 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5651 int ret = CAMERA_ERROR_NONE;
5652 camera_cli_s *pc = (camera_cli_s *)camera;
5653 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5655 if (!pc || !pc->cb_info || !foreach_cb) {
5656 LOGE("NULL pointer %p %p", pc, foreach_cb);
5657 return CAMERA_ERROR_INVALID_PARAMETER;
5662 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5663 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5665 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5667 LOGD("ret : 0x%x", ret);
5673 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5675 int ret = CAMERA_ERROR_NONE;
5676 camera_cli_s *pc = (camera_cli_s *)camera;
5677 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5679 if (!pc || !pc->cb_info || !foreach_cb) {
5680 LOGE("NULL pointer %p %p", pc, foreach_cb);
5681 return CAMERA_ERROR_INVALID_PARAMETER;
5686 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5687 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5689 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5691 LOGD("ret : 0x%x", ret);
5697 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5699 int ret = CAMERA_ERROR_NONE;
5700 camera_cli_s *pc = (camera_cli_s *)camera;
5701 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5703 if (!pc || !pc->cb_info || !foreach_cb) {
5704 LOGE("NULL pointer %p %p", pc, foreach_cb);
5705 return CAMERA_ERROR_INVALID_PARAMETER;
5710 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5711 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5713 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5715 LOGD("Enter, handle :%x", pc->remote_handle);
5721 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)
5723 int ret = CAMERA_ERROR_NONE;
5724 camera_cli_s *pc = (camera_cli_s *)camera;
5725 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5726 camera_msg_param param;
5729 if (!pc || !pc->cb_info || !foreach_cb) {
5730 LOGE("NULL pointer %p %p", pc, foreach_cb);
5731 return CAMERA_ERROR_INVALID_PARAMETER;
5736 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5737 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5739 value = (width << 16) | height;
5740 CAMERA_MSG_PARAM_SET(param, INT, value);
5742 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5744 LOGD("ret : 0x%x", ret);
5750 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5752 int ret = CAMERA_ERROR_NONE;
5753 camera_cli_s *pc = (camera_cli_s *)camera;
5754 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5756 if (!pc || !pc->cb_info || !foreach_cb) {
5757 LOGE("NULL pointer %p %p", pc, foreach_cb);
5758 return CAMERA_ERROR_INVALID_PARAMETER;
5763 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5764 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5766 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5768 LOGD("ret : 0x%x", ret);
5774 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5776 int ret = CAMERA_ERROR_NONE;
5777 camera_cli_s *pc = (camera_cli_s *)camera;
5778 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5780 if (!pc || !pc->cb_info || !foreach_cb) {
5781 LOGE("NULL pointer %p %p", pc, foreach_cb);
5782 return CAMERA_ERROR_INVALID_PARAMETER;
5787 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5788 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5790 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5792 LOGD("ret : 0x%x", ret);
5798 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5800 int ret = CAMERA_ERROR_NONE;
5801 camera_cli_s *pc = (camera_cli_s *)camera;
5802 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5803 camera_msg_param param;
5804 int set_rotation = (int)rotation;
5806 if (!pc || !pc->cb_info) {
5807 LOGE("NULL handle");
5808 return CAMERA_ERROR_INVALID_PARAMETER;
5813 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5815 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5817 LOGD("ret : 0x%x", ret);
5823 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5825 int ret = CAMERA_ERROR_NONE;
5826 camera_cli_s *pc = (camera_cli_s *)camera;
5827 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5829 if (!pc || !pc->cb_info || !rotation) {
5830 LOGE("NULL pointer %p %p", pc, rotation);
5831 return CAMERA_ERROR_INVALID_PARAMETER;
5836 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5838 if (ret == CAMERA_ERROR_NONE)
5839 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5841 LOGD("ret : 0x%x", ret);
5847 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5849 int ret = CAMERA_ERROR_NONE;
5850 camera_cli_s *pc = (camera_cli_s *)camera;
5851 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5852 camera_msg_param param;
5853 int set_flip = (int)flip;
5855 if (!pc || !pc->cb_info) {
5856 LOGE("NULL handle");
5857 return CAMERA_ERROR_INVALID_PARAMETER;
5862 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5864 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5866 LOGD("ret : 0x%x", ret);
5872 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
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_GET_STREAM_FLIP;
5878 if (!pc || !pc->cb_info || !flip) {
5879 LOGE("NULL pointer %p %p", pc, flip);
5880 return CAMERA_ERROR_INVALID_PARAMETER;
5885 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5887 if (ret == CAMERA_ERROR_NONE)
5888 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5890 LOGD("ret : 0x%x", ret);
5895 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5897 int ret = CAMERA_ERROR_NONE;
5898 camera_cli_s *pc = (camera_cli_s *)camera;
5899 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5900 camera_msg_param param;
5901 int set_mode = (int)mode;
5903 if (!pc || !pc->cb_info) {
5904 LOGE("NULL handle");
5905 return CAMERA_ERROR_INVALID_PARAMETER;
5910 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5912 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5914 LOGD("ret : 0x%x", ret);
5920 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5922 int ret = CAMERA_ERROR_NONE;
5923 camera_cli_s *pc = (camera_cli_s *)camera;
5924 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5926 if (!pc || !pc->cb_info || !mode) {
5927 LOGE("NULL pointer %p %p", pc, mode);
5928 return CAMERA_ERROR_INVALID_PARAMETER;
5933 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5935 if (ret == CAMERA_ERROR_NONE)
5936 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
5938 LOGD("ret : 0x%x", ret);
5944 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5946 int ret = CAMERA_ERROR_NONE;
5947 camera_cli_s *pc = (camera_cli_s *)camera;
5948 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
5950 if (!pc || !pc->cb_info) {
5951 LOGE("NULL handle");
5952 return CAMERA_ERROR_INVALID_PARAMETER;
5957 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5960 LOGE("error is occurred 0x%x", ret);
5964 LOGD("ret : %d", ret);
5970 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5972 int ret = CAMERA_ERROR_NONE;
5973 camera_cli_s *pc = (camera_cli_s *)camera;
5974 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5976 if (!pc || !pc->cb_info) {
5977 LOGE("NULL handle");
5978 return CAMERA_ERROR_INVALID_PARAMETER;
5983 if (!camera_attr_is_supported_hdr_capture(camera)) {
5984 LOGE("HDR not supported");
5985 return CAMERA_ERROR_NOT_SUPPORTED;
5989 LOGE("NULL callback");
5990 return CAMERA_ERROR_INVALID_PARAMETER;
5993 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5995 if (ret == CAMERA_ERROR_NONE) {
5996 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5998 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5999 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
6001 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6004 LOGD("ret : 0x%x", ret);
6010 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
6012 int ret = CAMERA_ERROR_NONE;
6013 camera_cli_s *pc = (camera_cli_s *)camera;
6014 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
6016 if (!pc || !pc->cb_info) {
6017 LOGE("NULL handle");
6018 return CAMERA_ERROR_INVALID_PARAMETER;
6023 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6025 if (ret == CAMERA_ERROR_NONE) {
6026 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6028 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6029 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6031 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6034 LOGD("ret : 0x%x", ret);
6040 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6042 int ret = CAMERA_ERROR_NONE;
6043 camera_cli_s *pc = (camera_cli_s *)camera;
6044 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
6045 camera_msg_param param;
6046 int set_enable = (int)enable;
6048 if (!pc || !pc->cb_info) {
6049 LOGE("NULL handle");
6050 return CAMERA_ERROR_INVALID_PARAMETER;
6055 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6057 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6059 LOGD("ret : 0x%x", ret);
6065 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6067 int ret = CAMERA_ERROR_NONE;
6068 camera_cli_s *pc = (camera_cli_s *)camera;
6069 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6071 if (!pc || !pc->cb_info || !enabled) {
6072 LOGE("NULL pointer %p %p", pc, enabled);
6073 return CAMERA_ERROR_INVALID_PARAMETER;
6078 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6080 if (ret == CAMERA_ERROR_NONE)
6081 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6083 LOGD("ret : 0x%x", ret);
6089 bool camera_attr_is_supported_anti_shake(camera_h camera)
6091 int ret = CAMERA_ERROR_NONE;
6092 camera_cli_s *pc = (camera_cli_s *)camera;
6093 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6095 if (!pc || !pc->cb_info) {
6096 LOGE("NULL handle");
6097 return CAMERA_ERROR_INVALID_PARAMETER;
6102 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6105 LOGE("error is occurred 0x%x", ret);
6109 LOGD("ret : %d", ret);
6115 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6117 int ret = CAMERA_ERROR_NONE;
6118 camera_cli_s *pc = (camera_cli_s *)camera;
6119 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6120 camera_msg_param param;
6121 int set_enable = (int)enable;
6123 if (!pc || !pc->cb_info) {
6124 LOGE("NULL handle");
6125 return CAMERA_ERROR_INVALID_PARAMETER;
6130 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6132 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6134 LOGD("ret : 0x%x", ret);
6140 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6142 int ret = CAMERA_ERROR_NONE;
6143 camera_cli_s *pc = (camera_cli_s *)camera;
6144 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6146 if (!pc || !pc->cb_info || !enabled) {
6147 LOGE("NULL pointer %p %p", pc, enabled);
6148 return CAMERA_ERROR_INVALID_PARAMETER;
6153 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6155 if (ret == CAMERA_ERROR_NONE)
6156 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6158 LOGD("ret : 0x%x", ret);
6164 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6166 int ret = CAMERA_ERROR_NONE;
6167 camera_cli_s *pc = (camera_cli_s *)camera;
6168 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6170 if (!pc || !pc->cb_info) {
6171 LOGE("NULL handle");
6172 return CAMERA_ERROR_INVALID_PARAMETER;
6177 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6180 LOGE("error is occurred 0x%x", ret);
6184 LOGD("ret : %d", ret);
6190 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6192 int ret = CAMERA_ERROR_NONE;
6193 camera_cli_s *pc = (camera_cli_s *)camera;
6194 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6195 camera_msg_param param;
6196 int set_enable = (int)enable;
6198 if (!pc || !pc->cb_info) {
6199 LOGE("NULL handle");
6200 return CAMERA_ERROR_INVALID_PARAMETER;
6205 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6207 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6209 LOGD("ret : 0x%x", ret);
6215 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6217 int ret = CAMERA_ERROR_NONE;
6218 camera_cli_s *pc = (camera_cli_s *)camera;
6219 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6221 if (!pc || !pc->cb_info || !enabled) {
6222 LOGE("NULL pointer %p %p", pc, enabled);
6223 return CAMERA_ERROR_INVALID_PARAMETER;
6228 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6230 if (ret == CAMERA_ERROR_NONE)
6231 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6233 LOGD("ret : 0x%x", ret);
6239 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6241 int ret = CAMERA_ERROR_NONE;
6242 camera_cli_s *pc = (camera_cli_s *)camera;
6243 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6245 if (!pc || !pc->cb_info) {
6246 LOGE("NULL handle");
6247 return CAMERA_ERROR_INVALID_PARAMETER;
6252 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6255 LOGE("error is occurred 0x%x", ret);
6259 LOGD("ret : %d", ret);
6265 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6267 int ret = CAMERA_ERROR_NONE;
6268 camera_cli_s *pc = (camera_cli_s *)camera;
6269 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6270 camera_msg_param param;
6271 int set_disable = (int)disable;
6273 if (!pc || !pc->cb_info) {
6274 LOGE("NULL handle");
6275 return CAMERA_ERROR_INVALID_PARAMETER;
6280 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6282 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6284 LOGD("ret : 0x%x", ret);
6290 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6292 int ret = CAMERA_ERROR_NONE;
6293 camera_cli_s *pc = (camera_cli_s *)camera;
6294 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6295 camera_msg_param param;
6296 int set_move_type = (int)move_type;
6299 if (!pc || !pc->cb_info) {
6300 LOGE("NULL handle");
6301 return CAMERA_ERROR_INVALID_PARAMETER;
6306 value = (set_move_type << 16) | pan_step;
6307 CAMERA_MSG_PARAM_SET(param, INT, value);
6309 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6311 LOGD("ret : 0x%x", ret);
6317 int camera_attr_get_pan(camera_h camera, int *pan_step)
6319 int ret = CAMERA_ERROR_NONE;
6320 camera_cli_s *pc = (camera_cli_s *)camera;
6321 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6323 if (!pc || !pc->cb_info || !pan_step) {
6324 LOGE("NULL pointer %p %p", pc, pan_step);
6325 return CAMERA_ERROR_INVALID_PARAMETER;
6330 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6332 if (ret == CAMERA_ERROR_NONE)
6333 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6335 LOGD("ret : 0x%x", ret);
6341 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6343 int ret = CAMERA_ERROR_NONE;
6344 camera_cli_s *pc = (camera_cli_s *)camera;
6345 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6347 if (!pc || !pc->cb_info || !min || !max) {
6348 LOGE("NULL pointer %p %p %p", pc, min, max);
6349 return CAMERA_ERROR_INVALID_PARAMETER;
6354 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6356 if (ret == CAMERA_ERROR_NONE) {
6357 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6358 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6361 LOGD("ret : 0x%x", ret);
6367 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6369 int ret = CAMERA_ERROR_NONE;
6370 camera_cli_s *pc = (camera_cli_s *)camera;
6371 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6372 camera_msg_param param;
6373 int set_move_type = (int)move_type;
6376 if (!pc || !pc->cb_info) {
6377 LOGE("NULL handle");
6378 return CAMERA_ERROR_INVALID_PARAMETER;
6383 value = (set_move_type << 16) | tilt_step;
6384 CAMERA_MSG_PARAM_SET(param, INT, value);
6386 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6388 LOGD("ret : 0x%x", ret);
6394 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6396 int ret = CAMERA_ERROR_NONE;
6397 camera_cli_s *pc = (camera_cli_s *)camera;
6398 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6400 if (!pc || !pc->cb_info || !tilt_step) {
6401 LOGE("NULL pointer %p %p", pc, tilt_step);
6402 return CAMERA_ERROR_INVALID_PARAMETER;
6407 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6409 if (ret == CAMERA_ERROR_NONE)
6410 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6412 LOGD("ret : 0x%x", ret);
6418 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6420 int ret = CAMERA_ERROR_NONE;
6421 camera_cli_s *pc = (camera_cli_s *)camera;
6422 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6424 if (!pc || !pc->cb_info || !min || !max) {
6425 LOGE("NULL pointer %p %p %p", pc, min, max);
6426 return CAMERA_ERROR_INVALID_PARAMETER;
6431 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6433 if (ret == CAMERA_ERROR_NONE) {
6434 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6435 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6438 LOGD("ret : 0x%x", ret);
6444 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6446 int ret = CAMERA_ERROR_NONE;
6447 camera_cli_s *pc = (camera_cli_s *)camera;
6448 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6449 camera_msg_param param;
6450 int set_ptz_type = (int)ptz_type;
6452 if (!pc || !pc->cb_info) {
6453 LOGE("NULL handle");
6454 return CAMERA_ERROR_INVALID_PARAMETER;
6459 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6461 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6463 LOGD("ret : 0x%x", ret);
6469 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6471 int ret = CAMERA_ERROR_NONE;
6472 camera_cli_s *pc = (camera_cli_s *)camera;
6473 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6475 if (!pc || !pc->cb_info || !foreach_cb) {
6476 LOGE("NULL pointer %p %p", pc, foreach_cb);
6477 return CAMERA_ERROR_INVALID_PARAMETER;
6482 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6483 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6485 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6487 LOGD("ret : 0x%x", ret);
6493 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6495 int ret = CAMERA_ERROR_NONE;
6496 camera_cli_s *pc = (camera_cli_s *)camera;
6497 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6498 int set_display_roi_area[4] = {x, y, width, height};
6503 if (!pc || !pc->cb_info) {
6504 LOGE("NULL handle");
6505 return CAMERA_ERROR_INVALID_PARAMETER;
6510 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6511 ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
6512 if (ret != MM_ERROR_NONE) {
6513 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6514 return CAMERA_ERROR_INVALID_OPERATION;
6518 length = sizeof(set_display_roi_area) / sizeof(int) + \
6519 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6521 msg = muse_core_msg_new(api,
6522 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6525 LOGE("msg creation failed: api %d", api);
6526 return CAMERA_ERROR_OUT_OF_MEMORY;
6529 if (pc->cb_info->is_server_connected) {
6530 __camera_update_api_waiting(pc->cb_info, api, 1);
6532 g_mutex_lock(&pc->cb_info->fd_lock);
6533 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
6534 g_mutex_unlock(&pc->cb_info->fd_lock);
6538 LOGE("message send failed");
6539 ret = CAMERA_ERROR_INVALID_OPERATION;
6541 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6544 __camera_update_api_waiting(pc->cb_info, api, -1);
6546 muse_core_msg_free(msg);
6548 LOGD("ret : 0x%x", ret);
6554 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6556 camera_cli_s *pc = (camera_cli_s *)camera;
6557 int ret = CAMERA_ERROR_NONE;
6558 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6560 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6561 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6562 return CAMERA_ERROR_INVALID_PARAMETER;
6567 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6569 if (ret == CAMERA_ERROR_NONE) {
6570 *x = pc->cb_info->get_display_roi_area[0];
6571 *y = pc->cb_info->get_display_roi_area[1];
6572 *width = pc->cb_info->get_display_roi_area[2];
6573 *height = pc->cb_info->get_display_roi_area[3];
6576 LOGD("ret : 0x%x", ret);
6582 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6584 int ret = CAMERA_ERROR_NONE;
6585 int get_device_state = 0;
6588 LOGE("NULL pointer");
6589 return CAMERA_ERROR_INVALID_PARAMETER;
6592 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6593 (int)device, "get_device_state", &get_device_state);
6595 if (ret == CAMERA_ERROR_NONE) {
6596 *state = (camera_device_state_e)get_device_state;
6597 LOGD("device state %d", *state);
6599 LOGE("failed 0x%x", ret);
6606 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6608 int ret = CAMERA_ERROR_NONE;
6609 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6610 camera_cb_info *info = NULL;
6612 if (!callback || !cb_id) {
6613 LOGE("invalid pointer %p %p", callback, cb_id);
6614 return CAMERA_ERROR_INVALID_PARAMETER;
6617 /* check camera support */
6618 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6619 if (ret != CAMERA_ERROR_NONE) {
6620 LOGE("get device state failed");
6624 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6626 info = g_new0(camera_cb_info, 1);
6628 LOGE("info failed");
6629 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6633 info->id = ++g_cam_dev_state_changed_cb_id;
6634 info->callback = (void *)callback;
6635 info->user_data = user_data;
6639 /* subscribe dbus signal for camera state change */
6640 if (!g_cam_dev_state_changed_cb_conn) {
6641 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6642 if (!g_cam_dev_state_changed_cb_conn) {
6643 LOGE("failed to get gdbus connection");
6644 ret = CAMERA_ERROR_INVALID_OPERATION;
6648 LOGD("subscribe signal %s - %s - %s",
6649 MM_CAMCORDER_DBUS_OBJECT,
6650 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6651 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6653 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6654 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6655 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6656 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6657 LOGE("failed to get gdbus connection");
6658 ret = CAMERA_ERROR_INVALID_OPERATION;
6662 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6665 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6667 LOGD("callback id %d", info->id);
6670 if (ret != CAMERA_ERROR_NONE) {
6676 if (g_cam_dev_state_changed_cb_conn) {
6677 g_object_unref(g_cam_dev_state_changed_cb_conn);
6678 g_cam_dev_state_changed_cb_conn = NULL;
6682 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6688 int camera_remove_device_state_changed_cb(int cb_id)
6690 int ret = CAMERA_ERROR_NONE;
6691 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6692 GList *tmp_list = NULL;
6693 camera_cb_info *info = NULL;
6695 /* check camera support */
6696 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6697 if (ret != CAMERA_ERROR_NONE) {
6698 LOGE("get device state failed");
6702 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6704 if (!g_cam_dev_state_changed_cb_list) {
6705 LOGE("there is no callback info");
6706 ret = CAMERA_ERROR_INVALID_OPERATION;
6710 tmp_list = g_cam_dev_state_changed_cb_list;
6713 info = tmp_list->data;
6714 tmp_list = tmp_list->next;
6721 if (info->id == cb_id) {
6722 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6727 if (!g_cam_dev_state_changed_cb_list) {
6728 /* no remained callback */
6729 if (g_cam_dev_state_changed_cb_conn) {
6730 /* unsubscribe signal */
6731 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6732 g_cam_dev_state_changed_cb_subscribe_id = 0;
6734 /* unref connection */
6735 g_object_unref(g_cam_dev_state_changed_cb_conn);
6736 g_cam_dev_state_changed_cb_conn = NULL;
6740 LOGD("id %d callback removed", cb_id);
6741 ret = CAMERA_ERROR_NONE;
6747 LOGE("id %d callback not found", cb_id);
6748 ret = CAMERA_ERROR_INVALID_PARAMETER;
6751 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);