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;
44 static GMutex g_cam_idle_event_lock;
46 static void _camera_msg_send(int api, camera_cb_info_s *cb_info,
47 int *ret, int timeout);
48 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
49 int *ret, camera_msg_param *param, int timeout);
50 static void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
51 int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout);
52 static int _camera_import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle);
53 static void _camera_release_imported_bo(tbm_bo *bo);
54 static void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_key,
55 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame);
56 static int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
57 camera_media_packet_data *mp_data, media_packet_h *packet);
58 static int _camera_media_packet_data_create(int tbm_key, int num_buffer_key, tbm_bo bo,
59 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data);
60 static void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info);
63 static void __camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value)
66 api < 0 || api >= MUSE_CAMERA_API_MAX) {
67 LOGE("invalid param %p %d", cb_info, api);
71 g_mutex_lock(&(cb_info->api_mutex[api]));
72 cb_info->api_waiting[api] += value;
73 g_mutex_unlock(&(cb_info->api_mutex[api]));
75 /*LOGD("api %d, value %d, waiting %d",
76 api, value, cb_info->api_waiting[api]);*/
82 static void __camera_device_state_changed_cb(GDBusConnection *connection,
83 const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
84 const gchar *signal_name, GVariant *param, gpointer user_data)
87 camera_device_e device = CAMERA_DEVICE_CAMERA0;
88 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
89 GList *tmp_list = NULL;
90 camera_cb_info *info = NULL;
92 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
94 if (!g_cam_dev_state_changed_cb_list || !param) {
95 LOGW("no callback or NULL param %p", param);
99 /* get device and state */
100 g_variant_get(param, "(i)", &value);
102 device = value >> 16;
103 state = 0x0000ffff & value;
105 LOGD("device %d, state %d", device, state);
107 tmp_list = g_cam_dev_state_changed_cb_list;
110 info = (camera_cb_info *)tmp_list->data;
113 if (info->callback) {
114 LOGD("start id[%d] callback", info->id);
115 ((camera_device_state_changed_cb)info->callback)(device, state, info->user_data);
116 LOGD("returned id[%d] callback", info->id);
118 LOGW("NULL callback for id %d", info->id);
122 tmp_list = tmp_list->next;
126 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
132 static void __camera_event_handler_preview(camera_cb_info_s *cb_info, char *recv_msg)
136 int num_buffer_key = 0;
137 int buffer_key[BUFFER_MAX_PLANE_NUM] = {0, };
140 unsigned char *buf_pos = NULL;
141 camera_msg_param param;
144 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
145 tbm_bo_handle bo_handle = {.ptr = NULL};
146 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
147 tbm_bo data_bo = NULL;
148 tbm_bo_handle data_bo_handle = {.ptr = NULL};
150 camera_preview_data_s frame;
151 camera_stream_data_s *stream = NULL;
152 camera_media_packet_data *mp_data = NULL;
153 media_packet_h pkt = NULL;
154 media_packet_h pkt_evas = NULL;
156 if (!cb_info || !recv_msg) {
157 LOGE("invalid param %p %p", cb_info, recv_msg);
161 muse_camera_msg_get(tbm_key, recv_msg);
162 muse_camera_msg_get(num_buffer_key, recv_msg);
163 muse_camera_msg_get_array(buffer_key, recv_msg);
164 muse_camera_msg_get(data_key, recv_msg);
166 memset(&frame, 0x0, sizeof(camera_preview_data_s));
169 LOGE("invalid key %d", tbm_key);
173 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
175 if (num_buffer_key < 0 || num_buffer_key > BUFFER_MAX_PLANE_NUM) {
176 LOGE("invalid num buffer key %d", num_buffer_key);
177 goto _PREVIEW_CB_HANDLER_DONE;
181 /* import tbm data_bo and get virtual address */
182 if (!_camera_import_tbm_key(cb_info->bufmgr, data_key, &data_bo, &data_bo_handle)) {
183 LOGE("failed to import data key %d", data_key);
184 goto _PREVIEW_CB_HANDLER_DONE;
188 /* import tbm bo and get virtual address */
189 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
190 LOGE("failed to import key %d", tbm_key);
191 goto _PREVIEW_CB_HANDLER_DONE;
194 buf_pos = (unsigned char *)bo_handle.ptr;
196 /* get stream info */
197 stream = (camera_stream_data_s *)buf_pos;
199 for (i = 0 ; i < num_buffer_key ; i++) {
200 /* import buffer bo and get virtual address */
201 if (!_camera_import_tbm_key(cb_info->bufmgr, buffer_key[i], &buffer_bo[i], &buffer_bo_handle[i])) {
202 LOGE("failed to import buffer key %d", buffer_key[i]);
203 goto _PREVIEW_CB_HANDLER_DONE;
207 /* call preview callback */
208 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
209 _camera_preview_frame_create(stream, num_buffer_key, buffer_bo_handle, &data_bo_handle, &frame);
211 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
212 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
215 if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
216 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
218 if (ret == CAMERA_ERROR_NONE) {
219 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt_evas);
220 if (ret != CAMERA_ERROR_NONE) {
221 LOGE("create pkt for evas failed");
222 _camera_media_packet_data_release(mp_data, cb_info);
228 /* call media packet callback */
229 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
230 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
232 if (ret == CAMERA_ERROR_NONE) {
233 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt);
235 if (ret == CAMERA_ERROR_NONE) {
236 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
237 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
239 _camera_media_packet_data_release(mp_data, cb_info);
245 /* call evas renderer */
247 if (cb_info->run_evas_render) {
248 mm_display_interface_evas_render(cb_info->dp_interface, pkt_evas);
250 LOGW("evas renderer is stopped, skip this buffer...");
251 media_packet_destroy(pkt_evas);
256 /* send message for preview callback return */
257 if (!CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS))
258 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info, NULL, 0);
260 _PREVIEW_CB_HANDLER_DONE:
261 if (mp_data == NULL) {
262 /* release imported bo */
263 for (i = 0 ; i < num_buffer_key && i < BUFFER_MAX_PLANE_NUM ; i++)
264 _camera_release_imported_bo(&buffer_bo[i]);
266 /* unmap and unref tbm bo */
267 _camera_release_imported_bo(&data_bo);
268 _camera_release_imported_bo(&bo);
271 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
273 /*LOGD("return buffer Done");*/
280 static void __camera_event_handler_capture(camera_cb_info_s *cb_info, char *recv_msg)
283 int tbm_key_main = 0;
284 int tbm_key_post = 0;
285 int tbm_key_thumb = 0;
286 unsigned char *buf_pos = NULL;
288 camera_msg_param param;
289 camera_image_data_s *rImage = NULL;
290 camera_image_data_s *rPostview = NULL;
291 camera_image_data_s *rThumbnail = NULL;
293 tbm_bo bo_main = NULL;
294 tbm_bo bo_post = NULL;
295 tbm_bo bo_thumb = NULL;
296 tbm_bo_handle bo_main_handle = {.ptr = NULL};
297 tbm_bo_handle bo_post_handle = {.ptr = NULL};
298 tbm_bo_handle bo_thumb_handle = {.ptr = NULL};
300 if (!cb_info || !recv_msg) {
301 LOGE("invalid param %p %p", cb_info, recv_msg);
305 muse_camera_msg_get(tbm_key_main, recv_msg);
306 muse_camera_msg_get(tbm_key_post, recv_msg);
307 muse_camera_msg_get(tbm_key_thumb, recv_msg);
310 LOGD("camera capture callback came in. tbm_key_main %d, tbm_key_post %d, tbm_key_thumb %d",
311 tbm_key_main, tbm_key_post, tbm_key_thumb);
314 if (tbm_key_main <= 0) {
315 LOGE("invalid key %d", tbm_key_main);
316 goto _CAPTURE_CB_HANDLER_DONE;
319 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] == NULL) {
320 LOGW("NULL callback");
321 goto _CAPTURE_CB_HANDLER_DONE;
324 /* import tbm bo and get virtual address */
325 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_main, &bo_main, &bo_main_handle)) {
326 LOGE("failed to import key [%d] for main", tbm_key_main);
327 goto _CAPTURE_CB_HANDLER_DONE;
330 buf_pos = (unsigned char *)bo_main_handle.ptr;
331 rImage = (camera_image_data_s *)buf_pos;
332 rImage->data = buf_pos + sizeof(camera_image_data_s);
333 if (rImage->exif && rImage->exif_size > 0) {
334 rImage->exif = rImage->data + rImage->size;
337 rImage->exif_size = 0;
340 LOGD("image info %dx%d, size %d, EXIF info %p, size %d",
341 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
343 if (tbm_key_post > 0) {
344 /* import tbm bo and get virtual address */
345 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key_post, &bo_post, &bo_post_handle)) {
346 buf_pos = (unsigned char *)bo_post_handle.ptr;
347 rPostview = (camera_image_data_s *)buf_pos;
348 LOGD("rPostview->size : %d", rPostview->size);
349 rPostview->data = buf_pos + sizeof(camera_image_data_s);
351 LOGE("failed to import key [%d] for postview", tbm_key_post);
355 if (tbm_key_thumb > 0) {
356 /* import tbm bo and get virtual address */
357 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key_thumb, &bo_thumb, &bo_thumb_handle)) {
358 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
359 rThumbnail = (camera_image_data_s *)buf_pos;
360 LOGD("rThumbnail->size : %d", rThumbnail->size);
361 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
363 LOGE("failed to import key [%d] for thumbnail", tbm_key_thumb);
367 ((camera_capturing_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE])(rImage,
368 rPostview, rThumbnail, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE]);
370 _CAPTURE_CB_HANDLER_DONE:
372 if (tbm_key_main > 0) {
373 _camera_release_imported_bo(&bo_main);
375 tbm_key = tbm_key_main;
376 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
378 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
381 if (tbm_key_post > 0) {
382 _camera_release_imported_bo(&bo_post);
384 tbm_key = tbm_key_post;
385 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
387 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
390 if (tbm_key_thumb > 0) {
391 _camera_release_imported_bo(&bo_thumb);
393 tbm_key = tbm_key_thumb;
394 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
396 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
399 LOGD("return buffer done");
405 static void __camera_event_handler_face_detection(camera_cb_info_s *cb_info, char *recv_msg)
409 camera_detected_face_s *faces = NULL;
410 camera_msg_param param;
413 tbm_bo_handle bo_handle = {.ptr = NULL};
415 if (!cb_info || !recv_msg) {
416 LOGE("invalid param %p %p", cb_info, recv_msg);
420 muse_camera_msg_get(count, recv_msg);
421 muse_camera_msg_get(tbm_key, recv_msg);
423 if (count >= 0 && cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]) {
424 LOGD("FACE_DETECTION - count %d, tbm_key %d", count, tbm_key);
428 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
430 faces = bo_handle.ptr;
434 ((camera_face_detected_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION])(faces,
435 count, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
438 _camera_release_imported_bo(&bo);
440 LOGW("skip face detection message [count %d, key %d, cb %p",
441 count, tbm_key, cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
446 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
447 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
448 /*LOGD("return buffer done");*/
455 static int _camera_import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle)
457 tbm_bo tmp_bo = NULL;
458 tbm_bo_handle tmp_bo_handle = {NULL, };
460 if (!bufmgr || !bo || !bo_handle || !tbm_key) {
461 LOGE("invalid parameter - %p %p %p, key %d",
462 bufmgr, bo, bo_handle, tbm_key);
466 tmp_bo = tbm_bo_import(bufmgr, tbm_key);
467 if (tmp_bo == NULL) {
468 LOGE("import failed - key %d", tbm_key);
472 tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
473 if (tmp_bo_handle.ptr == NULL) {
474 LOGE("map failed %p", tmp_bo);
475 tbm_bo_unref(tmp_bo);
480 tbm_bo_unmap(tmp_bo);
482 /* set bo and bo_handle */
484 *bo_handle = tmp_bo_handle;
489 static void _camera_release_imported_bo(tbm_bo *bo)
502 static int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
504 int ret = CAMERA_ERROR_NONE;
507 /*LOGD("Enter api : %d", api);*/
509 if (!cb_info->is_server_connected) {
510 LOGE("server is disconnected");
511 return CAMERA_ERROR_SERVICE_DISCONNECTED;
514 g_mutex_lock(&(cb_info->api_mutex[api]));
516 if (cb_info->api_activating[api] == 0) {
517 if (time_out == CAMERA_CB_NO_TIMEOUT) {
518 LOGW("wait for api %d", api);
519 g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
520 ret = cb_info->api_ret[api];
521 cb_info->api_activating[api] = 0;
522 LOGW("api %d returned 0x%x", api, ret);
524 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
525 if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
526 ret = cb_info->api_ret[api];
527 cb_info->api_activating[api] = 0;
528 /*LOGD("return value : 0x%x", ret);*/
530 ret = CAMERA_ERROR_INVALID_OPERATION;
531 LOGE("api %d was TIMED OUT!", api);
535 ret = cb_info->api_ret[api];
536 cb_info->api_activating[api] = 0;
538 /*LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);*/
541 g_mutex_unlock(&(cb_info->api_mutex[api]));
543 if (ret != CAMERA_ERROR_NONE)
544 LOGE("api %d : error 0x%x", api, ret);
550 static void _camera_msg_send(int api, camera_cb_info_s *cb_info,
551 int *ret, int timeout)
557 LOGE("NULL info - api %d", api);
560 *ret = CAMERA_ERROR_INVALID_PARAMETER;
565 msg = muse_core_msg_new(api, NULL);
567 LOGE("msg failed: api %d", api);
570 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
575 /*LOGD("send msg %s", msg);*/
577 if (cb_info->is_server_connected) {
578 __camera_update_api_waiting(cb_info, api, 1);
580 g_mutex_lock(&cb_info->fd_lock);
581 send_ret = muse_core_msg_send(cb_info->fd, msg);
582 g_mutex_unlock(&cb_info->fd_lock);
586 LOGE("msg send failed");
588 *ret = CAMERA_ERROR_INVALID_OPERATION;
591 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
594 __camera_update_api_waiting(cb_info, api, -1);
596 muse_core_msg_free(msg);
602 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
603 int *ret, camera_msg_param *param, int timeout)
608 if (!cb_info || !param) {
609 LOGE("invalid pointer : api %d - %p %p", api, cb_info, param);
612 *ret = CAMERA_ERROR_INVALID_PARAMETER;
617 /*LOGD("type %d, name %s", param->type, param->name);*/
619 switch (param->type) {
621 msg = muse_core_msg_new(api,
622 param->type, param->name, param->value.value_INT,
625 case MUSE_TYPE_STRING:
626 msg = muse_core_msg_new(api,
627 param->type, param->name, param->value.value_STRING,
631 LOGE("unknown type %d", param->type);
636 LOGE("msg failed: api %d", api);
639 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
644 /*LOGD("send msg %s", msg);*/
646 if (cb_info->is_server_connected) {
647 __camera_update_api_waiting(cb_info, api, 1);
649 g_mutex_lock(&cb_info->fd_lock);
650 send_ret = muse_core_msg_send(cb_info->fd, msg);
651 g_mutex_unlock(&cb_info->fd_lock);
655 LOGE("msg send failed");
658 *ret = CAMERA_ERROR_INVALID_OPERATION;
661 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
664 __camera_update_api_waiting(cb_info, api, -1);
666 muse_core_msg_free(msg);
672 static void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
673 int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout)
675 int func_ret = CAMERA_ERROR_NONE;
679 if (!cb_info || !param0 || !param1) {
680 LOGE("invalid ptr %p %p %p : api %d",
681 cb_info, param0, param1, api);
682 func_ret = CAMERA_ERROR_INVALID_PARAMETER;
683 goto _SEND_PARAM2_INT_DONE;
686 /*LOGD("api %d, param0 [%s:%d], param1 [%s:%d]",
688 param0->name, param0->value.value_INT,
689 param1->name, param1->value.value_INT);*/
691 msg = muse_core_msg_new(api,
692 param0->type, param0->name, param0->value.value_INT,
693 param1->type, param1->name, param1->value.value_INT,
696 LOGE("msg failed: api %d", api);
697 func_ret = CAMERA_ERROR_OUT_OF_MEMORY;
698 goto _SEND_PARAM2_INT_DONE;
701 /*LOGD("send msg [%s]", msg);*/
703 if (cb_info->is_server_connected) {
704 __camera_update_api_waiting(cb_info, api, 1);
706 g_mutex_lock(&cb_info->fd_lock);
707 send_ret = muse_core_msg_send(cb_info->fd, msg);
708 g_mutex_unlock(&cb_info->fd_lock);
712 LOGE("msg send failed");
714 func_ret = CAMERA_ERROR_INVALID_OPERATION;
716 func_ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
719 __camera_update_api_waiting(cb_info, api, -1);
721 muse_core_msg_free(msg);
723 _SEND_PARAM2_INT_DONE:
731 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
733 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
734 in_format >= MM_PIXEL_FORMAT_NUM ||
735 out_format == NULL) {
736 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
737 return CAMERA_ERROR_INVALID_PARAMETER;
741 case MM_PIXEL_FORMAT_NV12:
742 case MM_PIXEL_FORMAT_NV12T:
743 *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;
784 return CAMERA_ERROR_NONE;
788 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
790 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
791 in_format >= MM_PIXEL_FORMAT_NUM ||
793 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
794 return CAMERA_ERROR_INVALID_PARAMETER;
798 case MM_PIXEL_FORMAT_NV12:
799 case MM_PIXEL_FORMAT_NV12T:
800 *mimetype = MEDIA_FORMAT_NV12;
802 case MM_PIXEL_FORMAT_NV16:
803 *mimetype = MEDIA_FORMAT_NV16;
805 case MM_PIXEL_FORMAT_NV21:
806 *mimetype = MEDIA_FORMAT_NV21;
808 case MM_PIXEL_FORMAT_YUYV:
809 *mimetype = MEDIA_FORMAT_YUYV;
811 case MM_PIXEL_FORMAT_UYVY:
812 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
813 *mimetype = MEDIA_FORMAT_UYVY;
815 case MM_PIXEL_FORMAT_422P:
816 *mimetype = MEDIA_FORMAT_422P;
818 case MM_PIXEL_FORMAT_I420:
819 *mimetype = MEDIA_FORMAT_I420;
821 case MM_PIXEL_FORMAT_YV12:
822 *mimetype = MEDIA_FORMAT_YV12;
824 case MM_PIXEL_FORMAT_RGB565:
825 *mimetype = MEDIA_FORMAT_RGB565;
827 case MM_PIXEL_FORMAT_RGB888:
828 *mimetype = MEDIA_FORMAT_RGB888;
830 case MM_PIXEL_FORMAT_RGBA:
831 *mimetype = MEDIA_FORMAT_RGBA;
833 case MM_PIXEL_FORMAT_ARGB:
834 *mimetype = MEDIA_FORMAT_ARGB;
837 LOGE("invalid in_format %d", in_format);
838 return CAMERA_ERROR_INVALID_PARAMETER;
841 return CAMERA_ERROR_NONE;
844 static void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_key,
845 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame)
848 unsigned char *buf_pos = NULL;
850 if (stream == NULL || buffer_bo_handle == NULL || frame == NULL) {
851 LOGE("invalid parameter - stream:%p, buffer_bo_handle:%p", stream, buffer_bo_handle);
856 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
857 frame->format = MM_PIXEL_FORMAT_UYVY;
859 frame->format = stream->format;
861 frame->width = stream->width;
862 frame->height = stream->height;
863 frame->timestamp = stream->timestamp;
864 frame->num_of_planes = stream->num_planes;
866 if (num_buffer_key == 0) {
868 if (!data_bo_handle || !data_bo_handle->ptr) {
869 LOGE("NULL pointer");
873 buf_pos = data_bo_handle->ptr;
875 if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) {
876 frame->data.encoded_plane.data = buf_pos;
877 frame->data.encoded_plane.size = stream->data.encoded.length_data;
878 total_size = stream->data.encoded.length_data;
879 } else if (stream->format == MM_PIXEL_FORMAT_INVZ) {
880 frame->data.depth_plane.data = buf_pos;
881 frame->data.depth_plane.size = stream->data.depth.length_data;
882 total_size = stream->data.depth.length_data;
883 } else if (stream->format == MM_PIXEL_FORMAT_RGBA ||
884 stream->format == MM_PIXEL_FORMAT_ARGB) {
885 frame->data.rgb_plane.data = buf_pos;
886 frame->data.rgb_plane.size = stream->data.rgb.length_data;
887 total_size = stream->data.rgb.length_data;
889 switch (stream->num_planes) {
891 frame->data.single_plane.yuv = buf_pos;
892 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
893 total_size = stream->data.yuv420.length_yuv;
896 frame->data.double_plane.y = buf_pos;
897 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
898 buf_pos += stream->data.yuv420sp.length_y;
899 frame->data.double_plane.uv = buf_pos;
900 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
901 total_size = stream->data.yuv420sp.length_y + \
902 stream->data.yuv420sp.length_uv;
905 frame->data.triple_plane.y = buf_pos;
906 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
907 buf_pos += stream->data.yuv420p.length_y;
908 frame->data.triple_plane.u = buf_pos;
909 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
910 buf_pos += stream->data.yuv420p.length_u;
911 frame->data.triple_plane.v = buf_pos;
912 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
913 total_size = stream->data.yuv420p.length_y + \
914 stream->data.yuv420p.length_u + \
915 stream->data.yuv420p.length_v;
923 switch (stream->num_planes) {
925 frame->data.single_plane.yuv = buffer_bo_handle[0].ptr;
926 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
927 total_size = stream->data.yuv420.length_yuv;
930 frame->data.double_plane.y = buffer_bo_handle[0].ptr;
931 if (stream->num_planes == (unsigned int)num_buffer_key)
932 frame->data.double_plane.uv = buffer_bo_handle[1].ptr;
934 frame->data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
935 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
936 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
937 total_size = stream->data.yuv420sp.length_y + \
938 stream->data.yuv420sp.length_uv;
941 frame->data.triple_plane.y = buffer_bo_handle[0].ptr;
942 if (stream->num_planes == (unsigned int)num_buffer_key) {
943 frame->data.triple_plane.u = buffer_bo_handle[1].ptr;
944 frame->data.triple_plane.v = buffer_bo_handle[2].ptr;
946 frame->data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y;
947 frame->data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u;
949 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
950 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
951 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
952 total_size = stream->data.yuv420p.length_y + \
953 stream->data.yuv420p.length_u + \
954 stream->data.yuv420p.length_v;
962 LOGD("format %d, %dx%d, size %d plane num %d",
963 frame.format, frame.width, frame.height, total_size, frame.num_of_planes);
969 static int _camera_media_packet_data_create(int tbm_key, int num_buffer_key, tbm_bo bo,
970 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
973 int ret = CAMERA_ERROR_NONE;
974 camera_media_packet_data *tmp_mp_data = NULL;
976 if (*mp_data == NULL) {
977 tmp_mp_data = g_new0(camera_media_packet_data, 1);
979 tmp_mp_data->tbm_key = tbm_key;
980 tmp_mp_data->num_buffer_key = num_buffer_key;
981 tmp_mp_data->bo = bo;
982 tmp_mp_data->data_bo = data_bo;
983 tmp_mp_data->ref_cnt++;
985 for (i = 0 ; i < num_buffer_key ; i++)
986 tmp_mp_data->buffer_bo[i] = buffer_bo[i];
988 *mp_data = tmp_mp_data;
989 /*LOGD("mp_data %p", tmp_mp_data);*/
991 ret = CAMERA_ERROR_OUT_OF_MEMORY;
992 LOGE("failed to alloc media packet data");
995 ((camera_media_packet_data *)*mp_data)->ref_cnt++;
1001 static void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
1005 camera_msg_param param;
1007 if (!mp_data || !cb_info) {
1008 LOGE("NULL pointer %p %p", mp_data, cb_info);
1012 if (mp_data->ref_cnt > 1) {
1014 LOGD("ref count %d", mp_data->ref_cnt);
1016 /* release imported bo */
1017 for (i = 0 ; i < mp_data->num_buffer_key ; i++) {
1018 tbm_bo_unref(mp_data->buffer_bo[i]);
1019 mp_data->buffer_bo[i] = NULL;
1023 _camera_release_imported_bo(&mp_data->bo);
1024 _camera_release_imported_bo(&mp_data->data_bo);
1027 tbm_key = mp_data->tbm_key;
1029 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1031 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1040 static int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
1041 camera_media_packet_data *mp_data, media_packet_h *packet)
1043 media_packet_h pkt = NULL;
1044 bool make_pkt_fmt = false;
1045 tbm_surface_h tsurf = NULL;
1046 tbm_surface_info_s tsurf_info;
1047 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
1048 uint32_t bo_format = 0;
1051 int num_buffer_key = 0;
1052 tbm_bo *buffer_bo = NULL;
1054 if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) {
1055 LOGE("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p",
1056 cb_info, stream, mp_data, packet);
1057 return CAMERA_ERROR_INVALID_PARAMETER;
1060 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
1061 buffer_bo = mp_data->buffer_bo;
1062 num_buffer_key = mp_data->num_buffer_key;
1064 /* create tbm surface */
1065 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
1066 tsurf_info.planes[i].stride = stream->stride[i];
1068 /* get tbm surface format */
1069 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
1070 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
1072 if (ret == CAMERA_ERROR_NONE) {
1073 tsurf_info.width = stream->width;
1074 tsurf_info.height = stream->height;
1075 tsurf_info.format = bo_format;
1076 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
1077 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
1079 if (num_buffer_key > 0) {
1080 switch (bo_format) {
1081 case TBM_FORMAT_NV12:
1082 case TBM_FORMAT_NV21:
1083 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1084 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1085 tsurf_info.planes[0].offset = 0;
1086 if (num_buffer_key == 1)
1087 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1088 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1090 case TBM_FORMAT_YUV420:
1091 case TBM_FORMAT_YVU420:
1092 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1093 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1094 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
1095 tsurf_info.planes[0].offset = 0;
1096 if (num_buffer_key == 1) {
1097 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1098 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1100 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1102 case TBM_FORMAT_UYVY:
1103 case TBM_FORMAT_YUYV:
1104 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
1105 tsurf_info.planes[0].offset = 0;
1106 tsurf_info.size = tsurf_info.planes[0].size;
1112 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_key);
1113 } else if (mp_data->data_bo) {
1114 switch (bo_format) {
1115 case TBM_FORMAT_NV12:
1116 case TBM_FORMAT_NV21:
1117 tsurf_info.planes[0].size = stream->width * stream->height;
1118 tsurf_info.planes[1].size = (tsurf_info.planes[0].size) >> 1;
1119 tsurf_info.planes[0].offset = 0;
1120 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1121 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1123 case TBM_FORMAT_YUV420:
1124 case TBM_FORMAT_YVU420:
1125 tsurf_info.planes[0].size = stream->width * stream->height;
1126 tsurf_info.planes[1].size = (stream->width >> 1) * (stream->height >> 1);
1127 tsurf_info.planes[2].size = tsurf_info.planes[1].size;
1128 tsurf_info.planes[0].offset = 0;
1129 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1130 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1131 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1133 case TBM_FORMAT_UYVY:
1134 case TBM_FORMAT_YUYV:
1135 tsurf_info.planes[0].size = (stream->width * stream->height) << 1;
1136 tsurf_info.planes[0].offset = 0;
1137 tsurf_info.size = tsurf_info.planes[0].size;
1143 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1);
1145 /*LOGD("tbm surface %p", tsurf);*/
1149 /* check media packet format */
1150 if (cb_info->pkt_fmt) {
1151 int pkt_fmt_width = 0;
1152 int pkt_fmt_height = 0;
1153 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
1155 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
1156 if (pkt_fmt_mimetype != mimetype ||
1157 pkt_fmt_width != stream->width ||
1158 pkt_fmt_height != stream->height) {
1159 LOGW("change fmt: current 0x%x, %dx%d",
1160 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
1161 media_format_unref(cb_info->pkt_fmt);
1162 cb_info->pkt_fmt = NULL;
1163 make_pkt_fmt = true;
1166 make_pkt_fmt = true;
1169 /* create packet format */
1171 LOGW("make new pkt_fmt - 0x%x, %dx%d", mimetype, stream->width, stream->height);
1172 ret = media_format_create(&cb_info->pkt_fmt);
1173 if (ret == MEDIA_FORMAT_ERROR_NONE) {
1174 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
1175 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
1176 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
1177 LOGW("media_format_set : 0x%x", ret);
1179 LOGW("media_format_create failed 0x%x", ret);
1183 /* create media packet */
1184 ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt,
1185 tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
1186 (void *)cb_info, &pkt);
1187 if (ret != MEDIA_PACKET_ERROR_NONE) {
1188 LOGE("media_packet_create failed 0x%x", ret);
1189 tbm_surface_destroy(tsurf);
1193 LOGE("tbm surface failed. %dx%d, format %d, num_buffer_key %d, data_bo %p",
1194 stream->width, stream->height, stream->format, num_buffer_key, mp_data->data_bo);
1198 /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
1199 /* set media packet data */
1200 ret = media_packet_set_extra(pkt, (void *)mp_data);
1201 if (ret != MEDIA_PACKET_ERROR_NONE) {
1202 LOGE("media_packet_set_extra failed");
1204 _camera_media_packet_data_release(mp_data, cb_info);
1207 media_packet_destroy(pkt);
1210 /* set timestamp : msec -> nsec */
1211 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
1212 LOGW("media_packet_set_pts failed");
1221 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
1224 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1225 camera_media_packet_data *mp_data = NULL;
1226 tbm_surface_h tsurf = NULL;
1228 if (!pkt || !cb_info) {
1229 LOGE("NULL pointer %p %p", pkt, cb_info);
1230 return MEDIA_PACKET_FINALIZE;
1233 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1234 if (ret != MEDIA_PACKET_ERROR_NONE) {
1235 LOGE("media_packet_get_extra failed 0x%x", ret);
1236 return MEDIA_PACKET_FINALIZE;
1239 /*LOGD("mp_data %p", mp_data);*/
1241 g_mutex_lock(&cb_info->mp_data_mutex);
1243 _camera_media_packet_data_release(mp_data, cb_info);
1246 g_mutex_unlock(&cb_info->mp_data_mutex);
1248 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1249 if (ret != MEDIA_PACKET_ERROR_NONE)
1250 LOGE("get tbm_surface failed 0x%x", ret);
1253 tbm_surface_destroy(tsurf);
1257 return MEDIA_PACKET_FINALIZE;
1260 static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event)
1265 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1266 LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event);
1270 /*LOGD("get camera msg %s, event %d", recv_msg, event);*/
1272 g_mutex_lock(&cb_info->user_cb_mutex[event]);
1274 if (cb_info->user_cb[event] == NULL) {
1275 if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
1276 event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
1277 event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
1278 event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1279 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1280 LOGW("NULL callback for event %d, return here", event);
1284 /* return buffer message should be sent for some events.
1285 - MUSE_CAMERA_EVENT_TYPE_PREVIEW
1286 - MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW
1287 - MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION
1288 - MUSE_CAMERA_EVENT_TYPE_CAPTURE
1293 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1299 muse_camera_msg_get(previous, recv_msg);
1300 muse_camera_msg_get(current, recv_msg);
1301 muse_camera_msg_get(by_policy, recv_msg);
1303 LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
1304 previous, current, by_policy);
1306 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1307 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1310 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1314 muse_camera_msg_get(state, recv_msg);
1316 LOGD("FOCUS state - %d", state);
1318 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1321 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1322 LOGD("CAPTURE_COMPLETED");
1323 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1325 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1326 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1327 __camera_event_handler_preview(cb_info, recv_msg);
1329 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1333 muse_camera_msg_get(percent, recv_msg);
1335 LOGD("HDR progress - %d %%", percent);
1337 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1340 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1346 muse_camera_msg_get(policy, recv_msg);
1347 muse_camera_msg_get(previous, recv_msg);
1348 muse_camera_msg_get(current, recv_msg);
1350 LOGW("INTERRUPTED - policy %d, state %d -> %d", policy, previous, current);
1352 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1353 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1356 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1361 muse_camera_msg_get(policy, recv_msg);
1362 muse_camera_msg_get(state, recv_msg);
1364 LOGW("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1366 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1367 (camera_state_e)state, cb_info->user_data[event]);
1370 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1371 __camera_event_handler_face_detection(cb_info, recv_msg);
1373 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1376 int current_state = 0;
1378 muse_camera_msg_get(error, recv_msg);
1379 muse_camera_msg_get(current_state, recv_msg);
1381 LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
1383 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1384 (camera_state_e)current_state, cb_info->user_data[event]);
1387 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1389 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1390 muse_camera_msg_get(param1, recv_msg);
1391 muse_camera_msg_get(param2, recv_msg);
1393 /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/
1395 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1396 cb_info->user_cb[event] = NULL;
1397 cb_info->user_data[event] = NULL;
1398 LOGW("stop foreach callback for event %d", event);
1401 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1403 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1405 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1407 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1409 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1411 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1413 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1415 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1417 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1419 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1421 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1423 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1425 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1427 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1429 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1430 muse_camera_msg_get(param1, recv_msg);
1432 /*LOGD("event %d SUPPORTED %d ", event, param1);*/
1434 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1435 cb_info->user_cb[event] = NULL;
1436 cb_info->user_data[event] = NULL;
1437 LOGW("stop foreach callback for event %d", event);
1440 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1441 __camera_event_handler_capture(cb_info, recv_msg);
1444 LOGW("unhandled event %d", event);
1448 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1453 static gboolean _camera_idle_event_callback(gpointer data)
1455 camera_cb_info_s *cb_info = NULL;
1456 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1458 if (cam_idle_event == NULL) {
1459 LOGE("cam_idle_event is NULL");
1464 g_mutex_lock(&g_cam_idle_event_lock);
1466 cb_info = cam_idle_event->cb_info;
1467 if (cb_info == NULL) {
1468 LOGW("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1469 g_mutex_unlock(&g_cam_idle_event_lock);
1470 goto IDLE_EVENT_CALLBACK_DONE;
1473 /* remove event from list */
1474 if (cb_info->idle_event_list)
1475 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1477 g_mutex_unlock(&g_cam_idle_event_lock);
1480 _camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
1482 IDLE_EVENT_CALLBACK_DONE:
1484 g_free(cam_idle_event);
1485 cam_idle_event = NULL;
1490 static void *_camera_msg_handler_func(gpointer data)
1494 camera_message_s *cam_msg = NULL;
1495 camera_idle_event_s *cam_idle_event = NULL;
1496 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1497 camera_cb_info_s *cb_info = NULL;
1499 if (!handler_info || !handler_info->cb_info) {
1500 LOGE("NULL handler %p", handler_info);
1504 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1505 type = handler_info->type;
1507 LOGD("t:%d start", type);
1509 g_mutex_lock(&handler_info->mutex);
1511 while (g_atomic_int_get(&handler_info->running)) {
1512 if (g_queue_is_empty(handler_info->queue)) {
1513 /*LOGD("t:%d signal wait...", type);*/
1514 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1515 /*LOGD("t:%d signal received", type);*/
1517 if (g_atomic_int_get(&handler_info->running) == 0) {
1518 LOGD("t:%d stop event thread", type);
1523 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1525 g_mutex_unlock(&handler_info->mutex);
1527 if (cam_msg == NULL) {
1528 LOGE("t:%d NULL message", type);
1529 g_mutex_lock(&handler_info->mutex);
1535 if (api < MUSE_CAMERA_API_MAX) {
1538 g_mutex_lock(&cb_info->api_mutex[api]);
1540 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1541 if (cb_info->api_waiting[api] > 0) {
1542 cb_info->api_ret[api] = ret;
1543 cb_info->api_activating[api] = 1;
1545 /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
1547 g_cond_signal(&cb_info->api_cond[api]);
1549 LOGW("no waiting for this api [%d]", api);
1552 LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1555 g_mutex_unlock(&cb_info->api_mutex[api]);
1556 } else if (api == MUSE_CAMERA_CB_EVENT) {
1557 switch (cam_msg->event_class) {
1558 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1559 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event);
1561 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1562 cam_idle_event = g_new0(camera_idle_event_s, 1);
1563 if (cam_idle_event == NULL) {
1564 LOGE("t:%d cam_idle_event alloc failed", type);
1568 cam_idle_event->event = cam_msg->event;
1569 cam_idle_event->cb_info = cb_info;
1571 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg) - 1);
1573 /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, cam_msg->event, cam_idle_event);*/
1575 g_mutex_lock(&g_cam_idle_event_lock);
1576 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1577 g_mutex_unlock(&g_cam_idle_event_lock);
1579 g_idle_add_full(G_PRIORITY_DEFAULT,
1580 (GSourceFunc)_camera_idle_event_callback,
1581 (gpointer)cam_idle_event,
1585 LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
1589 LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1595 g_mutex_lock(&handler_info->mutex);
1598 /* remove remained event */
1599 while (!g_queue_is_empty(handler_info->queue)) {
1600 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1602 LOGD("t:%d remove camera message %p", type, cam_msg);
1606 LOGW("t:%d NULL camera message", type);
1610 g_mutex_unlock(&handler_info->mutex);
1612 LOGD("t:%d return", type);
1618 static void _camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1620 camera_idle_event_s *cam_idle_event = NULL;
1623 if (cb_info == NULL) {
1624 LOGE("cb_info is NULL");
1628 g_mutex_lock(&g_cam_idle_event_lock);
1630 if (cb_info->idle_event_list == NULL) {
1631 LOGD("No remained idle event");
1632 g_mutex_unlock(&g_cam_idle_event_lock);
1636 list = cb_info->idle_event_list;
1639 cam_idle_event = list->data;
1640 list = g_list_next(list);
1642 if (!cam_idle_event) {
1643 LOGW("Fail to remove idle event. The event is NULL");
1647 if (g_idle_remove_by_data(cam_idle_event)) {
1648 LOGW("remove idle event %p done", cam_idle_event);
1650 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1652 g_free(cam_idle_event);
1653 cam_idle_event = NULL;
1658 LOGW("set NULL cb_info for event %p %d, it will be freed on idle callback",
1659 cam_idle_event, cam_idle_event->event);
1661 cam_idle_event->cb_info = NULL;
1663 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1666 g_list_free(cb_info->idle_event_list);
1667 cb_info->idle_event_list = NULL;
1669 g_mutex_unlock(&g_cam_idle_event_lock);
1675 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg)
1677 camera_message_s *cam_msg = NULL;
1679 if (!cb_info || !msg) {
1680 LOGE("NULL pointer %p %p", cb_info, msg);
1684 cam_msg = g_new0(camera_message_s, 1);
1686 LOGE("failed to alloc cam_msg for [%s]", msg);
1691 cam_msg->event = event;
1692 cam_msg->event_class = event_class;
1694 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1696 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1698 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1699 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1700 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1701 g_cond_signal(&cb_info->preview_cb_info.cond);
1702 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1703 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1704 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1705 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1706 g_cond_signal(&cb_info->capture_cb_info.cond);
1707 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1709 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1710 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1711 g_cond_signal(&cb_info->msg_handler_info.cond);
1712 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1721 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg)
1723 int ret = CAMERA_ERROR_NONE;
1727 int event_class = -1;
1731 if (!cb_info || !msg) {
1732 LOGE("invalid ptr %p %p", cb_info, msg);
1736 /*LOGD("msg [%s]", msg);*/
1738 if (!muse_camera_msg_get(api, msg)) {
1739 LOGE("failed to get camera api");
1743 if (api == MUSE_CAMERA_CB_EVENT) {
1744 if (!muse_camera_msg_get(event, msg) ||
1745 !muse_camera_msg_get(event_class, msg)) {
1746 LOGE("failed to get camera event or event_class [%s]", msg);
1750 if (!muse_camera_msg_get(api_class, msg)) {
1751 LOGE("failed to get camera api_class [%s]", msg);
1756 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1757 if (api >= MUSE_CAMERA_API_MAX) {
1758 LOGE("invalid api %d", api);
1762 if (!muse_camera_msg_get(ret, msg)) {
1763 LOGE("failed to get camera ret");
1767 g_mutex_lock(&cb_info->api_mutex[api]);
1770 case MUSE_CAMERA_API_CREATE:
1771 if (ret != CAMERA_ERROR_NONE) {
1772 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1773 LOGE("camera create error 0x%x. close client cb handler", ret);
1776 case MUSE_CAMERA_API_DESTROY:
1777 if (ret == CAMERA_ERROR_NONE) {
1778 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1779 LOGD("camera destroy done. close client cb handler");
1783 muse_camera_msg_get(get_type, msg);
1784 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1785 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1786 muse_camera_msg_get(get_index, msg);
1789 case MUSE_CAMERA_GET_TYPE_INT:
1790 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
1792 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1793 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
1794 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
1796 case MUSE_CAMERA_GET_TYPE_ARRAY:
1797 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
1798 muse_core_msg_deserialize("get_value",
1799 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
1800 LOGD("get display roi %d,%d,%dx%d",
1801 cb_info->get_display_roi_area[0],
1802 cb_info->get_display_roi_area[1],
1803 cb_info->get_display_roi_area[2],
1804 cb_info->get_display_roi_area[3]);
1806 muse_core_msg_deserialize("get_value",
1807 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
1808 LOGD("get geotag %lf, %lf, %lf",
1809 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
1812 case MUSE_CAMERA_GET_TYPE_STRING:
1813 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
1816 LOGW("unknown type %d", get_type);
1823 if (cb_info->api_waiting[api] > 0) {
1824 cb_info->api_ret[api] = ret;
1825 cb_info->api_activating[api] = 1;
1827 g_cond_signal(&cb_info->api_cond[api]);
1829 LOGW("no waiting for this api [%d]", api);
1832 g_mutex_unlock(&cb_info->api_mutex[api]);
1833 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
1834 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg);
1836 LOGW("unknown camera api %d, class %d", api, api_class);
1843 static void *_camera_msg_recv_func(gpointer data)
1845 int recv_length = 0;
1846 int single_length = 0;
1847 int remained_length = 0;
1848 char *recv_msg = NULL;
1849 char *single_msg = NULL;
1850 char *remained_msg = NULL;
1854 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
1857 LOGE("cb_info NULL");
1861 LOGD("start - fd : %d", cb_info->fd);
1863 single_msg = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
1865 LOGE("single_msg malloc failed");
1869 recv_msg = cb_info->recv_msg;
1871 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
1872 recv_length = muse_core_msg_recv(cb_info->fd, recv_msg, MUSE_MSG_MAX_LENGTH);
1873 if (recv_length <= 0) {
1874 cb_info->is_server_connected = FALSE;
1875 LOGE("receive msg failed - server disconnected");
1883 /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
1885 /* Need to split the combined entering msgs */
1886 for (cur_pos = 0 ; cur_pos < recv_length ; cur_pos++) {
1887 if (recv_msg[cur_pos] == '}') {
1888 single_length = cur_pos - prev_pos + 1;
1890 if (single_length < MUSE_CAMERA_MSG_MAX_LENGTH) {
1891 /* check remained msg */
1892 if (remained_length > 0) {
1894 strncpy(single_msg, remained_msg, remained_length);
1895 strncpy(single_msg + remained_length, recv_msg + prev_pos, single_length);
1896 single_msg[remained_length + single_length] = '\0';
1899 remained_msg = NULL;
1901 strncpy(single_msg, recv_msg + prev_pos, single_length);
1902 single_msg[single_length] = '\0';
1903 LOGE("lost msg [%s], skip...", single_msg);
1906 remained_length = 0;
1908 strncpy(single_msg, recv_msg + prev_pos, single_length);
1909 single_msg[single_length] = '\0';
1912 if (single_msg[0] == '{') {
1914 /*LOGD("splitted msg : [%s], Index : %d", single_msg, num_msg);*/
1915 /* process each message */
1916 __camera_process_msg(cb_info, single_msg);
1918 LOGE("invalid msg [%s]", single_msg);
1921 LOGE("too long message [len %d] skip...", single_length);
1924 prev_pos = cur_pos + 1;
1928 /* check incompleted message */
1929 if (recv_msg[recv_length - 1] != '}') {
1930 remained_length = recv_length - prev_pos;
1932 LOGW("incompleted message [len %d]", remained_length);
1936 remained_msg = NULL;
1939 remained_msg = (char *)malloc(remained_length + 1);
1941 strncpy(remained_msg, recv_msg + prev_pos, remained_length);
1942 remained_msg[remained_length] = '\0';
1944 LOGE("failed to alloc for remained msg");
1947 remained_length = 0;
1951 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
1953 if (!cb_info->is_server_connected) {
1954 char *error_msg = NULL;
1956 if (cb_info->fd < 0) {
1957 LOGE("fd is closed in client side");
1958 goto CB_HANDLER_EXIT;
1961 /* send error msg for server disconnection */
1962 error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
1963 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
1964 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
1968 LOGE("error_msg failed");
1969 goto CB_HANDLER_EXIT;
1972 __camera_add_msg_to_queue(cb_info,
1973 MUSE_CAMERA_CB_EVENT,
1974 MUSE_CAMERA_EVENT_TYPE_ERROR,
1975 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
1978 muse_core_msg_free(error_msg);
1981 LOGE("add error msg for service disconnection done");
1992 remained_msg = NULL;
1999 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2000 int type, const char *thread_name, camera_cb_info_s *cb_info)
2002 if (!handler_info || !thread_name || !cb_info) {
2003 LOGE("t:%d NULL %p %p %p",
2004 type, handler_info, thread_name, cb_info);
2010 handler_info->type = type;
2011 handler_info->queue = g_queue_new();
2012 if (handler_info->queue == NULL) {
2013 LOGE("t:%d queue failed", type);
2017 g_mutex_init(&handler_info->mutex);
2018 g_cond_init(&handler_info->cond);
2020 handler_info->cb_info = (void *)cb_info;
2021 g_atomic_int_set(&handler_info->running, 1);
2023 handler_info->thread = g_thread_try_new(thread_name,
2024 _camera_msg_handler_func, (gpointer)handler_info, NULL);
2025 if (handler_info->thread == NULL) {
2026 LOGE("t:%d thread failed", type);
2028 g_mutex_clear(&handler_info->mutex);
2029 g_cond_clear(&handler_info->cond);
2030 g_queue_free(handler_info->queue);
2031 handler_info->queue = NULL;
2036 LOGD("t:%d done", type);
2042 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2046 if (!handler_info) {
2047 LOGE("NULL handler");
2051 if (!handler_info->thread) {
2052 LOGW("thread is not created");
2056 type = handler_info->type;
2058 LOGD("t:%d thread %p", type, handler_info->thread);
2060 g_mutex_lock(&handler_info->mutex);
2061 g_atomic_int_set(&handler_info->running, 0);
2062 g_cond_signal(&handler_info->cond);
2063 g_mutex_unlock(&handler_info->mutex);
2065 g_thread_join(handler_info->thread);
2066 handler_info->thread = NULL;
2068 g_mutex_clear(&handler_info->mutex);
2069 g_cond_clear(&handler_info->cond);
2070 g_queue_free(handler_info->queue);
2071 handler_info->queue = NULL;
2073 LOGD("t:%d done", type);
2079 static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
2081 camera_cb_info_s *cb_info = NULL;
2084 g_return_val_if_fail(sockfd > 0, NULL);
2086 cb_info = g_new0(camera_cb_info_s, 1);
2087 if (cb_info == NULL) {
2088 LOGE("cb_info failed");
2092 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2094 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2095 g_mutex_init(&cb_info->api_mutex[i]);
2096 g_cond_init(&cb_info->api_cond[i]);
2099 g_mutex_init(&cb_info->fd_lock);
2100 g_mutex_init(&cb_info->mp_data_mutex);
2102 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2103 g_mutex_init(&cb_info->user_cb_mutex[i]);
2105 /* message handler thread */
2106 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2107 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2108 LOGE("msg_handler_info failed");
2112 /* message handler thread for preview callback */
2113 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2114 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2115 LOGE("preview_cb_info failed");
2119 /* message handler thread for capture callback */
2120 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2121 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2122 LOGE("capture_cb_info failed");
2126 cb_info->fd = sockfd;
2127 cb_info->preview_cb_flag = 0;
2129 /* message receive thread */
2130 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2131 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2132 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2133 if (cb_info->msg_recv_thread == NULL) {
2134 LOGE("message receive thread creation failed");
2138 cb_info->is_server_connected = TRUE;
2144 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2145 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2146 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2148 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2149 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2151 g_mutex_clear(&cb_info->fd_lock);
2152 g_mutex_clear(&cb_info->mp_data_mutex);
2154 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2155 g_mutex_clear(&cb_info->api_mutex[i]);
2156 g_cond_clear(&cb_info->api_cond[i]);
2166 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2170 g_return_if_fail(cb_info != NULL);
2172 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2174 g_thread_join(cb_info->msg_recv_thread);
2175 cb_info->msg_recv_thread = NULL;
2177 LOGD("msg_recv thread removed");
2179 /* destroy msg handler threads */
2180 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2181 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2182 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2184 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2185 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2187 g_mutex_clear(&cb_info->fd_lock);
2188 g_mutex_clear(&cb_info->mp_data_mutex);
2190 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2191 g_mutex_clear(&cb_info->api_mutex[i]);
2192 g_cond_clear(&cb_info->api_cond[i]);
2195 if (cb_info->fd > -1) {
2196 muse_client_close(cb_info->fd);
2200 if (cb_info->bufmgr) {
2201 tbm_bufmgr_deinit(cb_info->bufmgr);
2202 cb_info->bufmgr = NULL;
2204 if (cb_info->pkt_fmt) {
2205 media_format_unref(cb_info->pkt_fmt);
2206 cb_info->pkt_fmt = NULL;
2209 if (cb_info->dp_interface) {
2210 mm_display_interface_deinit(cb_info->dp_interface);
2211 cb_info->dp_interface = NULL;
2214 cb_info->preview_cb_flag = 0;
2223 int _camera_start_evas_rendering(camera_h camera)
2225 camera_cli_s *pc = (camera_cli_s *)camera;
2227 if (!pc || !pc->cb_info) {
2228 LOGE("NULL handle");
2229 return CAMERA_ERROR_INVALID_PARAMETER;
2234 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2235 LOGE("EVAS surface is not set");
2236 return CAMERA_ERROR_NONE;
2239 /* set evas render flag as RUN */
2240 pc->cb_info->run_evas_render = true;
2242 return CAMERA_ERROR_NONE;
2246 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2248 int ret = CAMERA_ERROR_NONE;
2249 camera_cli_s *pc = (camera_cli_s *)camera;
2251 if (!pc || !pc->cb_info) {
2252 LOGE("NULL handle");
2253 return CAMERA_ERROR_INVALID_PARAMETER;
2256 LOGD("stop - keep screen %d", keep_screen);
2258 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2259 LOGE("EVAS surface is not set");
2260 return CAMERA_ERROR_NONE;
2263 /* set evas render flag as STOP and release buffers */
2264 pc->cb_info->run_evas_render = false;
2266 ret = mm_display_interface_evas_flush(pc->cb_info->dp_interface, keep_screen);
2267 if (ret == MM_ERROR_NONE) {
2268 ret = CAMERA_ERROR_NONE;
2270 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2271 ret = CAMERA_ERROR_INVALID_OPERATION;
2278 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2280 int ret = CAMERA_ERROR_NONE;
2283 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2285 /* create muse connection */
2286 if (!key || !value) {
2287 LOGE("NULL pointer");
2288 return CAMERA_ERROR_INVALID_PARAMETER;
2291 sock_fd = muse_client_new();
2293 LOGE("muse_client_new failed");
2294 return CAMERA_ERROR_INVALID_OPERATION;
2297 msg = muse_core_msg_new(api,
2298 MUSE_TYPE_INT, "module", MUSE_CAMERA,
2299 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2303 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2307 ret = muse_core_msg_send(sock_fd, msg);
2309 muse_core_msg_free(msg);
2313 LOGE("send msg failed");
2314 ret = CAMERA_ERROR_INVALID_OPERATION;
2318 ret = muse_core_msg_recv(sock_fd, recv_msg, MUSE_CAMERA_MSG_MAX_LENGTH);
2320 LOGE("recv msg failed %d", errno);
2321 ret = CAMERA_ERROR_INVALID_OPERATION;
2325 if (!muse_camera_msg_get(ret, recv_msg)) {
2326 LOGE("failed to get return value from msg [%s]", recv_msg);
2327 ret = CAMERA_ERROR_INVALID_OPERATION;
2331 if (ret == CAMERA_ERROR_NONE)
2332 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2334 LOGD("api %d - value %d", api, *value);
2338 muse_client_close(sock_fd);
2346 int camera_create(camera_device_e device, camera_h *camera)
2349 char *send_msg = NULL;
2351 int ret = CAMERA_ERROR_NONE;
2353 camera_cli_s *pc = NULL;
2354 tbm_bufmgr bufmgr = NULL;
2356 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2357 muse_core_api_module_e muse_module = MUSE_CAMERA;
2358 int device_type = (int)device;
2361 LOGE("NULL pointer");
2362 return CAMERA_ERROR_INVALID_PARAMETER;
2365 sock_fd = muse_client_new();
2367 LOGE("muse_client_new failed - returned fd %d", sock_fd);
2368 ret = CAMERA_ERROR_INVALID_OPERATION;
2374 send_msg = muse_core_msg_new(api,
2375 MUSE_TYPE_INT, "module", muse_module,
2376 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2377 MUSE_TYPE_INT, "pid", pid,
2382 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2386 send_ret = muse_core_msg_send(sock_fd, send_msg);
2388 muse_core_msg_free(send_msg);
2392 LOGE("send msg failed %d", errno);
2393 ret = CAMERA_ERROR_INVALID_OPERATION;
2397 pc = g_new0(camera_cli_s, 1);
2399 LOGE("camera_cli_s alloc failed");
2400 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2404 bufmgr = tbm_bufmgr_init(-1);
2405 if (bufmgr == NULL) {
2406 LOGE("get tbm bufmgr failed");
2407 ret = CAMERA_ERROR_INVALID_OPERATION;
2411 pc->cb_info = _camera_client_callback_new(sock_fd);
2412 if (pc->cb_info == NULL) {
2413 LOGE("cb_info alloc failed");
2414 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2420 LOGD("cb info : %d", pc->cb_info->fd);
2422 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2424 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2426 if (ret == CAMERA_ERROR_NONE) {
2427 intptr_t handle = 0;
2429 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2431 LOGE("Receiving Handle Failed!!");
2432 ret = CAMERA_ERROR_INVALID_OPERATION;
2436 pc->remote_handle = handle;
2437 pc->cb_info->bufmgr = bufmgr;
2439 ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL);
2440 if (ret != CAMERA_ERROR_NONE) {
2441 LOGE("init display failed 0x%x", ret);
2445 LOGD("camera create 0x%x", pc->remote_handle);
2447 *camera = (camera_h)pc;
2449 /* get display interface handle */
2450 if (mm_display_interface_init(&pc->cb_info->dp_interface) != MM_ERROR_NONE)
2451 LOGW("display interface init failed");
2453 /* get default preview format */
2454 if (camera_get_preview_format(*camera, &pc->cb_info->preview_format) != CAMERA_ERROR_NONE) {
2455 LOGW("get default preview format failed");
2456 pc->cb_info->preview_format = CAMERA_PIXEL_FORMAT_INVALID;
2466 tbm_bufmgr_deinit(bufmgr);
2471 muse_client_close(sock_fd);
2477 int temp_fd = pc->cb_info->fd;
2479 /* pc->cb_info->fd should be closed,
2480 because g_thread_join for msg_recv_thread is not returned
2481 in _camera_client_callback_destroy. */
2483 pc->cb_info->fd = -1;
2484 muse_client_close(temp_fd);
2487 _camera_client_callback_destroy(pc->cb_info);
2494 LOGE("camera create error : 0x%x", ret);
2500 int camera_change_device(camera_h camera, camera_device_e device)
2503 int ret = CAMERA_ERROR_NONE;
2504 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2505 camera_cli_s *pc = (camera_cli_s *)camera;
2506 camera_msg_param param;
2508 if (!pc || !pc->cb_info) {
2509 LOGE("NULL handle");
2510 return CAMERA_ERROR_INVALID_PARAMETER;
2513 CAMERA_MSG_PARAM_SET(param, INT, device);
2515 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2517 if (ret == CAMERA_ERROR_NONE) {
2518 /* reset callback and user data */
2519 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2520 pc->cb_info->user_cb[i] = NULL;
2521 pc->cb_info->user_data[i] = NULL;
2523 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
2530 int camera_destroy(camera_h camera)
2532 int ret = CAMERA_ERROR_NONE;
2533 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2534 camera_cli_s *pc = (camera_cli_s *)camera;
2536 if (!pc || !pc->cb_info) {
2537 LOGE("NULL handle");
2538 return CAMERA_ERROR_INVALID_PARAMETER;
2543 if (pc->cb_info->is_server_connected)
2544 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2546 LOGW("server disconnected. release resource without send message.");
2548 if (ret == CAMERA_ERROR_NONE) {
2549 _camera_deactivate_idle_event_all(pc->cb_info);
2550 _camera_client_callback_destroy(pc->cb_info);
2557 LOGD("ret : 0x%x", ret);
2562 int camera_start_preview(camera_h camera)
2564 int ret = CAMERA_ERROR_NONE;
2565 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2566 camera_cli_s *pc = (camera_cli_s *)camera;
2568 if (!pc || !pc->cb_info) {
2569 LOGE("NULL handle");
2570 return CAMERA_ERROR_INVALID_PARAMETER;
2573 LOGD("Enter : preview format %d, display type %d",
2574 pc->cb_info->preview_format, pc->cb_info->dp_type);
2576 if (pc->cb_info->preview_format == CAMERA_PIXEL_FORMAT_INVZ &&
2577 pc->cb_info->dp_type != CAMERA_DISPLAY_TYPE_NONE) {
2578 LOGE("CAMERA_DISPLAY_TYPE_NONE[current %d] should be set with INVZ format",
2579 pc->cb_info->dp_type);
2580 return CAMERA_ERROR_INVALID_OPERATION;
2583 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2584 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2585 ret = _camera_start_evas_rendering(camera);
2586 if (ret != CAMERA_ERROR_NONE) {
2587 LOGE("stop preview because of error");
2588 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, pc->cb_info, NULL, 0);
2592 LOGD("ret : 0x%x", ret);
2598 int camera_stop_preview(camera_h camera)
2600 int ret = CAMERA_ERROR_NONE;
2601 camera_cli_s *pc = (camera_cli_s *)camera;
2602 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2603 camera_state_e current_state = CAMERA_STATE_NONE;
2605 if (!pc || !pc->cb_info) {
2606 LOGE("NULL handle");
2607 return CAMERA_ERROR_INVALID_PARAMETER;
2612 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2613 ret = camera_get_state(camera, ¤t_state);
2614 if (ret != CAMERA_ERROR_NONE) {
2615 LOGE("failed to get current state 0x%x", ret);
2619 if (current_state == CAMERA_STATE_PREVIEW) {
2620 ret = _camera_stop_evas_rendering(camera, false);
2621 if (ret != CAMERA_ERROR_NONE)
2626 /* send stop preview message */
2627 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2629 if (ret != CAMERA_ERROR_NONE &&
2630 current_state == CAMERA_STATE_PREVIEW) {
2631 LOGW("restart evas rendering");
2632 _camera_start_evas_rendering(camera);
2635 LOGD("ret : 0x%x", ret);
2641 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2643 int ret = CAMERA_ERROR_NONE;
2644 camera_cli_s *pc = (camera_cli_s *)camera;
2645 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2647 if (!pc || !pc->cb_info) {
2648 LOGE("NULL handle");
2649 return CAMERA_ERROR_INVALID_PARAMETER;
2654 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2655 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2657 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2658 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2660 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2662 LOGD("ret : 0x%x", ret);
2668 bool camera_is_supported_continuous_capture(camera_h camera)
2670 int ret = CAMERA_ERROR_NONE;
2671 camera_cli_s *pc = (camera_cli_s *)camera;
2672 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2674 if (!pc || !pc->cb_info) {
2675 LOGE("NULL handle");
2676 return CAMERA_ERROR_INVALID_PARAMETER;
2681 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2684 LOGE("error is occurred 0x%x", ret);
2688 LOGD("ret : %d", ret);
2694 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)
2696 int ret = CAMERA_ERROR_NONE;
2697 camera_cli_s *pc = (camera_cli_s *)camera;
2698 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2699 camera_msg_param param;
2702 if (!pc || !pc->cb_info) {
2703 LOGE("NULL handle");
2704 return CAMERA_ERROR_INVALID_PARAMETER;
2709 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2710 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2712 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2713 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2715 value = (count << 16) | interval;
2716 CAMERA_MSG_PARAM_SET(param, INT, value);
2718 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2720 LOGD("ret : 0x%x", ret);
2726 int camera_stop_continuous_capture(camera_h camera)
2728 int ret = CAMERA_ERROR_NONE;
2729 camera_cli_s *pc = (camera_cli_s *)camera;
2730 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2732 if (!pc || !pc->cb_info) {
2733 LOGE("NULL handle");
2734 return CAMERA_ERROR_INVALID_PARAMETER;
2739 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2741 LOGD("ret : 0x%x", ret);
2747 bool camera_is_supported_face_detection(camera_h camera)
2749 int ret = CAMERA_ERROR_NONE;
2750 camera_cli_s *pc = (camera_cli_s *)camera;
2751 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2753 if (!pc || !pc->cb_info) {
2754 LOGE("NULL handle");
2755 return CAMERA_ERROR_INVALID_PARAMETER;
2760 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2763 LOGE("error is occurred 0x%x", ret);
2767 LOGD("ret : %d", ret);
2773 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2775 int ret = CAMERA_ERROR_NONE;
2776 camera_cli_s *pc = (camera_cli_s *)camera;
2777 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2779 if (!pc || !pc->cb_info) {
2780 LOGE("NULL handle");
2781 return CAMERA_ERROR_INVALID_PARAMETER;
2786 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2789 LOGE("error is occurred 0x%x", ret);
2793 LOGD("ret : %d", ret);
2799 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2801 int ret = CAMERA_ERROR_NONE;
2802 camera_cli_s *pc = (camera_cli_s *)camera;
2803 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2805 if (!pc || !pc->cb_info) {
2806 LOGE("NULL handle");
2807 return CAMERA_ERROR_INVALID_PARAMETER;
2812 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2815 LOGE("error is occurred 0x%x", ret);
2819 LOGD("ret : %d", ret);
2824 int camera_get_device_count(camera_h camera, int *device_count)
2826 int ret = CAMERA_ERROR_NONE;
2827 camera_cli_s *pc = (camera_cli_s *)camera;
2828 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2830 if (!pc || !pc->cb_info) {
2831 LOGE("NULL handle");
2832 return CAMERA_ERROR_INVALID_PARAMETER;
2837 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2839 if (ret == CAMERA_ERROR_NONE)
2840 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2842 LOGD("ret : 0x%x", ret);
2847 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2849 int ret = CAMERA_ERROR_NONE;
2850 camera_cli_s *pc = (camera_cli_s *)camera;
2851 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
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);
2862 if (ret == CAMERA_ERROR_NONE) {
2863 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2865 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2866 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2868 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2871 LOGD("ret : 0x%x", ret);
2876 int camera_stop_face_detection(camera_h camera)
2878 int ret = CAMERA_ERROR_NONE;
2879 camera_cli_s *pc = (camera_cli_s *)camera;
2880 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
2882 if (!pc || !pc->cb_info) {
2883 LOGE("NULL handle");
2884 return CAMERA_ERROR_INVALID_PARAMETER;
2889 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2891 if (ret == CAMERA_ERROR_NONE) {
2892 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2894 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
2895 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
2897 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2900 LOGD("ret : 0x%x", ret);
2905 int camera_get_state(camera_h camera, camera_state_e *state)
2907 int ret = CAMERA_ERROR_NONE;
2908 camera_cli_s *pc = (camera_cli_s *)camera;
2909 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
2911 if (!pc || !pc->cb_info || !state) {
2912 LOGE("NULL pointer %p %p", pc, state);
2913 return CAMERA_ERROR_INVALID_PARAMETER;
2918 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2920 if (ret == CAMERA_ERROR_NONE)
2921 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
2923 LOGD("ret : 0x%x", ret);
2928 int camera_start_focusing(camera_h camera, bool continuous)
2930 int ret = CAMERA_ERROR_NONE;
2931 camera_cli_s *pc = (camera_cli_s *)camera;
2932 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
2933 camera_msg_param param;
2934 int is_continuous = (int)continuous;
2936 if (!pc || !pc->cb_info) {
2937 LOGE("NULL handle");
2938 return CAMERA_ERROR_INVALID_PARAMETER;
2943 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
2945 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2947 LOGD("ret : 0x%x", ret);
2952 int camera_cancel_focusing(camera_h camera)
2954 int ret = CAMERA_ERROR_NONE;
2955 camera_cli_s *pc = (camera_cli_s *)camera;
2956 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
2958 if (!pc || !pc->cb_info) {
2959 LOGE("NULL handle");
2960 return CAMERA_ERROR_INVALID_PARAMETER;
2963 LOGD("Enter, remote_handle : %x", pc->remote_handle);
2965 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2967 LOGD("ret : 0x%x", ret);
2972 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
2974 int ret = CAMERA_ERROR_NONE;
2976 camera_cli_s *pc = (camera_cli_s *)camera;
2977 camera_cb_info_s *cb_info = NULL;
2978 camera_state_e current_state = CAMERA_STATE_NONE;
2979 camera_msg_param param0;
2980 camera_msg_param param1;
2981 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
2983 if (!pc || !pc->cb_info) {
2984 LOGE("NULL handle");
2985 return CAMERA_ERROR_INVALID_PARAMETER;
2988 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
2989 LOGE("invalid type %d", type);
2990 return CAMERA_ERROR_INVALID_PARAMETER;
2993 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
2994 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
2995 return CAMERA_ERROR_INVALID_PARAMETER;
2998 cb_info = (camera_cb_info_s *)pc->cb_info;
3000 ret = camera_get_state(camera, ¤t_state);
3001 if (ret != CAMERA_ERROR_NONE) {
3002 LOGE("failed to get current state 0x%x", ret);
3006 if (current_state != CAMERA_STATE_CREATED) {
3007 LOGE("INVALID_STATE : current %d", current_state);
3008 return CAMERA_ERROR_INVALID_STATE;
3011 LOGD("Enter - type : %d, display : %p", type, display);
3013 if (type != CAMERA_DISPLAY_TYPE_NONE) {
3014 /* check display interface handle */
3015 if (!cb_info->dp_interface) {
3016 LOGE("display interface not supported");
3017 return CAMERA_ERROR_NOT_SUPPORTED;
3020 ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &parent_id);
3021 if (ret != MM_ERROR_NONE) {
3022 LOGE("[INVALID_OPERATION] set display failed[0x%x]", ret);
3023 return CAMERA_ERROR_INVALID_OPERATION;
3026 if (type == CAMERA_DISPLAY_TYPE_EVAS) {
3027 camera_flip_e flip = CAMERA_FLIP_NONE;
3028 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3029 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3036 camera_get_display_flip(camera, &flip);
3037 camera_get_display_mode(camera, &mode);
3038 camera_get_display_rotation(camera, &rotation);
3039 camera_is_display_visible(camera, &visible);
3040 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3042 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
3043 flip, mode, rotation, visible, x, y, width, height);
3045 ret = mm_display_interface_evas_set_flip(cb_info->dp_interface, flip);
3046 ret |= mm_display_interface_evas_set_mode(cb_info->dp_interface, mode);
3047 ret |= mm_display_interface_evas_set_rotation(cb_info->dp_interface, rotation);
3048 ret |= mm_display_interface_evas_set_visible(cb_info->dp_interface, visible);
3050 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
3051 ret |= mm_display_interface_evas_set_roi_area(cb_info->dp_interface, x, y, width, height);
3055 CAMERA_MSG_PARAM_SET(param0, INT, type);
3056 CAMERA_MSG_PARAM_SET(param1, INT, parent_id);
3058 _camera_msg_send_param2_int(api, cb_info, &ret,
3059 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
3061 if (ret == CAMERA_ERROR_NONE) {
3062 pc->cb_info->dp_type = type;
3064 if (type == CAMERA_DISPLAY_TYPE_EVAS)
3065 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3072 int camera_set_preview_resolution(camera_h camera, int width, int height)
3074 int ret = CAMERA_ERROR_NONE;
3075 camera_state_e current_state = CAMERA_STATE_NONE;
3076 camera_cli_s *pc = (camera_cli_s *)camera;
3077 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3078 camera_msg_param param;
3081 if (!pc || !pc->cb_info) {
3082 LOGE("NULL handle");
3083 return CAMERA_ERROR_INVALID_PARAMETER;
3086 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3087 ret = camera_get_state(camera, ¤t_state);
3088 if (ret != CAMERA_ERROR_NONE) {
3089 LOGE("failed to get current state 0x%x", ret);
3093 if (current_state == CAMERA_STATE_PREVIEW) {
3094 ret = _camera_stop_evas_rendering(camera, true);
3095 if (ret != CAMERA_ERROR_NONE)
3100 value = (width << 16) | height;
3101 CAMERA_MSG_PARAM_SET(param, INT, value);
3103 LOGD("%dx%d -> 0x%x", width, height, value);
3105 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3107 LOGD("ret : 0x%x", ret);
3109 if (current_state == CAMERA_STATE_PREVIEW) {
3110 LOGW("restart evas rendering");
3111 _camera_start_evas_rendering(camera);
3118 int camera_set_capture_resolution(camera_h camera, int width, int height)
3120 int ret = CAMERA_ERROR_NONE;
3121 camera_cli_s *pc = (camera_cli_s *)camera;
3122 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3123 camera_msg_param param;
3126 if (!pc || !pc->cb_info) {
3127 LOGE("NULL handle");
3128 return CAMERA_ERROR_INVALID_PARAMETER;
3133 value = (width << 16) | height;
3134 CAMERA_MSG_PARAM_SET(param, INT, value);
3136 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3138 LOGD("ret : 0x%x", ret);
3144 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3146 int ret = CAMERA_ERROR_NONE;
3147 int set_format = (int)format;
3148 camera_cli_s *pc = (camera_cli_s *)camera;
3149 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3150 camera_msg_param param;
3152 if (!pc || !pc->cb_info) {
3153 LOGE("NULL handle");
3154 return CAMERA_ERROR_INVALID_PARAMETER;
3157 LOGD("Enter - format %d", set_format);
3159 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3161 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3163 LOGD("ret : 0x%x", ret);
3169 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3171 int ret = CAMERA_ERROR_NONE;
3172 int set_format = (int)format;
3173 camera_msg_param param;
3174 camera_cli_s *pc = (camera_cli_s *)camera;
3175 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3177 if (!pc || !pc->cb_info) {
3178 LOGE("NULL handle");
3179 return CAMERA_ERROR_INVALID_PARAMETER;
3182 LOGD("Enter - capture_format %d", set_format);
3184 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3186 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3188 if (ret == CAMERA_ERROR_NONE)
3189 pc->cb_info->preview_format = set_format;
3191 LOGD("ret : 0x%x", ret);
3197 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3199 int ret = CAMERA_ERROR_NONE;
3200 camera_cli_s *pc = (camera_cli_s *)camera;
3201 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3203 if (!pc || !pc->cb_info || !width || !height) {
3204 LOGE("NULL pointer %p %p %p", pc, width, height);
3205 return CAMERA_ERROR_INVALID_PARAMETER;
3210 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3212 if (ret == CAMERA_ERROR_NONE) {
3213 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3214 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3217 LOGD("ret : 0x%x", ret);
3223 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3225 int ret = CAMERA_ERROR_NONE;
3226 int set_rotation = (int)rotation;
3227 camera_cli_s *pc = (camera_cli_s *)camera;
3228 camera_msg_param param;
3230 if (!pc || !pc->cb_info) {
3231 LOGE("NULL handle");
3232 return CAMERA_ERROR_INVALID_PARAMETER;
3235 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3236 ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
3237 if (ret != MM_ERROR_NONE) {
3238 LOGE("failed to set rotation for evas surface 0x%x", ret);
3239 return CAMERA_ERROR_INVALID_OPERATION;
3243 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3245 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3251 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3253 int ret = CAMERA_ERROR_NONE;
3254 camera_cli_s *pc = (camera_cli_s *)camera;
3256 if (!pc || !pc->cb_info || !rotation) {
3257 LOGE("NULL pointer %p %p", pc, rotation);
3258 return CAMERA_ERROR_INVALID_PARAMETER;
3261 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3263 if (ret == CAMERA_ERROR_NONE)
3264 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3270 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3272 int ret = CAMERA_ERROR_NONE;
3273 int set_flip = (int)flip;
3274 camera_cli_s *pc = (camera_cli_s *)camera;
3275 camera_msg_param param;
3277 if (!pc || !pc->cb_info) {
3278 LOGE("NULL handle");
3279 return CAMERA_ERROR_INVALID_PARAMETER;
3282 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3283 ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
3284 if (ret != MM_ERROR_NONE) {
3285 LOGE("failed to set flip for evas surface 0x%x", ret);
3286 return CAMERA_ERROR_INVALID_OPERATION;
3290 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3292 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3298 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3300 int ret = CAMERA_ERROR_NONE;
3301 camera_cli_s *pc = (camera_cli_s *)camera;
3303 if (!pc || !pc->cb_info || !flip) {
3304 LOGE("NULL pointer %p %p", pc, flip);
3305 return CAMERA_ERROR_INVALID_PARAMETER;
3308 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3310 if (ret == CAMERA_ERROR_NONE)
3311 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3317 int camera_set_display_visible(camera_h camera, bool visible)
3319 int ret = CAMERA_ERROR_NONE;
3320 int set_visible = (int)visible;
3321 camera_cli_s *pc = (camera_cli_s *)camera;
3322 camera_msg_param param;
3324 if (!pc || !pc->cb_info) {
3325 LOGE("NULL handle");
3326 return CAMERA_ERROR_INVALID_PARAMETER;
3329 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3330 ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
3331 if (ret != MM_ERROR_NONE) {
3332 LOGE("failed to set visible for evas surface 0x%x", ret);
3333 return CAMERA_ERROR_INVALID_OPERATION;
3337 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3339 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3345 int camera_is_display_visible(camera_h camera, bool *visible)
3347 int ret = CAMERA_ERROR_NONE;
3348 camera_cli_s *pc = (camera_cli_s *)camera;
3350 if (!pc || !pc->cb_info || !visible) {
3351 LOGE("NULL pointer %p %p", pc, visible);
3352 return CAMERA_ERROR_INVALID_PARAMETER;
3355 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3357 if (ret == CAMERA_ERROR_NONE)
3358 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3364 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3366 int ret = CAMERA_ERROR_NONE;
3367 int set_mode = (int)mode;
3368 camera_cli_s *pc = (camera_cli_s *)camera;
3369 camera_msg_param param;
3371 if (!pc || !pc->cb_info) {
3372 LOGE("NULL handle");
3373 return CAMERA_ERROR_INVALID_PARAMETER;
3376 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3377 ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
3378 if (ret != MM_ERROR_NONE) {
3379 LOGE("failed to set geometry for evas surface 0x%x", ret);
3380 return CAMERA_ERROR_INVALID_OPERATION;
3384 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3386 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3392 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3394 int ret = CAMERA_ERROR_NONE;
3395 camera_cli_s *pc = (camera_cli_s *)camera;
3397 if (!pc || !pc->cb_info || !mode) {
3398 LOGE("NULL pointer %p %p", pc, mode);
3399 return CAMERA_ERROR_INVALID_PARAMETER;
3402 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3404 if (ret == CAMERA_ERROR_NONE)
3405 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3411 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3413 int ret = CAMERA_ERROR_NONE;
3414 int set_hint = (int)hint;
3415 camera_cli_s *pc = (camera_cli_s *)camera;
3416 camera_msg_param param;
3418 if (!pc || !pc->cb_info) {
3419 LOGE("NULL handle");
3420 return CAMERA_ERROR_INVALID_PARAMETER;
3423 LOGD("Enter - hint %d", set_hint);
3425 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3427 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3433 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3435 int ret = CAMERA_ERROR_NONE;
3436 camera_cli_s *pc = (camera_cli_s *)camera;
3437 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3439 if (!pc || !pc->cb_info || !hint) {
3440 LOGE("NULL pointer %p %p", pc, hint);
3441 return CAMERA_ERROR_INVALID_PARAMETER;
3444 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3446 if (ret == CAMERA_ERROR_NONE) {
3447 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3448 LOGD("display reuse hint %d", *hint);
3455 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3457 int ret = CAMERA_ERROR_NONE;
3458 camera_cli_s *pc = (camera_cli_s *)camera;
3459 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3461 if (!pc || !pc->cb_info || !width || !height) {
3462 LOGE("NULL pointer %p %p %p", pc, width, height);
3463 return CAMERA_ERROR_INVALID_PARAMETER;
3468 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3470 if (ret == CAMERA_ERROR_NONE) {
3471 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3472 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3475 LOGD("ret : 0x%x", ret);
3481 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3483 int ret = CAMERA_ERROR_NONE;
3484 camera_cli_s *pc = (camera_cli_s *)camera;
3485 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3487 if (!pc || !pc->cb_info || !format) {
3488 LOGE("NULL pointer %p %p", pc, format);
3489 return CAMERA_ERROR_INVALID_PARAMETER;
3494 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3496 if (ret == CAMERA_ERROR_NONE)
3497 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3499 LOGD("ret : 0x%x", ret);
3505 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
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_PREVIEW_FORMAT;
3511 if (!pc || !pc->cb_info || !format) {
3512 LOGE("NULL pointer %p %p", pc, format);
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 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3523 LOGD("ret : 0x%x", ret);
3529 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3531 int ret = CAMERA_ERROR_NONE;
3532 camera_cli_s *pc = (camera_cli_s *)camera;
3533 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3535 if (!pc || !pc->cb_info || !facing_direction) {
3536 LOGE("NULL pointer %p %p", pc, facing_direction);
3537 return CAMERA_ERROR_INVALID_PARAMETER;
3542 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3544 if (ret == CAMERA_ERROR_NONE)
3545 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3547 LOGD("ret : 0x%x", ret);
3553 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3555 int ret = CAMERA_ERROR_NONE;
3556 camera_cli_s *pc = (camera_cli_s *)camera;
3557 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3559 if (!pc || !pc->cb_info || !callback) {
3560 LOGE("NULL pointer %p %p", pc, callback);
3561 return CAMERA_ERROR_INVALID_PARAMETER;
3566 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3568 if (ret == CAMERA_ERROR_NONE) {
3569 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3571 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3572 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3574 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3576 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3579 LOGD("ret : 0x%x", ret);
3585 int camera_unset_preview_cb(camera_h camera)
3587 int ret = CAMERA_ERROR_NONE;
3588 camera_cli_s *pc = (camera_cli_s *)camera;
3589 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3591 if (!pc || !pc->cb_info) {
3592 LOGE("NULL handle");
3593 return CAMERA_ERROR_INVALID_PARAMETER;
3598 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3600 if (ret == CAMERA_ERROR_NONE) {
3601 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3603 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3604 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3606 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3608 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3611 LOGD("ret : 0x%x", ret);
3617 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3619 int ret = CAMERA_ERROR_NONE;
3620 camera_cli_s *pc = (camera_cli_s *)camera;
3621 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3623 if (!pc || !pc->cb_info) {
3624 LOGE("NULL handle");
3625 return CAMERA_ERROR_INVALID_PARAMETER;
3628 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3629 LOGE("NOT SUPPORTED");
3630 return CAMERA_ERROR_NOT_SUPPORTED;
3633 if (callback == NULL) {
3634 LOGE("NULL callback");
3635 return CAMERA_ERROR_INVALID_PARAMETER;
3640 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3642 if (ret == CAMERA_ERROR_NONE) {
3643 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3645 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3646 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3648 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3651 LOGD("ret : 0x%x", ret);
3657 int camera_unset_media_packet_preview_cb(camera_h camera)
3659 int ret = CAMERA_ERROR_NONE;
3660 camera_cli_s *pc = (camera_cli_s *)camera;
3661 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3663 if (!pc || !pc->cb_info) {
3664 LOGE("NULL handle");
3665 return CAMERA_ERROR_INVALID_PARAMETER;
3670 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3672 if (ret == CAMERA_ERROR_NONE) {
3673 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3675 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3676 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3678 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3681 LOGD("ret : 0x%x", ret);
3687 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3689 int ret = CAMERA_ERROR_NONE;
3690 camera_cli_s *pc = (camera_cli_s *)camera;
3691 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3693 if (!pc || !pc->cb_info || !callback) {
3694 LOGE("NULL pointer %p %p", pc, callback);
3695 return CAMERA_ERROR_INVALID_PARAMETER;
3700 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3702 if (ret == CAMERA_ERROR_NONE) {
3703 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3705 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3706 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3708 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3711 LOGD("ret : 0x%x", ret);
3717 int camera_unset_state_changed_cb(camera_h camera)
3719 int ret = CAMERA_ERROR_NONE;
3720 camera_cli_s *pc = (camera_cli_s *)camera;
3721 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3723 if (!pc || !pc->cb_info) {
3724 LOGE("NULL handle");
3725 return CAMERA_ERROR_INVALID_PARAMETER;
3730 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3732 if (ret == CAMERA_ERROR_NONE) {
3733 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3735 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3736 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3738 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3741 LOGD("ret : 0x%x", ret);
3747 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3749 int ret = CAMERA_ERROR_NONE;
3750 camera_cli_s *pc = (camera_cli_s *)camera;
3751 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3753 if (!pc || !pc->cb_info || !callback) {
3754 LOGE("NULL pointer %p %p", pc, callback);
3755 return CAMERA_ERROR_INVALID_PARAMETER;
3760 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3762 if (ret == CAMERA_ERROR_NONE) {
3763 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3765 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3766 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3768 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3771 LOGD("ret : 0x%x", ret);
3777 int camera_unset_interrupted_cb(camera_h camera)
3779 int ret = CAMERA_ERROR_NONE;
3780 camera_cli_s *pc = (camera_cli_s *)camera;
3781 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3783 if (!pc || !pc->cb_info) {
3784 LOGE("NULL handle");
3785 return CAMERA_ERROR_INVALID_PARAMETER;
3790 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3792 if (ret == CAMERA_ERROR_NONE) {
3793 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3795 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3796 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3798 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3801 LOGD("ret : 0x%x", ret);
3807 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
3809 int ret = CAMERA_ERROR_NONE;
3810 camera_cli_s *pc = (camera_cli_s *)camera;
3811 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
3813 if (!pc || !pc->cb_info || !callback) {
3814 LOGE("NULL pointer %p %p", pc, callback);
3815 return CAMERA_ERROR_INVALID_PARAMETER;
3820 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3822 if (ret == CAMERA_ERROR_NONE) {
3823 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3825 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
3826 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
3828 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3831 LOGD("ret : 0x%x", ret);
3837 int camera_unset_interrupt_started_cb(camera_h camera)
3839 int ret = CAMERA_ERROR_NONE;
3840 camera_cli_s *pc = (camera_cli_s *)camera;
3841 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
3843 if (!pc || !pc->cb_info) {
3844 LOGE("NULL handle");
3845 return CAMERA_ERROR_INVALID_PARAMETER;
3850 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3852 if (ret == CAMERA_ERROR_NONE) {
3853 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3855 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3856 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3858 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3861 LOGD("ret : 0x%x", ret);
3867 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
3869 int ret = CAMERA_ERROR_NONE;
3870 camera_cli_s *pc = (camera_cli_s *)camera;
3871 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3873 if (!pc || !pc->cb_info || !callback) {
3874 LOGE("NULL pointer %p %p", pc, callback);
3875 return CAMERA_ERROR_INVALID_PARAMETER;
3880 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3882 if (ret == CAMERA_ERROR_NONE) {
3883 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3885 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3886 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3888 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3891 LOGD("ret : 0x%x", ret);
3897 int camera_unset_focus_changed_cb(camera_h camera)
3899 int ret = CAMERA_ERROR_NONE;
3900 camera_cli_s *pc = (camera_cli_s *)camera;
3901 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
3903 if (!pc || !pc->cb_info) {
3904 LOGE("NULL handle");
3905 return CAMERA_ERROR_INVALID_PARAMETER;
3910 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3912 if (ret == CAMERA_ERROR_NONE) {
3913 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3915 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3916 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3918 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3921 LOGD("ret : 0x%x", ret);
3927 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
3929 int ret = CAMERA_ERROR_NONE;
3930 camera_cli_s *pc = (camera_cli_s *)camera;
3931 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
3933 if (!pc || !pc->cb_info || !callback) {
3934 LOGE("NULL pointer %p %p", pc, callback);
3935 return CAMERA_ERROR_INVALID_PARAMETER;
3940 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3942 if (ret == CAMERA_ERROR_NONE) {
3943 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3945 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
3946 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
3948 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3951 LOGD("ret : 0x%x", ret);
3957 int camera_unset_error_cb(camera_h camera)
3959 int ret = CAMERA_ERROR_NONE;
3960 camera_cli_s *pc = (camera_cli_s *)camera;
3961 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
3963 if (!pc || !pc->cb_info) {
3964 LOGE("NULL handle");
3965 return CAMERA_ERROR_INVALID_PARAMETER;
3970 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3972 if (ret == CAMERA_ERROR_NONE) {
3973 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3975 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
3976 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
3978 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3981 LOGD("ret : 0x%x", ret);
3987 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
3989 int ret = CAMERA_ERROR_NONE;
3990 camera_cli_s *pc = (camera_cli_s *)camera;
3991 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
3993 if (!pc || !pc->cb_info || !foreach_cb) {
3994 LOGE("NULL pointer %p %p", pc, foreach_cb);
3995 return CAMERA_ERROR_INVALID_PARAMETER;
4000 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4001 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4003 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4005 LOGD("ret : 0x%x", ret);
4011 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4013 int ret = CAMERA_ERROR_NONE;
4014 camera_cli_s *pc = (camera_cli_s *)camera;
4015 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4017 if (!pc || !pc->cb_info || !foreach_cb) {
4018 LOGE("NULL pointer %p %p", pc, foreach_cb);
4019 return CAMERA_ERROR_INVALID_PARAMETER;
4024 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4025 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4027 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4029 LOGD("ret : 0x%x", ret);
4035 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4037 int ret = CAMERA_ERROR_NONE;
4038 camera_cli_s *pc = (camera_cli_s *)camera;
4039 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4041 if (!pc || !pc->cb_info || !foreach_cb) {
4042 LOGE("NULL pointer %p %p", pc, foreach_cb);
4043 return CAMERA_ERROR_INVALID_PARAMETER;
4048 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4049 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4051 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4053 LOGD("ret : 0x%x", ret);
4059 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4061 int ret = CAMERA_ERROR_NONE;
4062 camera_cli_s *pc = (camera_cli_s *)camera;
4063 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4065 if (!pc || !pc->cb_info || !foreach_cb) {
4066 LOGE("NULL pointer %p %p", pc, foreach_cb);
4067 return CAMERA_ERROR_INVALID_PARAMETER;
4072 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4073 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4075 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4077 LOGD("ret : 0x%x", ret);
4083 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4085 int ret = CAMERA_ERROR_NONE;
4086 camera_cli_s *pc = (camera_cli_s *)camera;
4087 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4089 if (!pc || !pc->cb_info || !width || !height) {
4090 LOGE("NULL pointer %p %p %p", pc, width, height);
4091 return CAMERA_ERROR_INVALID_PARAMETER;
4095 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4097 if (ret == CAMERA_ERROR_NONE) {
4098 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4099 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4102 LOGD("ret : 0x%x", ret);
4108 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4110 int ret = CAMERA_ERROR_NONE;
4111 camera_cli_s *pc = (camera_cli_s *)camera;
4112 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4114 if (!pc || !pc->cb_info || !angle) {
4115 LOGE("NULL pointer %p %p", pc, angle);
4116 return CAMERA_ERROR_INVALID_PARAMETER;
4121 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4123 if (ret == CAMERA_ERROR_NONE)
4124 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4126 LOGD("ret : 0x%x", ret);
4132 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4134 int ret = CAMERA_ERROR_NONE;
4135 camera_cli_s *pc = (camera_cli_s *)camera;
4136 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4137 camera_msg_param param;
4138 int set_mode = (int)mode;
4140 if (!pc || !pc->cb_info) {
4141 LOGE("NULL handle");
4142 return CAMERA_ERROR_INVALID_PARAMETER;
4147 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4149 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4151 LOGD("ret : 0x%x", ret);
4157 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4159 int ret = CAMERA_ERROR_NONE;
4160 camera_cli_s *pc = (camera_cli_s *)camera;
4161 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4163 if (!pc || !pc->cb_info || !mode) {
4164 LOGE("NULL pointer %p %p", pc, mode);
4165 return CAMERA_ERROR_INVALID_PARAMETER;
4170 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4172 if (ret == CAMERA_ERROR_NONE)
4173 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4175 LOGD("ret : 0x%x", ret);
4181 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4183 int ret = CAMERA_ERROR_NONE;
4184 camera_cli_s *pc = (camera_cli_s *)camera;
4185 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4187 if (!pc || !pc->cb_info || !foreach_cb) {
4188 LOGE("NULL pointer %p %p", pc, foreach_cb);
4189 return CAMERA_ERROR_INVALID_PARAMETER;
4194 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4195 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4197 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4199 LOGD("Finish, return :%x", ret);
4205 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4207 int ret = CAMERA_ERROR_NONE;
4208 camera_cli_s *pc = (camera_cli_s *)camera;
4209 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4210 camera_msg_param param;
4211 int set_fps = (int)fps;
4213 if (!pc || !pc->cb_info) {
4214 LOGE("NULL handle");
4215 return CAMERA_ERROR_INVALID_PARAMETER;
4220 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4222 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4224 LOGD("ret : 0x%x", ret);
4230 int camera_attr_set_image_quality(camera_h camera, int quality)
4232 int ret = CAMERA_ERROR_NONE;
4233 camera_cli_s *pc = (camera_cli_s *)camera;
4234 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4235 camera_msg_param param;
4237 if (!pc || !pc->cb_info) {
4238 LOGE("NULL handle");
4239 return CAMERA_ERROR_INVALID_PARAMETER;
4244 CAMERA_MSG_PARAM_SET(param, INT, quality);
4246 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4248 LOGD("ret : 0x%x", ret);
4254 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4256 int ret = CAMERA_ERROR_NONE;
4257 camera_cli_s *pc = (camera_cli_s *)camera;
4258 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4260 if (!pc || !pc->cb_info || !fps) {
4261 LOGE("NULL pointer %p %p", pc, fps);
4262 return CAMERA_ERROR_INVALID_PARAMETER;
4267 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4269 if (ret == CAMERA_ERROR_NONE)
4270 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4272 LOGD("ret : 0x%x", ret);
4278 int camera_attr_get_image_quality(camera_h camera, int *quality)
4280 int ret = CAMERA_ERROR_NONE;
4281 camera_cli_s *pc = (camera_cli_s *)camera;
4282 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4284 if (!pc || !pc->cb_info || !quality) {
4285 LOGE("NULL pointer %p %p", pc, quality);
4286 return CAMERA_ERROR_INVALID_PARAMETER;
4291 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4293 if (ret == CAMERA_ERROR_NONE)
4294 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4296 LOGD("ret : 0x%x", ret);
4302 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4304 int ret = CAMERA_ERROR_NONE;
4305 camera_cli_s *pc = (camera_cli_s *)camera;
4306 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4308 if (!pc || !pc->cb_info || !bitrate) {
4309 LOGE("NULL pointer %p %p", pc, bitrate);
4310 return CAMERA_ERROR_INVALID_PARAMETER;
4315 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4317 if (ret == CAMERA_ERROR_NONE)
4318 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4320 LOGD("ret : 0x%x", ret);
4326 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4328 int ret = CAMERA_ERROR_NONE;
4329 camera_cli_s *pc = (camera_cli_s *)camera;
4330 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4331 camera_msg_param param;
4332 int set_bitrate = bitrate;
4334 if (!pc || !pc->cb_info) {
4335 LOGE("NULL handle");
4336 return CAMERA_ERROR_INVALID_PARAMETER;
4341 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4343 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4345 LOGD("ret : 0x%x", ret);
4351 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4353 int ret = CAMERA_ERROR_NONE;
4354 camera_cli_s *pc = (camera_cli_s *)camera;
4355 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4357 if (!pc || !pc->cb_info || !interval) {
4358 LOGE("NULL pointer %p %p", pc, interval);
4359 return CAMERA_ERROR_INVALID_PARAMETER;
4364 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4366 if (ret == CAMERA_ERROR_NONE)
4367 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4369 LOGD("ret : 0x%x", ret);
4375 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4377 int ret = CAMERA_ERROR_NONE;
4378 camera_cli_s *pc = (camera_cli_s *)camera;
4379 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4380 camera_msg_param param;
4381 int set_gop_interval = interval;
4383 if (!pc || !pc->cb_info) {
4384 LOGE("NULL handle");
4385 return CAMERA_ERROR_INVALID_PARAMETER;
4390 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4392 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4394 LOGD("ret : 0x%x", ret);
4400 int camera_attr_set_zoom(camera_h camera, int zoom)
4402 int ret = CAMERA_ERROR_NONE;
4403 camera_cli_s *pc = (camera_cli_s *)camera;
4404 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4405 camera_msg_param param;
4407 if (!pc || !pc->cb_info) {
4408 LOGE("NULL handle");
4409 return CAMERA_ERROR_INVALID_PARAMETER;
4412 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4414 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4416 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4418 LOGD("ret : 0x%x", ret);
4424 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4426 int ret = CAMERA_ERROR_NONE;
4427 camera_cli_s *pc = (camera_cli_s *)camera;
4428 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4429 camera_msg_param param;
4430 int set_mode = (int)mode;
4432 if (!pc || !pc->cb_info) {
4433 LOGE("NULL handle");
4434 return CAMERA_ERROR_INVALID_PARAMETER;
4437 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4439 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4441 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4447 int camera_attr_set_af_area(camera_h camera, int x, int y)
4449 int ret = CAMERA_ERROR_NONE;
4450 camera_cli_s *pc = (camera_cli_s *)camera;
4451 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4452 camera_msg_param param;
4455 if (!pc || !pc->cb_info) {
4456 LOGE("NULL handle");
4457 return CAMERA_ERROR_INVALID_PARAMETER;
4460 LOGD("Enter - %d,%d", x, y);
4462 value = (x << 16) | y;
4463 CAMERA_MSG_PARAM_SET(param, INT, value);
4465 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4467 LOGD("ret : 0x%x", ret);
4473 int camera_attr_clear_af_area(camera_h camera)
4475 int ret = CAMERA_ERROR_NONE;
4476 camera_cli_s *pc = (camera_cli_s *)camera;
4477 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4479 if (!pc || !pc->cb_info) {
4480 LOGE("NULL handle");
4481 return CAMERA_ERROR_INVALID_PARAMETER;
4486 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4488 LOGD("ret : 0x%x", ret);
4494 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4496 int ret = CAMERA_ERROR_NONE;
4497 camera_cli_s *pc = (camera_cli_s *)camera;
4498 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4499 camera_msg_param param;
4500 int set_mode = (int)mode;
4502 if (!pc || !pc->cb_info) {
4503 LOGE("NULL handle");
4504 return CAMERA_ERROR_INVALID_PARAMETER;
4509 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4511 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4513 LOGD("ret : 0x%x", ret);
4519 int camera_attr_set_exposure(camera_h camera, int value)
4521 int ret = CAMERA_ERROR_NONE;
4522 camera_cli_s *pc = (camera_cli_s *)camera;
4523 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4524 camera_msg_param param;
4526 if (!pc || !pc->cb_info) {
4527 LOGE("NULL handle");
4528 return CAMERA_ERROR_INVALID_PARAMETER;
4533 CAMERA_MSG_PARAM_SET(param, INT, value);
4535 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4537 LOGD("ret : 0x%x", ret);
4543 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4545 int ret = CAMERA_ERROR_NONE;
4546 camera_cli_s *pc = (camera_cli_s *)camera;
4547 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4548 camera_msg_param param;
4549 int set_iso = (int)iso;
4551 if (!pc || !pc->cb_info) {
4552 LOGE("NULL handle");
4553 return CAMERA_ERROR_INVALID_PARAMETER;
4558 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4560 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4562 LOGD("ret : 0x%x", ret);
4568 int camera_attr_set_brightness(camera_h camera, int level)
4570 int ret = CAMERA_ERROR_NONE;
4571 camera_cli_s *pc = (camera_cli_s *)camera;
4572 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4573 camera_msg_param param;
4575 if (!pc || !pc->cb_info) {
4576 LOGE("NULL handle");
4577 return CAMERA_ERROR_INVALID_PARAMETER;
4582 CAMERA_MSG_PARAM_SET(param, INT, level);
4584 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4586 LOGD("ret : 0x%x", ret);
4592 int camera_attr_set_contrast(camera_h camera, int level)
4594 int ret = CAMERA_ERROR_NONE;
4595 camera_cli_s *pc = (camera_cli_s *)camera;
4596 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4597 camera_msg_param param;
4599 if (!pc || !pc->cb_info) {
4600 LOGE("NULL handle");
4601 return CAMERA_ERROR_INVALID_PARAMETER;
4606 CAMERA_MSG_PARAM_SET(param, INT, level);
4608 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4610 LOGD("ret : 0x%x", ret);
4616 int camera_attr_set_hue(camera_h camera, int level)
4618 int ret = CAMERA_ERROR_NONE;
4619 camera_cli_s *pc = (camera_cli_s *)camera;
4620 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HUE;
4621 camera_msg_param param;
4623 if (!pc || !pc->cb_info) {
4624 LOGE("NULL handle");
4625 return CAMERA_ERROR_INVALID_PARAMETER;
4630 CAMERA_MSG_PARAM_SET(param, INT, level);
4632 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4634 LOGD("ret : 0x%x", ret);
4640 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4642 int ret = CAMERA_ERROR_NONE;
4643 camera_cli_s *pc = (camera_cli_s *)camera;
4644 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4645 camera_msg_param param;
4646 int set_whitebalance = (int)wb;
4648 if (!pc || !pc->cb_info) {
4649 LOGE("NULL handle");
4650 return CAMERA_ERROR_INVALID_PARAMETER;
4655 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4657 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4659 LOGD("ret : 0x%x", ret);
4665 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4667 int ret = CAMERA_ERROR_NONE;
4668 camera_cli_s *pc = (camera_cli_s *)camera;
4669 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4670 camera_msg_param param;
4671 int set_effect = (int)effect;
4673 if (!pc || !pc->cb_info) {
4674 LOGE("NULL handle");
4675 return CAMERA_ERROR_INVALID_PARAMETER;
4680 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
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_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
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_SCENE_MODE;
4695 camera_msg_param param;
4696 int set_mode = (int)mode;
4698 if (!pc || !pc->cb_info) {
4699 LOGE("NULL handle");
4700 return CAMERA_ERROR_INVALID_PARAMETER;
4705 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4707 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4709 LOGD("ret : 0x%x", ret);
4715 int camera_attr_enable_tag(camera_h camera, bool enable)
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_ENABLE_TAG;
4720 camera_msg_param param;
4721 int set_enable = (int)enable;
4723 if (!pc || !pc->cb_info) {
4724 LOGE("NULL handle");
4725 return CAMERA_ERROR_INVALID_PARAMETER;
4730 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
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_tag_image_description(camera_h camera, const char *description)
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_TAG_IMAGE_DESCRIPTION;
4745 camera_msg_param param;
4747 if (!pc || !pc->cb_info || !description) {
4748 LOGE("NULL pointer %p %p", pc, description);
4749 return CAMERA_ERROR_INVALID_PARAMETER;
4754 CAMERA_MSG_PARAM_SET(param, STRING, description);
4756 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4758 LOGD("ret : 0x%x", ret);
4764 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4766 int ret = CAMERA_ERROR_NONE;
4767 camera_cli_s *pc = (camera_cli_s *)camera;
4768 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4769 camera_msg_param param;
4770 int set_orientation = (int)orientation;
4772 if (!pc || !pc->cb_info) {
4773 LOGE("NULL handle");
4774 return CAMERA_ERROR_INVALID_PARAMETER;
4779 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4781 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4783 LOGD("ret : 0x%x", ret);
4789 int camera_attr_set_tag_software(camera_h camera, const char *software)
4791 int ret = CAMERA_ERROR_NONE;
4792 camera_cli_s *pc = (camera_cli_s *)camera;
4793 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4794 camera_msg_param param;
4796 if (!pc || !pc->cb_info || !software) {
4797 LOGE("NULL pointer %p %p", pc, software);
4798 return CAMERA_ERROR_INVALID_PARAMETER;
4801 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4803 CAMERA_MSG_PARAM_SET(param, STRING, software);
4805 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4807 LOGD("ret : 0x%x", ret);
4813 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4815 int ret = CAMERA_ERROR_NONE;
4816 camera_cli_s *pc = (camera_cli_s *)camera;
4817 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4818 double set_geotag[3] = {latitude, longitude, altitude};
4823 if (!pc || !pc->cb_info) {
4824 LOGE("NULL handle");
4825 return CAMERA_ERROR_INVALID_PARAMETER;
4830 length = sizeof(set_geotag) / sizeof(int) + \
4831 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4833 msg = muse_core_msg_new(api,
4834 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4837 LOGE("msg creation failed: api %d", api);
4838 return CAMERA_ERROR_OUT_OF_MEMORY;
4841 if (pc->cb_info->is_server_connected) {
4842 __camera_update_api_waiting(pc->cb_info, api, 1);
4844 g_mutex_lock(&pc->cb_info->fd_lock);
4845 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
4846 g_mutex_unlock(&pc->cb_info->fd_lock);
4850 LOGE("message send failed");
4851 ret = CAMERA_ERROR_INVALID_OPERATION;
4853 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
4856 __camera_update_api_waiting(pc->cb_info, api, -1);
4858 muse_core_msg_free(msg);
4860 LOGD("ret : 0x%x", ret);
4866 int camera_attr_remove_geotag(camera_h camera)
4868 int ret = CAMERA_ERROR_NONE;
4869 camera_cli_s *pc = (camera_cli_s *)camera;
4870 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4872 if (!pc || !pc->cb_info) {
4873 LOGE("NULL handle");
4874 return CAMERA_ERROR_INVALID_PARAMETER;
4879 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4881 LOGD("ret : 0x%x", ret);
4887 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4889 int ret = CAMERA_ERROR_NONE;
4890 camera_cli_s *pc = (camera_cli_s *)camera;
4891 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
4892 camera_msg_param param;
4893 int set_mode = (int)mode;
4895 if (!pc || !pc->cb_info) {
4896 LOGE("NULL handle");
4897 return CAMERA_ERROR_INVALID_PARAMETER;
4902 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4904 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4906 LOGD("ret : 0x%x", ret);
4912 int camera_attr_get_zoom(camera_h camera, int *zoom)
4914 int ret = CAMERA_ERROR_NONE;
4915 camera_cli_s *pc = (camera_cli_s *)camera;
4916 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4918 if (!pc || !pc->cb_info || !zoom) {
4919 LOGE("NULL pointer %p %p", pc, zoom);
4920 return CAMERA_ERROR_INVALID_PARAMETER;
4925 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4927 if (ret == CAMERA_ERROR_NONE)
4928 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
4930 LOGD("ret : 0x%x", ret);
4936 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
4938 int ret = CAMERA_ERROR_NONE;
4939 camera_cli_s *pc = (camera_cli_s *)camera;
4940 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
4942 if (!pc || !pc->cb_info || !min || !max) {
4943 LOGE("NULL pointer %p %p %p", pc, min, max);
4944 return CAMERA_ERROR_INVALID_PARAMETER;
4949 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4951 if (ret == CAMERA_ERROR_NONE) {
4952 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
4953 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
4956 LOGD("ret : 0x%x", ret);
4962 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
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_AF_MODE;
4968 if (!pc || !pc->cb_info || !mode) {
4969 LOGE("NULL pointer %p %p", pc, mode);
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 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
4980 LOGD("ret : 0x%x", ret);
4986 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
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_EXPOSURE_MODE;
4992 if (!pc || !pc->cb_info || !mode) {
4993 LOGE("NULL pointer %p %p", pc, mode);
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 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5004 LOGD("ret : 0x%x", ret);
5010 int camera_attr_get_exposure(camera_h camera, int *value)
5012 int ret = CAMERA_ERROR_NONE;
5013 camera_cli_s *pc = (camera_cli_s *)camera;
5014 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5016 if (!pc || !pc->cb_info || !value) {
5017 LOGE("NULL pointer %p %p", pc, value);
5018 return CAMERA_ERROR_INVALID_PARAMETER;
5023 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5025 if (ret == CAMERA_ERROR_NONE)
5026 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5028 LOGD("ret : 0x%x", ret);
5034 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5036 int ret = CAMERA_ERROR_NONE;
5037 camera_cli_s *pc = (camera_cli_s *)camera;
5038 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5040 if (!pc || !pc->cb_info || !min || !max) {
5041 LOGE("NULL pointer %p %p %p", pc, min, max);
5042 return CAMERA_ERROR_INVALID_PARAMETER;
5047 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5049 if (ret == CAMERA_ERROR_NONE) {
5050 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5051 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5054 LOGD("ret : 0x%x", ret);
5060 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
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_ISO;
5066 if (!pc || !pc->cb_info || !iso) {
5067 LOGE("NULL pointer %p %p", pc, iso);
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 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5078 LOGD("ret : 0x%x", ret);
5084 int camera_attr_get_brightness(camera_h camera, int *level)
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_BRIGHTNESS;
5090 if (!pc || !pc->cb_info || !level) {
5091 LOGE("NULL pointer %p %p", pc, level);
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 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5102 LOGD("ret : 0x%x", ret);
5108 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5110 int ret = CAMERA_ERROR_NONE;
5111 camera_cli_s *pc = (camera_cli_s *)camera;
5112 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5114 if (!pc || !pc->cb_info || !min || !max) {
5115 LOGE("NULL pointer %p %p %p", pc, min, max);
5116 return CAMERA_ERROR_INVALID_PARAMETER;
5121 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5123 if (ret == CAMERA_ERROR_NONE) {
5124 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5125 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5128 LOGD("ret : 0x%x", ret);
5134 int camera_attr_get_contrast(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_CONTRAST;
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_CONTRAST];
5152 LOGD("ret : 0x%x", ret);
5158 int camera_attr_get_contrast_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_CONTRAST_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_CONTRAST_RANGE][0];
5175 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5176 LOGD("min %d, max %d", *min, *max);
5179 LOGD("ret : 0x%x", ret);
5185 int camera_attr_get_hue(camera_h camera, int *level)
5187 int ret = CAMERA_ERROR_NONE;
5188 camera_cli_s *pc = (camera_cli_s *)camera;
5189 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE;
5191 if (!pc || !pc->cb_info || !level) {
5192 LOGE("NULL pointer %p %p", pc, level);
5193 return CAMERA_ERROR_INVALID_PARAMETER;
5198 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5200 if (ret == CAMERA_ERROR_NONE)
5201 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HUE];
5203 LOGD("ret : 0x%x", ret);
5209 int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
5211 int ret = CAMERA_ERROR_NONE;
5212 camera_cli_s *pc = (camera_cli_s *)camera;
5213 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE_RANGE;
5215 if (!pc || !pc->cb_info || !min || !max) {
5216 LOGE("NULL pointer %p %p %p", pc, min, max);
5217 return CAMERA_ERROR_INVALID_PARAMETER;
5222 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5224 if (ret == CAMERA_ERROR_NONE) {
5225 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][0];
5226 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][1];
5227 LOGD("min %d, max %d", *min, *max);
5230 LOGD("ret : 0x%x", ret);
5236 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5238 int ret = CAMERA_ERROR_NONE;
5239 camera_cli_s *pc = (camera_cli_s *)camera;
5240 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5242 if (!pc || !pc->cb_info || !wb) {
5243 LOGE("NULL pointer %p %p", pc, wb);
5244 return CAMERA_ERROR_INVALID_PARAMETER;
5249 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5251 if (ret == CAMERA_ERROR_NONE)
5252 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5254 LOGD("ret : 0x%x", ret);
5260 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5262 int ret = CAMERA_ERROR_NONE;
5263 camera_cli_s *pc = (camera_cli_s *)camera;
5264 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5266 if (!pc || !pc->cb_info || !effect) {
5267 LOGE("NULL pointer %p %p", pc, effect);
5268 return CAMERA_ERROR_INVALID_PARAMETER;
5273 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5275 if (ret == CAMERA_ERROR_NONE)
5276 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5278 LOGD("ret : 0x%x", ret);
5284 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5286 int ret = CAMERA_ERROR_NONE;
5287 camera_cli_s *pc = (camera_cli_s *)camera;
5288 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5290 if (!pc || !pc->cb_info || !mode) {
5291 LOGE("NULL pointer %p %p", pc, mode);
5292 return CAMERA_ERROR_INVALID_PARAMETER;
5297 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5299 if (ret == CAMERA_ERROR_NONE)
5300 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5302 LOGD("ret : 0x%x", ret);
5308 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5310 int ret = CAMERA_ERROR_NONE;
5311 camera_cli_s *pc = (camera_cli_s *)camera;
5312 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5314 if (!pc || !pc->cb_info || !enable) {
5315 LOGE("NULL pointer %p %p", pc, enable);
5316 return CAMERA_ERROR_INVALID_PARAMETER;
5321 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5323 if (ret == CAMERA_ERROR_NONE)
5324 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5326 LOGD("ret : 0x%x", ret);
5332 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5334 int ret = CAMERA_ERROR_NONE;
5335 camera_cli_s *pc = (camera_cli_s *)camera;
5336 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5338 if (!pc || !pc->cb_info || !description) {
5339 LOGE("NULL pointer %p %p", pc, description);
5340 return CAMERA_ERROR_INVALID_PARAMETER;
5345 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5347 if (ret == CAMERA_ERROR_NONE)
5348 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5350 LOGD("ret : 0x%x", ret);
5356 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5358 int ret = CAMERA_ERROR_NONE;
5359 camera_cli_s *pc = (camera_cli_s *)camera;
5360 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5362 if (!pc || !pc->cb_info || !orientation) {
5363 LOGE("NULL pointer %p %p", pc, orientation);
5364 return CAMERA_ERROR_INVALID_PARAMETER;
5369 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5371 if (ret == CAMERA_ERROR_NONE)
5372 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5374 LOGD("ret : 0x%x", ret);
5380 int camera_attr_get_tag_software(camera_h camera, char **software)
5382 int ret = CAMERA_ERROR_NONE;
5383 camera_cli_s *pc = (camera_cli_s *)camera;
5384 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5386 if (!pc || !pc->cb_info || !software) {
5387 LOGE("NULL pointer %p %p", pc, software);
5388 return CAMERA_ERROR_INVALID_PARAMETER;
5393 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5395 if (ret == CAMERA_ERROR_NONE)
5396 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5398 LOGD("ret : 0x%x", ret);
5404 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5406 int ret = CAMERA_ERROR_NONE;
5407 camera_cli_s *pc = (camera_cli_s *)camera;
5408 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5410 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5411 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5412 return CAMERA_ERROR_INVALID_PARAMETER;
5417 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5419 if (ret == CAMERA_ERROR_NONE) {
5420 *latitude = pc->cb_info->get_geotag[0];
5421 *longitude = pc->cb_info->get_geotag[1];
5422 *altitude = pc->cb_info->get_geotag[2];
5425 LOGD("ret : 0x%x", ret);
5431 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5433 int ret = CAMERA_ERROR_NONE;
5434 camera_cli_s *pc = (camera_cli_s *)camera;
5435 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5437 if (!pc || !pc->cb_info || !mode) {
5438 LOGE("NULL pointer %p %p", pc, mode);
5439 return CAMERA_ERROR_INVALID_PARAMETER;
5444 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5446 if (ret == CAMERA_ERROR_NONE)
5447 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5449 LOGD("ret : 0x%x", ret);
5455 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5457 int ret = CAMERA_ERROR_NONE;
5458 int get_flash_state = 0;
5461 LOGE("NULL pointer");
5462 return CAMERA_ERROR_INVALID_PARAMETER;
5465 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5466 (int)device, "get_flash_state", &get_flash_state);
5468 if (ret == CAMERA_ERROR_NONE) {
5469 *state = (camera_flash_state_e)get_flash_state;
5470 LOGD("flash state %d", *state);
5472 LOGE("failed 0x%x", ret);
5479 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5481 int ret = CAMERA_ERROR_NONE;
5482 camera_cli_s *pc = (camera_cli_s *)camera;
5483 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5485 if (!pc || !pc->cb_info || !foreach_cb) {
5486 LOGE("NULL pointer %p %p", pc, foreach_cb);
5487 return CAMERA_ERROR_INVALID_PARAMETER;
5492 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5493 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5495 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5497 LOGD("ret : 0x%x", ret);
5503 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5505 int ret = CAMERA_ERROR_NONE;
5506 camera_cli_s *pc = (camera_cli_s *)camera;
5507 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5509 if (!pc || !pc->cb_info || !foreach_cb) {
5510 LOGE("NULL pointer %p %p", pc, foreach_cb);
5511 return CAMERA_ERROR_INVALID_PARAMETER;
5516 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5517 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5519 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5521 LOGD("ret : 0x%x", ret);
5527 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5529 int ret = CAMERA_ERROR_NONE;
5530 camera_cli_s *pc = (camera_cli_s *)camera;
5531 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5533 if (!pc || !pc->cb_info || !foreach_cb) {
5534 LOGE("NULL pointer %p %p", pc, foreach_cb);
5535 return CAMERA_ERROR_INVALID_PARAMETER;
5540 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5541 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5543 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5545 LOGD("ret : 0x%x", ret);
5551 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5553 int ret = CAMERA_ERROR_NONE;
5554 camera_cli_s *pc = (camera_cli_s *)camera;
5555 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5557 if (!pc || !pc->cb_info || !foreach_cb) {
5558 LOGE("NULL pointer %p %p", pc, foreach_cb);
5559 return CAMERA_ERROR_INVALID_PARAMETER;
5564 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5565 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5567 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5569 LOGD("ret : 0x%x", ret);
5575 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5577 int ret = CAMERA_ERROR_NONE;
5578 camera_cli_s *pc = (camera_cli_s *)camera;
5579 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5581 if (!pc || !pc->cb_info || !foreach_cb) {
5582 LOGE("NULL pointer %p %p", pc, foreach_cb);
5583 return CAMERA_ERROR_INVALID_PARAMETER;
5588 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5589 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5591 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5593 LOGD("ret : 0x%x", ret);
5599 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5601 int ret = CAMERA_ERROR_NONE;
5602 camera_cli_s *pc = (camera_cli_s *)camera;
5603 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5605 if (!pc || !pc->cb_info || !foreach_cb) {
5606 LOGE("NULL pointer %p %p", pc, foreach_cb);
5607 return CAMERA_ERROR_INVALID_PARAMETER;
5612 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5613 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5615 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5617 LOGD("ret : 0x%x", ret);
5623 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5625 int ret = CAMERA_ERROR_NONE;
5626 camera_cli_s *pc = (camera_cli_s *)camera;
5627 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5629 if (!pc || !pc->cb_info || !foreach_cb) {
5630 LOGE("NULL pointer %p %p", pc, foreach_cb);
5631 return CAMERA_ERROR_INVALID_PARAMETER;
5636 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5637 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5639 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5641 LOGD("ret : 0x%x", ret);
5647 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5649 int ret = CAMERA_ERROR_NONE;
5650 camera_cli_s *pc = (camera_cli_s *)camera;
5651 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5653 if (!pc || !pc->cb_info || !foreach_cb) {
5654 LOGE("NULL pointer %p %p", pc, foreach_cb);
5655 return CAMERA_ERROR_INVALID_PARAMETER;
5660 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5661 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5663 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5665 LOGD("Enter, handle :%x", pc->remote_handle);
5671 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)
5673 int ret = CAMERA_ERROR_NONE;
5674 camera_cli_s *pc = (camera_cli_s *)camera;
5675 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5676 camera_msg_param param;
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_FPS_BY_RESOLUTION] = foreach_cb;
5687 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5689 value = (width << 16) | height;
5690 CAMERA_MSG_PARAM_SET(param, INT, value);
5692 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5694 LOGD("ret : 0x%x", ret);
5700 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5702 int ret = CAMERA_ERROR_NONE;
5703 camera_cli_s *pc = (camera_cli_s *)camera;
5704 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5706 if (!pc || !pc->cb_info || !foreach_cb) {
5707 LOGE("NULL pointer %p %p", pc, foreach_cb);
5708 return CAMERA_ERROR_INVALID_PARAMETER;
5713 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5714 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5716 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5718 LOGD("ret : 0x%x", ret);
5724 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5726 int ret = CAMERA_ERROR_NONE;
5727 camera_cli_s *pc = (camera_cli_s *)camera;
5728 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5730 if (!pc || !pc->cb_info || !foreach_cb) {
5731 LOGE("NULL pointer %p %p", pc, foreach_cb);
5732 return CAMERA_ERROR_INVALID_PARAMETER;
5737 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5738 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5740 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5742 LOGD("ret : 0x%x", ret);
5748 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5750 int ret = CAMERA_ERROR_NONE;
5751 camera_cli_s *pc = (camera_cli_s *)camera;
5752 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5753 camera_msg_param param;
5754 int set_rotation = (int)rotation;
5756 if (!pc || !pc->cb_info) {
5757 LOGE("NULL handle");
5758 return CAMERA_ERROR_INVALID_PARAMETER;
5763 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5765 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5767 LOGD("ret : 0x%x", ret);
5773 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5775 int ret = CAMERA_ERROR_NONE;
5776 camera_cli_s *pc = (camera_cli_s *)camera;
5777 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5779 if (!pc || !pc->cb_info || !rotation) {
5780 LOGE("NULL pointer %p %p", pc, rotation);
5781 return CAMERA_ERROR_INVALID_PARAMETER;
5786 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5788 if (ret == CAMERA_ERROR_NONE)
5789 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5791 LOGD("ret : 0x%x", ret);
5797 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5799 int ret = CAMERA_ERROR_NONE;
5800 camera_cli_s *pc = (camera_cli_s *)camera;
5801 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5802 camera_msg_param param;
5803 int set_flip = (int)flip;
5805 if (!pc || !pc->cb_info) {
5806 LOGE("NULL handle");
5807 return CAMERA_ERROR_INVALID_PARAMETER;
5812 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5814 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5816 LOGD("ret : 0x%x", ret);
5822 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5824 int ret = CAMERA_ERROR_NONE;
5825 camera_cli_s *pc = (camera_cli_s *)camera;
5826 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5828 if (!pc || !pc->cb_info || !flip) {
5829 LOGE("NULL pointer %p %p", pc, flip);
5830 return CAMERA_ERROR_INVALID_PARAMETER;
5835 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5837 if (ret == CAMERA_ERROR_NONE)
5838 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5840 LOGD("ret : 0x%x", ret);
5845 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5847 int ret = CAMERA_ERROR_NONE;
5848 camera_cli_s *pc = (camera_cli_s *)camera;
5849 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5850 camera_msg_param param;
5851 int set_mode = (int)mode;
5853 if (!pc || !pc->cb_info) {
5854 LOGE("NULL handle");
5855 return CAMERA_ERROR_INVALID_PARAMETER;
5860 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5862 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5864 LOGD("ret : 0x%x", ret);
5870 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5872 int ret = CAMERA_ERROR_NONE;
5873 camera_cli_s *pc = (camera_cli_s *)camera;
5874 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5876 if (!pc || !pc->cb_info || !mode) {
5877 LOGE("NULL pointer %p %p", pc, mode);
5878 return CAMERA_ERROR_INVALID_PARAMETER;
5883 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5885 if (ret == CAMERA_ERROR_NONE)
5886 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
5888 LOGD("ret : 0x%x", ret);
5894 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5896 int ret = CAMERA_ERROR_NONE;
5897 camera_cli_s *pc = (camera_cli_s *)camera;
5898 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
5900 if (!pc || !pc->cb_info) {
5901 LOGE("NULL handle");
5902 return CAMERA_ERROR_INVALID_PARAMETER;
5907 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5910 LOGE("error is occurred 0x%x", ret);
5914 LOGD("ret : %d", ret);
5920 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
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_SET_HDR_CAPTURE_PROGRESS_CB;
5926 if (!pc || !pc->cb_info) {
5927 LOGE("NULL handle");
5928 return CAMERA_ERROR_INVALID_PARAMETER;
5933 if (!camera_attr_is_supported_hdr_capture(camera)) {
5934 LOGE("HDR not supported");
5935 return CAMERA_ERROR_NOT_SUPPORTED;
5939 LOGE("NULL callback");
5940 return CAMERA_ERROR_INVALID_PARAMETER;
5943 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5945 if (ret == CAMERA_ERROR_NONE) {
5946 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5948 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5949 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5951 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5954 LOGD("ret : 0x%x", ret);
5960 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5962 int ret = CAMERA_ERROR_NONE;
5963 camera_cli_s *pc = (camera_cli_s *)camera;
5964 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5966 if (!pc || !pc->cb_info) {
5967 LOGE("NULL handle");
5968 return CAMERA_ERROR_INVALID_PARAMETER;
5973 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5975 if (ret == CAMERA_ERROR_NONE) {
5976 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5978 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5979 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5981 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5984 LOGD("ret : 0x%x", ret);
5990 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
5992 int ret = CAMERA_ERROR_NONE;
5993 camera_cli_s *pc = (camera_cli_s *)camera;
5994 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
5995 camera_msg_param param;
5996 int set_enable = (int)enable;
5998 if (!pc || !pc->cb_info) {
5999 LOGE("NULL handle");
6000 return CAMERA_ERROR_INVALID_PARAMETER;
6005 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6007 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6009 LOGD("ret : 0x%x", ret);
6015 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6017 int ret = CAMERA_ERROR_NONE;
6018 camera_cli_s *pc = (camera_cli_s *)camera;
6019 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6021 if (!pc || !pc->cb_info || !enabled) {
6022 LOGE("NULL pointer %p %p", pc, enabled);
6023 return CAMERA_ERROR_INVALID_PARAMETER;
6028 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6030 if (ret == CAMERA_ERROR_NONE)
6031 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6033 LOGD("ret : 0x%x", ret);
6039 bool camera_attr_is_supported_anti_shake(camera_h camera)
6041 int ret = CAMERA_ERROR_NONE;
6042 camera_cli_s *pc = (camera_cli_s *)camera;
6043 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6045 if (!pc || !pc->cb_info) {
6046 LOGE("NULL handle");
6047 return CAMERA_ERROR_INVALID_PARAMETER;
6052 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6055 LOGE("error is occurred 0x%x", ret);
6059 LOGD("ret : %d", ret);
6065 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
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_ENABLE_VIDEO_STABILIZATION;
6070 camera_msg_param param;
6071 int set_enable = (int)enable;
6073 if (!pc || !pc->cb_info) {
6074 LOGE("NULL handle");
6075 return CAMERA_ERROR_INVALID_PARAMETER;
6080 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6082 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6084 LOGD("ret : 0x%x", ret);
6090 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6092 int ret = CAMERA_ERROR_NONE;
6093 camera_cli_s *pc = (camera_cli_s *)camera;
6094 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6096 if (!pc || !pc->cb_info || !enabled) {
6097 LOGE("NULL pointer %p %p", pc, enabled);
6098 return CAMERA_ERROR_INVALID_PARAMETER;
6103 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6105 if (ret == CAMERA_ERROR_NONE)
6106 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6108 LOGD("ret : 0x%x", ret);
6114 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6116 int ret = CAMERA_ERROR_NONE;
6117 camera_cli_s *pc = (camera_cli_s *)camera;
6118 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6120 if (!pc || !pc->cb_info) {
6121 LOGE("NULL handle");
6122 return CAMERA_ERROR_INVALID_PARAMETER;
6127 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6130 LOGE("error is occurred 0x%x", ret);
6134 LOGD("ret : %d", ret);
6140 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
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_ENABLE_AUTO_CONTRAST;
6145 camera_msg_param param;
6146 int set_enable = (int)enable;
6148 if (!pc || !pc->cb_info) {
6149 LOGE("NULL handle");
6150 return CAMERA_ERROR_INVALID_PARAMETER;
6155 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6157 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6159 LOGD("ret : 0x%x", ret);
6165 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6167 int ret = CAMERA_ERROR_NONE;
6168 camera_cli_s *pc = (camera_cli_s *)camera;
6169 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6171 if (!pc || !pc->cb_info || !enabled) {
6172 LOGE("NULL pointer %p %p", pc, enabled);
6173 return CAMERA_ERROR_INVALID_PARAMETER;
6178 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6180 if (ret == CAMERA_ERROR_NONE)
6181 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6183 LOGD("ret : 0x%x", ret);
6189 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6191 int ret = CAMERA_ERROR_NONE;
6192 camera_cli_s *pc = (camera_cli_s *)camera;
6193 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6195 if (!pc || !pc->cb_info) {
6196 LOGE("NULL handle");
6197 return CAMERA_ERROR_INVALID_PARAMETER;
6202 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6205 LOGE("error is occurred 0x%x", ret);
6209 LOGD("ret : %d", ret);
6215 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
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_DISABLE_SHUTTER_SOUND;
6220 camera_msg_param param;
6221 int set_disable = (int)disable;
6223 if (!pc || !pc->cb_info) {
6224 LOGE("NULL handle");
6225 return CAMERA_ERROR_INVALID_PARAMETER;
6230 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6232 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6234 LOGD("ret : 0x%x", ret);
6240 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6242 int ret = CAMERA_ERROR_NONE;
6243 camera_cli_s *pc = (camera_cli_s *)camera;
6244 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6245 camera_msg_param param;
6246 int set_move_type = (int)move_type;
6249 if (!pc || !pc->cb_info) {
6250 LOGE("NULL handle");
6251 return CAMERA_ERROR_INVALID_PARAMETER;
6256 value = (set_move_type << 16) | pan_step;
6257 CAMERA_MSG_PARAM_SET(param, INT, value);
6259 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6261 LOGD("ret : 0x%x", ret);
6267 int camera_attr_get_pan(camera_h camera, int *pan_step)
6269 int ret = CAMERA_ERROR_NONE;
6270 camera_cli_s *pc = (camera_cli_s *)camera;
6271 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6273 if (!pc || !pc->cb_info || !pan_step) {
6274 LOGE("NULL pointer %p %p", pc, pan_step);
6275 return CAMERA_ERROR_INVALID_PARAMETER;
6280 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6282 if (ret == CAMERA_ERROR_NONE)
6283 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6285 LOGD("ret : 0x%x", ret);
6291 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6293 int ret = CAMERA_ERROR_NONE;
6294 camera_cli_s *pc = (camera_cli_s *)camera;
6295 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6297 if (!pc || !pc->cb_info || !min || !max) {
6298 LOGE("NULL pointer %p %p %p", pc, min, max);
6299 return CAMERA_ERROR_INVALID_PARAMETER;
6304 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6306 if (ret == CAMERA_ERROR_NONE) {
6307 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6308 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6311 LOGD("ret : 0x%x", ret);
6317 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_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_SET_TILT;
6322 camera_msg_param param;
6323 int set_move_type = (int)move_type;
6326 if (!pc || !pc->cb_info) {
6327 LOGE("NULL handle");
6328 return CAMERA_ERROR_INVALID_PARAMETER;
6333 value = (set_move_type << 16) | tilt_step;
6334 CAMERA_MSG_PARAM_SET(param, INT, value);
6336 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6338 LOGD("ret : 0x%x", ret);
6344 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6346 int ret = CAMERA_ERROR_NONE;
6347 camera_cli_s *pc = (camera_cli_s *)camera;
6348 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6350 if (!pc || !pc->cb_info || !tilt_step) {
6351 LOGE("NULL pointer %p %p", pc, tilt_step);
6352 return CAMERA_ERROR_INVALID_PARAMETER;
6357 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6359 if (ret == CAMERA_ERROR_NONE)
6360 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6362 LOGD("ret : 0x%x", ret);
6368 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6370 int ret = CAMERA_ERROR_NONE;
6371 camera_cli_s *pc = (camera_cli_s *)camera;
6372 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6374 if (!pc || !pc->cb_info || !min || !max) {
6375 LOGE("NULL pointer %p %p %p", pc, min, max);
6376 return CAMERA_ERROR_INVALID_PARAMETER;
6381 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6383 if (ret == CAMERA_ERROR_NONE) {
6384 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6385 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6388 LOGD("ret : 0x%x", ret);
6394 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
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_SET_PTZ_TYPE;
6399 camera_msg_param param;
6400 int set_ptz_type = (int)ptz_type;
6402 if (!pc || !pc->cb_info) {
6403 LOGE("NULL handle");
6404 return CAMERA_ERROR_INVALID_PARAMETER;
6409 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6411 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6413 LOGD("ret : 0x%x", ret);
6419 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6421 int ret = CAMERA_ERROR_NONE;
6422 camera_cli_s *pc = (camera_cli_s *)camera;
6423 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6425 if (!pc || !pc->cb_info || !foreach_cb) {
6426 LOGE("NULL pointer %p %p", pc, foreach_cb);
6427 return CAMERA_ERROR_INVALID_PARAMETER;
6432 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6433 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6435 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6437 LOGD("ret : 0x%x", ret);
6443 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6445 int ret = CAMERA_ERROR_NONE;
6446 camera_cli_s *pc = (camera_cli_s *)camera;
6447 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6448 int set_display_roi_area[4] = {x, y, width, height};
6453 if (!pc || !pc->cb_info) {
6454 LOGE("NULL handle");
6455 return CAMERA_ERROR_INVALID_PARAMETER;
6460 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6461 ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
6462 if (ret != MM_ERROR_NONE) {
6463 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6464 return CAMERA_ERROR_INVALID_OPERATION;
6468 length = sizeof(set_display_roi_area) / sizeof(int) + \
6469 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6471 msg = muse_core_msg_new(api,
6472 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6475 LOGE("msg creation failed: api %d", api);
6476 return CAMERA_ERROR_OUT_OF_MEMORY;
6479 if (pc->cb_info->is_server_connected) {
6480 __camera_update_api_waiting(pc->cb_info, api, 1);
6482 g_mutex_lock(&pc->cb_info->fd_lock);
6483 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
6484 g_mutex_unlock(&pc->cb_info->fd_lock);
6488 LOGE("message send failed");
6489 ret = CAMERA_ERROR_INVALID_OPERATION;
6491 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6494 __camera_update_api_waiting(pc->cb_info, api, -1);
6496 muse_core_msg_free(msg);
6498 LOGD("ret : 0x%x", ret);
6504 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6506 camera_cli_s *pc = (camera_cli_s *)camera;
6507 int ret = CAMERA_ERROR_NONE;
6508 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6510 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6511 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6512 return CAMERA_ERROR_INVALID_PARAMETER;
6517 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6519 if (ret == CAMERA_ERROR_NONE) {
6520 *x = pc->cb_info->get_display_roi_area[0];
6521 *y = pc->cb_info->get_display_roi_area[1];
6522 *width = pc->cb_info->get_display_roi_area[2];
6523 *height = pc->cb_info->get_display_roi_area[3];
6526 LOGD("ret : 0x%x", ret);
6532 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6534 int ret = CAMERA_ERROR_NONE;
6535 int get_device_state = 0;
6538 LOGE("NULL pointer");
6539 return CAMERA_ERROR_INVALID_PARAMETER;
6542 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6543 (int)device, "get_device_state", &get_device_state);
6545 if (ret == CAMERA_ERROR_NONE) {
6546 *state = (camera_device_state_e)get_device_state;
6547 LOGD("device state %d", *state);
6549 LOGE("failed 0x%x", ret);
6556 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6558 int ret = CAMERA_ERROR_NONE;
6559 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6560 camera_cb_info *info = NULL;
6562 if (!callback || !cb_id) {
6563 LOGE("invalid pointer %p %p", callback, cb_id);
6564 return CAMERA_ERROR_INVALID_PARAMETER;
6567 /* check camera support */
6568 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6569 if (ret != CAMERA_ERROR_NONE) {
6570 LOGE("get device state failed");
6574 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6576 info = g_new0(camera_cb_info, 1);
6578 LOGE("info failed");
6579 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6583 info->id = ++g_cam_dev_state_changed_cb_id;
6584 info->callback = (void *)callback;
6585 info->user_data = user_data;
6589 /* subscribe dbus signal for camera state change */
6590 if (!g_cam_dev_state_changed_cb_conn) {
6591 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6592 if (!g_cam_dev_state_changed_cb_conn) {
6593 LOGE("failed to get gdbus connection");
6594 ret = CAMERA_ERROR_INVALID_OPERATION;
6598 LOGD("subscribe signal %s - %s - %s",
6599 MM_CAMCORDER_DBUS_OBJECT,
6600 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6601 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6603 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6604 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6605 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6606 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6607 LOGE("failed to get gdbus connection");
6608 ret = CAMERA_ERROR_INVALID_OPERATION;
6612 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6615 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6617 LOGD("callback id %d", info->id);
6620 if (ret != CAMERA_ERROR_NONE) {
6626 if (g_cam_dev_state_changed_cb_conn) {
6627 g_object_unref(g_cam_dev_state_changed_cb_conn);
6628 g_cam_dev_state_changed_cb_conn = NULL;
6632 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6638 int camera_remove_device_state_changed_cb(int cb_id)
6640 int ret = CAMERA_ERROR_NONE;
6641 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6642 GList *tmp_list = NULL;
6643 camera_cb_info *info = NULL;
6645 /* check camera support */
6646 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6647 if (ret != CAMERA_ERROR_NONE) {
6648 LOGE("get device state failed");
6652 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6654 if (!g_cam_dev_state_changed_cb_list) {
6655 LOGE("there is no callback info");
6656 ret = CAMERA_ERROR_INVALID_OPERATION;
6660 tmp_list = g_cam_dev_state_changed_cb_list;
6663 info = tmp_list->data;
6664 tmp_list = tmp_list->next;
6671 if (info->id == cb_id) {
6672 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6677 if (!g_cam_dev_state_changed_cb_list) {
6678 /* no remained callback */
6679 if (g_cam_dev_state_changed_cb_conn) {
6680 /* unsubscribe signal */
6681 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6682 g_cam_dev_state_changed_cb_subscribe_id = 0;
6684 /* unref connection */
6685 g_object_unref(g_cam_dev_state_changed_cb_conn);
6686 g_cam_dev_state_changed_cb_conn = NULL;
6690 LOGD("id %d callback removed", cb_id);
6691 ret = CAMERA_ERROR_NONE;
6697 LOGE("id %d callback not found", cb_id);
6698 ret = CAMERA_ERROR_INVALID_PARAMETER;
6701 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);