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;
746 case MM_PIXEL_FORMAT_NV16:
747 *out_format = TBM_FORMAT_NV16;
749 case MM_PIXEL_FORMAT_NV21:
750 *out_format = TBM_FORMAT_NV21;
752 case MM_PIXEL_FORMAT_YUYV:
753 *out_format = TBM_FORMAT_YUYV;
755 case MM_PIXEL_FORMAT_UYVY:
756 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
757 *out_format = TBM_FORMAT_UYVY;
759 case MM_PIXEL_FORMAT_422P:
760 *out_format = TBM_FORMAT_YUV422;
762 case MM_PIXEL_FORMAT_I420:
763 *out_format = TBM_FORMAT_YUV420;
765 case MM_PIXEL_FORMAT_YV12:
766 *out_format = TBM_FORMAT_YVU420;
768 case MM_PIXEL_FORMAT_RGB565:
769 *out_format = TBM_FORMAT_RGB565;
771 case MM_PIXEL_FORMAT_RGB888:
772 *out_format = TBM_FORMAT_RGB888;
774 case MM_PIXEL_FORMAT_RGBA:
775 *out_format = TBM_FORMAT_RGBA8888;
777 case MM_PIXEL_FORMAT_ARGB:
778 *out_format = TBM_FORMAT_ARGB8888;
781 LOGE("invalid in_format %d", in_format);
782 return CAMERA_ERROR_INVALID_PARAMETER;
786 return CAMERA_ERROR_NONE;
790 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
792 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
793 in_format >= MM_PIXEL_FORMAT_NUM ||
795 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
796 return CAMERA_ERROR_INVALID_PARAMETER;
800 case MM_PIXEL_FORMAT_NV12:
801 case MM_PIXEL_FORMAT_NV12T:
802 *mimetype = MEDIA_FORMAT_NV12;
805 case MM_PIXEL_FORMAT_NV16:
806 *mimetype = MEDIA_FORMAT_NV16;
808 case MM_PIXEL_FORMAT_NV21:
809 *mimetype = MEDIA_FORMAT_NV21;
811 case MM_PIXEL_FORMAT_YUYV:
812 *mimetype = MEDIA_FORMAT_YUYV;
814 case MM_PIXEL_FORMAT_UYVY:
815 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
816 *mimetype = MEDIA_FORMAT_UYVY;
818 case MM_PIXEL_FORMAT_422P:
819 *mimetype = MEDIA_FORMAT_422P;
821 case MM_PIXEL_FORMAT_I420:
822 *mimetype = MEDIA_FORMAT_I420;
824 case MM_PIXEL_FORMAT_YV12:
825 *mimetype = MEDIA_FORMAT_YV12;
827 case MM_PIXEL_FORMAT_RGB565:
828 *mimetype = MEDIA_FORMAT_RGB565;
830 case MM_PIXEL_FORMAT_RGB888:
831 *mimetype = MEDIA_FORMAT_RGB888;
833 case MM_PIXEL_FORMAT_RGBA:
834 *mimetype = MEDIA_FORMAT_RGBA;
836 case MM_PIXEL_FORMAT_ARGB:
837 *mimetype = MEDIA_FORMAT_ARGB;
840 LOGE("invalid in_format %d", in_format);
841 return CAMERA_ERROR_INVALID_PARAMETER;
845 return CAMERA_ERROR_NONE;
848 static void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_key,
849 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame)
852 unsigned char *buf_pos = NULL;
854 if (stream == NULL || buffer_bo_handle == NULL || frame == NULL) {
855 LOGE("invalid parameter - stream:%p, buffer_bo_handle:%p", stream, buffer_bo_handle);
860 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
861 frame->format = MM_PIXEL_FORMAT_UYVY;
863 frame->format = stream->format;
865 frame->width = stream->width;
866 frame->height = stream->height;
867 frame->timestamp = stream->timestamp;
868 frame->num_of_planes = stream->num_planes;
870 if (num_buffer_key == 0) {
873 if (!data_bo_handle || !data_bo_handle->ptr) {
874 LOGE("NULL pointer");
878 buf_pos = data_bo_handle->ptr;
880 if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) {
881 frame->data.encoded_plane.data = buf_pos;
882 frame->data.encoded_plane.size = stream->data.encoded.length_data;
883 total_size = stream->data.encoded.length_data;
884 } else if (stream->format == MM_PIXEL_FORMAT_INVZ) {
885 frame->data.depth_plane.data = buf_pos;
886 frame->data.depth_plane.size = stream->data.depth.length_data;
887 total_size = stream->data.depth.length_data;
888 } else if (stream->format == MM_PIXEL_FORMAT_RGBA ||
889 stream->format == MM_PIXEL_FORMAT_ARGB) {
890 frame->data.rgb_plane.data = buf_pos;
891 frame->data.rgb_plane.size = stream->data.rgb.length_data;
892 total_size = stream->data.rgb.length_data;
894 switch (stream->num_planes) {
896 frame->data.single_plane.yuv = buf_pos;
897 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
898 total_size = stream->data.yuv420.length_yuv;
901 frame->data.double_plane.y = buf_pos;
902 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
903 buf_pos += stream->data.yuv420sp.length_y;
904 frame->data.double_plane.uv = buf_pos;
905 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
906 total_size = stream->data.yuv420sp.length_y + \
907 stream->data.yuv420sp.length_uv;
910 frame->data.triple_plane.y = buf_pos;
911 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
912 buf_pos += stream->data.yuv420p.length_y;
913 frame->data.triple_plane.u = buf_pos;
914 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
915 buf_pos += stream->data.yuv420p.length_u;
916 frame->data.triple_plane.v = buf_pos;
917 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
918 total_size = stream->data.yuv420p.length_y + \
919 stream->data.yuv420p.length_u + \
920 stream->data.yuv420p.length_v;
929 switch (stream->num_planes) {
932 frame->data.single_plane.yuv = buffer_bo_handle[0].ptr;
933 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
934 total_size = stream->data.yuv420.length_yuv;
938 frame->data.double_plane.y = buffer_bo_handle[0].ptr;
939 if (stream->num_planes == (unsigned int)num_buffer_key)
940 frame->data.double_plane.uv = buffer_bo_handle[1].ptr;
942 frame->data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
943 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
944 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
945 total_size = stream->data.yuv420sp.length_y + \
946 stream->data.yuv420sp.length_uv;
950 frame->data.triple_plane.y = buffer_bo_handle[0].ptr;
951 if (stream->num_planes == (unsigned int)num_buffer_key) {
952 frame->data.triple_plane.u = buffer_bo_handle[1].ptr;
953 frame->data.triple_plane.v = buffer_bo_handle[2].ptr;
955 frame->data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y;
956 frame->data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u;
958 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
959 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
960 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
961 total_size = stream->data.yuv420p.length_y + \
962 stream->data.yuv420p.length_u + \
963 stream->data.yuv420p.length_v;
972 LOGD("format %d, %dx%d, size %d plane num %d",
973 frame.format, frame.width, frame.height, total_size, frame.num_of_planes);
979 static int _camera_media_packet_data_create(int tbm_key, int num_buffer_key, tbm_bo bo,
980 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
983 int ret = CAMERA_ERROR_NONE;
984 camera_media_packet_data *tmp_mp_data = NULL;
986 if (*mp_data == NULL) {
987 tmp_mp_data = g_new0(camera_media_packet_data, 1);
989 tmp_mp_data->tbm_key = tbm_key;
990 tmp_mp_data->num_buffer_key = num_buffer_key;
991 tmp_mp_data->bo = bo;
992 tmp_mp_data->data_bo = data_bo;
993 tmp_mp_data->ref_cnt++;
995 for (i = 0 ; i < num_buffer_key ; i++)
996 tmp_mp_data->buffer_bo[i] = buffer_bo[i];
998 *mp_data = tmp_mp_data;
999 /*LOGD("mp_data %p", tmp_mp_data);*/
1001 ret = CAMERA_ERROR_OUT_OF_MEMORY;
1002 LOGE("failed to alloc media packet data");
1005 ((camera_media_packet_data *)*mp_data)->ref_cnt++;
1011 static void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
1015 camera_msg_param param;
1017 if (!mp_data || !cb_info) {
1018 LOGE("NULL pointer %p %p", mp_data, cb_info);
1022 if (mp_data->ref_cnt > 1) {
1024 LOGD("ref count %d", mp_data->ref_cnt);
1026 /* release imported bo */
1027 for (i = 0 ; i < mp_data->num_buffer_key ; i++) {
1028 tbm_bo_unref(mp_data->buffer_bo[i]);
1029 mp_data->buffer_bo[i] = NULL;
1033 _camera_release_imported_bo(&mp_data->bo);
1034 _camera_release_imported_bo(&mp_data->data_bo);
1037 tbm_key = mp_data->tbm_key;
1039 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1041 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1050 static int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
1051 camera_media_packet_data *mp_data, media_packet_h *packet)
1053 media_packet_h pkt = NULL;
1054 bool make_pkt_fmt = false;
1055 tbm_surface_h tsurf = NULL;
1056 tbm_surface_info_s tsurf_info;
1057 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
1058 uint32_t bo_format = 0;
1061 int num_buffer_key = 0;
1062 tbm_bo *buffer_bo = NULL;
1064 if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) {
1065 LOGE("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p",
1066 cb_info, stream, mp_data, packet);
1067 return CAMERA_ERROR_INVALID_PARAMETER;
1070 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
1071 buffer_bo = mp_data->buffer_bo;
1072 num_buffer_key = mp_data->num_buffer_key;
1074 /* create tbm surface */
1075 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
1076 tsurf_info.planes[i].stride = stream->stride[i];
1078 /* get tbm surface format */
1079 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
1080 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
1082 if (ret == CAMERA_ERROR_NONE) {
1083 tsurf_info.width = stream->width;
1084 tsurf_info.height = stream->height;
1085 tsurf_info.format = bo_format;
1086 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
1087 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
1089 if (num_buffer_key > 0) {
1090 switch (bo_format) {
1091 case TBM_FORMAT_NV12:
1092 case TBM_FORMAT_NV21:
1093 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1094 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
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.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1101 case TBM_FORMAT_YUV420:
1102 case TBM_FORMAT_YVU420:
1103 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1104 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1105 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
1106 tsurf_info.planes[0].offset = 0;
1107 if (num_buffer_key == 1) {
1108 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1109 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1111 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1113 case TBM_FORMAT_UYVY:
1114 case TBM_FORMAT_YUYV:
1115 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
1116 tsurf_info.planes[0].offset = 0;
1117 tsurf_info.size = tsurf_info.planes[0].size;
1124 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_key);
1125 } else if (mp_data->data_bo) {
1127 switch (bo_format) {
1128 case TBM_FORMAT_NV12:
1129 case TBM_FORMAT_NV21:
1130 tsurf_info.planes[0].size = stream->width * stream->height;
1131 tsurf_info.planes[1].size = (tsurf_info.planes[0].size) >> 1;
1132 tsurf_info.planes[0].offset = 0;
1133 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1134 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1136 case TBM_FORMAT_YUV420:
1137 case TBM_FORMAT_YVU420:
1138 tsurf_info.planes[0].size = stream->width * stream->height;
1139 tsurf_info.planes[1].size = (stream->width >> 1) * (stream->height >> 1);
1140 tsurf_info.planes[2].size = tsurf_info.planes[1].size;
1141 tsurf_info.planes[0].offset = 0;
1142 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1143 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1144 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1146 case TBM_FORMAT_UYVY:
1147 case TBM_FORMAT_YUYV:
1148 tsurf_info.planes[0].size = (stream->width * stream->height) << 1;
1149 tsurf_info.planes[0].offset = 0;
1150 tsurf_info.size = tsurf_info.planes[0].size;
1156 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1);
1159 /*LOGD("tbm surface %p", tsurf);*/
1163 /* check media packet format */
1164 if (cb_info->pkt_fmt) {
1165 int pkt_fmt_width = 0;
1166 int pkt_fmt_height = 0;
1167 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
1169 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
1170 if (pkt_fmt_mimetype != mimetype ||
1171 pkt_fmt_width != stream->width ||
1172 pkt_fmt_height != stream->height) {
1173 LOGW("change fmt: current 0x%x, %dx%d",
1174 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
1175 media_format_unref(cb_info->pkt_fmt);
1176 cb_info->pkt_fmt = NULL;
1177 make_pkt_fmt = true;
1180 make_pkt_fmt = true;
1183 /* create packet format */
1185 LOGW("make new pkt_fmt - 0x%x, %dx%d", mimetype, stream->width, stream->height);
1186 ret = media_format_create(&cb_info->pkt_fmt);
1187 if (ret == MEDIA_FORMAT_ERROR_NONE) {
1188 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
1189 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
1190 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
1191 LOGW("media_format_set : 0x%x", ret);
1193 LOGW("media_format_create failed 0x%x", ret);
1197 /* create media packet */
1198 ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt,
1199 tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
1200 (void *)cb_info, &pkt);
1201 if (ret != MEDIA_PACKET_ERROR_NONE) {
1202 LOGE("media_packet_create failed 0x%x", ret);
1203 tbm_surface_destroy(tsurf);
1207 LOGE("tbm surface failed. %dx%d, format %d, num_buffer_key %d, data_bo %p",
1208 stream->width, stream->height, stream->format, num_buffer_key, mp_data->data_bo);
1212 /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
1213 /* set media packet data */
1214 ret = media_packet_set_extra(pkt, (void *)mp_data);
1215 if (ret != MEDIA_PACKET_ERROR_NONE) {
1216 LOGE("media_packet_set_extra failed");
1218 _camera_media_packet_data_release(mp_data, cb_info);
1221 media_packet_destroy(pkt);
1224 /* set timestamp : msec -> nsec */
1225 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
1226 LOGW("media_packet_set_pts failed");
1235 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
1238 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1239 camera_media_packet_data *mp_data = NULL;
1240 tbm_surface_h tsurf = NULL;
1242 if (!pkt || !cb_info) {
1243 LOGE("NULL pointer %p %p", pkt, cb_info);
1244 return MEDIA_PACKET_FINALIZE;
1247 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1248 if (ret != MEDIA_PACKET_ERROR_NONE) {
1249 LOGE("media_packet_get_extra failed 0x%x", ret);
1250 return MEDIA_PACKET_FINALIZE;
1253 /*LOGD("mp_data %p", mp_data);*/
1255 g_mutex_lock(&cb_info->mp_data_mutex);
1257 _camera_media_packet_data_release(mp_data, cb_info);
1260 g_mutex_unlock(&cb_info->mp_data_mutex);
1262 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1263 if (ret != MEDIA_PACKET_ERROR_NONE)
1264 LOGE("get tbm_surface failed 0x%x", ret);
1267 tbm_surface_destroy(tsurf);
1271 return MEDIA_PACKET_FINALIZE;
1274 static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event)
1279 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1280 LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event);
1284 /*LOGD("get camera msg %s, event %d", recv_msg, event);*/
1286 g_mutex_lock(&cb_info->user_cb_mutex[event]);
1288 if (cb_info->user_cb[event] == NULL) {
1289 if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
1290 event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
1291 event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
1292 event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1293 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1294 LOGW("NULL callback for event %d, return here", event);
1298 /* return buffer message should be sent for some events.
1299 - MUSE_CAMERA_EVENT_TYPE_PREVIEW
1300 - MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW
1301 - MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION
1302 - MUSE_CAMERA_EVENT_TYPE_CAPTURE
1307 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1313 muse_camera_msg_get(previous, recv_msg);
1314 muse_camera_msg_get(current, recv_msg);
1315 muse_camera_msg_get(by_policy, recv_msg);
1317 LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
1318 previous, current, by_policy);
1320 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1321 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1324 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1328 muse_camera_msg_get(state, recv_msg);
1330 LOGD("FOCUS state - %d", state);
1332 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1335 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1336 LOGD("CAPTURE_COMPLETED");
1337 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1339 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1340 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1341 __camera_event_handler_preview(cb_info, recv_msg);
1344 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1348 muse_camera_msg_get(percent, recv_msg);
1350 LOGD("HDR progress - %d %%", percent);
1352 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1355 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1361 muse_camera_msg_get(policy, recv_msg);
1362 muse_camera_msg_get(previous, recv_msg);
1363 muse_camera_msg_get(current, recv_msg);
1365 LOGW("INTERRUPTED - policy %d, state %d -> %d", policy, previous, current);
1367 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1368 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1371 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1376 muse_camera_msg_get(policy, recv_msg);
1377 muse_camera_msg_get(state, recv_msg);
1379 LOGW("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1381 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1382 (camera_state_e)state, cb_info->user_data[event]);
1385 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1386 __camera_event_handler_face_detection(cb_info, recv_msg);
1388 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1391 int current_state = 0;
1393 muse_camera_msg_get(error, recv_msg);
1394 muse_camera_msg_get(current_state, recv_msg);
1396 LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
1398 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1399 (camera_state_e)current_state, cb_info->user_data[event]);
1403 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1405 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1406 muse_camera_msg_get(param1, recv_msg);
1407 muse_camera_msg_get(param2, recv_msg);
1409 /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/
1411 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1412 cb_info->user_cb[event] = NULL;
1413 cb_info->user_data[event] = NULL;
1414 LOGW("stop foreach callback for event %d", event);
1417 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1419 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1421 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1423 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1425 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1427 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1429 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1431 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1433 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1435 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1437 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1439 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1441 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1444 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1446 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1447 muse_camera_msg_get(param1, recv_msg);
1449 /*LOGD("event %d SUPPORTED %d ", event, param1);*/
1451 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1452 cb_info->user_cb[event] = NULL;
1453 cb_info->user_data[event] = NULL;
1454 LOGW("stop foreach callback for event %d", event);
1458 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1459 __camera_event_handler_capture(cb_info, recv_msg);
1462 LOGW("unhandled event %d", event);
1466 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1471 static gboolean _camera_idle_event_callback(gpointer data)
1473 camera_cb_info_s *cb_info = NULL;
1474 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1476 if (cam_idle_event == NULL) {
1477 LOGE("cam_idle_event is NULL");
1482 g_mutex_lock(&g_cam_idle_event_lock);
1484 cb_info = cam_idle_event->cb_info;
1485 if (cb_info == NULL) {
1486 LOGW("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1487 g_mutex_unlock(&g_cam_idle_event_lock);
1488 goto IDLE_EVENT_CALLBACK_DONE;
1491 /* remove event from list */
1492 if (cb_info->idle_event_list)
1493 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1495 g_mutex_unlock(&g_cam_idle_event_lock);
1498 _camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
1500 IDLE_EVENT_CALLBACK_DONE:
1502 g_free(cam_idle_event);
1503 cam_idle_event = NULL;
1508 static void *_camera_msg_handler_func(gpointer data)
1512 camera_message_s *cam_msg = NULL;
1513 camera_idle_event_s *cam_idle_event = NULL;
1514 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1515 camera_cb_info_s *cb_info = NULL;
1517 if (!handler_info || !handler_info->cb_info) {
1518 LOGE("NULL handler %p", handler_info);
1522 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1523 type = handler_info->type;
1525 LOGD("t:%d start", type);
1527 g_mutex_lock(&handler_info->mutex);
1529 while (g_atomic_int_get(&handler_info->running)) {
1530 if (g_queue_is_empty(handler_info->queue)) {
1531 /*LOGD("t:%d signal wait...", type);*/
1532 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1533 /*LOGD("t:%d signal received", type);*/
1535 if (g_atomic_int_get(&handler_info->running) == 0) {
1536 LOGD("t:%d stop event thread", type);
1541 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1543 g_mutex_unlock(&handler_info->mutex);
1545 if (cam_msg == NULL) {
1546 LOGE("t:%d NULL message", type);
1547 g_mutex_lock(&handler_info->mutex);
1553 if (api < MUSE_CAMERA_API_MAX) {
1556 g_mutex_lock(&cb_info->api_mutex[api]);
1558 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1559 if (cb_info->api_waiting[api] > 0) {
1560 cb_info->api_ret[api] = ret;
1561 cb_info->api_activating[api] = 1;
1563 /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
1565 g_cond_signal(&cb_info->api_cond[api]);
1567 LOGW("no waiting for this api [%d]", api);
1570 LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1573 g_mutex_unlock(&cb_info->api_mutex[api]);
1574 } else if (api == MUSE_CAMERA_CB_EVENT) {
1575 switch (cam_msg->event_class) {
1576 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1577 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event);
1579 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1580 cam_idle_event = g_new0(camera_idle_event_s, 1);
1581 if (cam_idle_event == NULL) {
1582 LOGE("t:%d cam_idle_event alloc failed", type);
1586 cam_idle_event->event = cam_msg->event;
1587 cam_idle_event->cb_info = cb_info;
1589 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg) - 1);
1591 /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, cam_msg->event, cam_idle_event);*/
1593 g_mutex_lock(&g_cam_idle_event_lock);
1594 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1595 g_mutex_unlock(&g_cam_idle_event_lock);
1597 g_idle_add_full(G_PRIORITY_DEFAULT,
1598 (GSourceFunc)_camera_idle_event_callback,
1599 (gpointer)cam_idle_event,
1603 LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
1607 LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1613 g_mutex_lock(&handler_info->mutex);
1616 /* remove remained event */
1617 while (!g_queue_is_empty(handler_info->queue)) {
1618 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1620 LOGD("t:%d remove camera message %p", type, cam_msg);
1624 LOGW("t:%d NULL camera message", type);
1628 g_mutex_unlock(&handler_info->mutex);
1630 LOGD("t:%d return", type);
1636 static void _camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1638 camera_idle_event_s *cam_idle_event = NULL;
1641 if (cb_info == NULL) {
1642 LOGE("cb_info is NULL");
1646 g_mutex_lock(&g_cam_idle_event_lock);
1648 if (cb_info->idle_event_list == NULL) {
1649 LOGD("No remained idle event");
1650 g_mutex_unlock(&g_cam_idle_event_lock);
1654 list = cb_info->idle_event_list;
1657 cam_idle_event = list->data;
1658 list = g_list_next(list);
1660 if (!cam_idle_event) {
1661 LOGW("Fail to remove idle event. The event is NULL");
1665 if (g_idle_remove_by_data(cam_idle_event)) {
1666 LOGW("remove idle event %p done", cam_idle_event);
1668 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1670 g_free(cam_idle_event);
1671 cam_idle_event = NULL;
1676 LOGW("set NULL cb_info for event %p %d, it will be freed on idle callback",
1677 cam_idle_event, cam_idle_event->event);
1679 cam_idle_event->cb_info = NULL;
1681 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1684 g_list_free(cb_info->idle_event_list);
1685 cb_info->idle_event_list = NULL;
1687 g_mutex_unlock(&g_cam_idle_event_lock);
1693 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg)
1695 camera_message_s *cam_msg = NULL;
1697 if (!cb_info || !msg) {
1698 LOGE("NULL pointer %p %p", cb_info, msg);
1702 cam_msg = g_new0(camera_message_s, 1);
1704 LOGE("failed to alloc cam_msg for [%s]", msg);
1709 cam_msg->event = event;
1710 cam_msg->event_class = event_class;
1712 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1714 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1716 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1717 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1718 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1719 g_cond_signal(&cb_info->preview_cb_info.cond);
1720 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1721 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1722 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1723 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1724 g_cond_signal(&cb_info->capture_cb_info.cond);
1725 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1727 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1728 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1729 g_cond_signal(&cb_info->msg_handler_info.cond);
1730 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1739 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg)
1741 int ret = CAMERA_ERROR_NONE;
1745 int event_class = -1;
1749 if (!cb_info || !msg) {
1750 LOGE("invalid ptr %p %p", cb_info, msg);
1754 /*LOGD("msg [%s]", msg);*/
1756 if (!muse_camera_msg_get(api, msg)) {
1757 LOGE("failed to get camera api");
1761 if (api == MUSE_CAMERA_CB_EVENT) {
1762 if (!muse_camera_msg_get(event, msg) ||
1763 !muse_camera_msg_get(event_class, msg)) {
1764 LOGE("failed to get camera event or event_class [%s]", msg);
1768 if (!muse_camera_msg_get(api_class, msg)) {
1769 LOGE("failed to get camera api_class [%s]", msg);
1774 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1775 if (api >= MUSE_CAMERA_API_MAX) {
1776 LOGE("invalid api %d", api);
1780 if (!muse_camera_msg_get(ret, msg)) {
1781 LOGE("failed to get camera ret");
1785 g_mutex_lock(&cb_info->api_mutex[api]);
1788 case MUSE_CAMERA_API_CREATE:
1789 if (ret != CAMERA_ERROR_NONE) {
1790 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1791 LOGE("camera create error 0x%x. close client cb handler", ret);
1794 case MUSE_CAMERA_API_DESTROY:
1795 if (ret == CAMERA_ERROR_NONE) {
1796 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1797 LOGD("camera destroy done. close client cb handler");
1801 muse_camera_msg_get(get_type, msg);
1802 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1803 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1804 muse_camera_msg_get(get_index, msg);
1807 case MUSE_CAMERA_GET_TYPE_INT:
1808 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
1810 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1811 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
1812 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
1814 case MUSE_CAMERA_GET_TYPE_ARRAY:
1815 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
1816 muse_core_msg_deserialize("get_value",
1817 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
1818 LOGD("get display roi %d,%d,%dx%d",
1819 cb_info->get_display_roi_area[0],
1820 cb_info->get_display_roi_area[1],
1821 cb_info->get_display_roi_area[2],
1822 cb_info->get_display_roi_area[3]);
1824 muse_core_msg_deserialize("get_value",
1825 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
1826 LOGD("get geotag %lf, %lf, %lf",
1827 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
1830 case MUSE_CAMERA_GET_TYPE_STRING:
1831 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
1834 LOGW("unknown type %d", get_type);
1841 if (cb_info->api_waiting[api] > 0) {
1842 cb_info->api_ret[api] = ret;
1843 cb_info->api_activating[api] = 1;
1845 g_cond_signal(&cb_info->api_cond[api]);
1847 LOGW("no waiting for this api [%d]", api);
1850 g_mutex_unlock(&cb_info->api_mutex[api]);
1851 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
1852 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg);
1854 LOGW("unknown camera api %d, class %d", api, api_class);
1861 static void *_camera_msg_recv_func(gpointer data)
1863 int recv_length = 0;
1864 int single_length = 0;
1865 int remained_length = 0;
1866 char *recv_msg = NULL;
1867 char *single_msg = NULL;
1868 char *remained_msg = NULL;
1872 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
1875 LOGE("cb_info NULL");
1879 LOGD("start - fd : %d", cb_info->fd);
1881 single_msg = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
1883 LOGE("single_msg malloc failed");
1887 recv_msg = cb_info->recv_msg;
1889 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
1890 recv_length = muse_core_msg_recv(cb_info->fd, recv_msg, MUSE_MSG_MAX_LENGTH);
1891 if (recv_length <= 0) {
1892 cb_info->is_server_connected = FALSE;
1893 LOGE("receive msg failed - server disconnected");
1901 /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
1903 /* Need to split the combined entering msgs */
1904 for (cur_pos = 0 ; cur_pos < recv_length ; cur_pos++) {
1905 if (recv_msg[cur_pos] == '}') {
1906 single_length = cur_pos - prev_pos + 1;
1908 if (single_length < MUSE_CAMERA_MSG_MAX_LENGTH) {
1909 /* check remained msg */
1910 if (remained_length > 0) {
1912 strncpy(single_msg, remained_msg, remained_length);
1913 strncpy(single_msg + remained_length, recv_msg + prev_pos, single_length);
1914 single_msg[remained_length + single_length] = '\0';
1917 remained_msg = NULL;
1919 strncpy(single_msg, recv_msg + prev_pos, single_length);
1920 single_msg[single_length] = '\0';
1921 LOGE("lost msg [%s], skip...", single_msg);
1924 remained_length = 0;
1926 strncpy(single_msg, recv_msg + prev_pos, single_length);
1927 single_msg[single_length] = '\0';
1930 if (single_msg[0] == '{') {
1932 /*LOGD("splitted msg : [%s], Index : %d", single_msg, num_msg);*/
1933 /* process each message */
1934 __camera_process_msg(cb_info, single_msg);
1936 LOGE("invalid msg [%s]", single_msg);
1939 LOGE("too long message [len %d] skip...", single_length);
1942 prev_pos = cur_pos + 1;
1946 /* check incompleted message */
1947 if (recv_msg[recv_length - 1] != '}') {
1948 remained_length = recv_length - prev_pos;
1950 LOGW("incompleted message [len %d]", remained_length);
1954 remained_msg = NULL;
1957 remained_msg = (char *)malloc(remained_length + 1);
1959 strncpy(remained_msg, recv_msg + prev_pos, remained_length);
1960 remained_msg[remained_length] = '\0';
1962 LOGE("failed to alloc for remained msg");
1965 remained_length = 0;
1969 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
1971 if (!cb_info->is_server_connected) {
1972 char *error_msg = NULL;
1974 if (cb_info->fd < 0) {
1975 LOGE("fd is closed in client side");
1976 goto CB_HANDLER_EXIT;
1979 /* send error msg for server disconnection */
1980 error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
1981 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
1982 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
1986 LOGE("error_msg failed");
1987 goto CB_HANDLER_EXIT;
1990 __camera_add_msg_to_queue(cb_info,
1991 MUSE_CAMERA_CB_EVENT,
1992 MUSE_CAMERA_EVENT_TYPE_ERROR,
1993 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
1996 muse_core_msg_free(error_msg);
1999 LOGE("add error msg for service disconnection done");
2010 remained_msg = NULL;
2017 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2018 int type, const char *thread_name, camera_cb_info_s *cb_info)
2020 if (!handler_info || !thread_name || !cb_info) {
2021 LOGE("t:%d NULL %p %p %p",
2022 type, handler_info, thread_name, cb_info);
2028 handler_info->type = type;
2029 handler_info->queue = g_queue_new();
2030 if (handler_info->queue == NULL) {
2031 LOGE("t:%d queue failed", type);
2035 g_mutex_init(&handler_info->mutex);
2036 g_cond_init(&handler_info->cond);
2038 handler_info->cb_info = (void *)cb_info;
2039 g_atomic_int_set(&handler_info->running, 1);
2041 handler_info->thread = g_thread_try_new(thread_name,
2042 _camera_msg_handler_func, (gpointer)handler_info, NULL);
2043 if (handler_info->thread == NULL) {
2044 LOGE("t:%d thread failed", type);
2046 g_mutex_clear(&handler_info->mutex);
2047 g_cond_clear(&handler_info->cond);
2048 g_queue_free(handler_info->queue);
2049 handler_info->queue = NULL;
2054 LOGD("t:%d done", type);
2060 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2064 if (!handler_info) {
2065 LOGE("NULL handler");
2069 if (!handler_info->thread) {
2070 LOGW("thread is not created");
2074 type = handler_info->type;
2076 LOGD("t:%d thread %p", type, handler_info->thread);
2078 g_mutex_lock(&handler_info->mutex);
2079 g_atomic_int_set(&handler_info->running, 0);
2080 g_cond_signal(&handler_info->cond);
2081 g_mutex_unlock(&handler_info->mutex);
2083 g_thread_join(handler_info->thread);
2084 handler_info->thread = NULL;
2086 g_mutex_clear(&handler_info->mutex);
2087 g_cond_clear(&handler_info->cond);
2088 g_queue_free(handler_info->queue);
2089 handler_info->queue = NULL;
2091 LOGD("t:%d done", type);
2097 static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
2099 camera_cb_info_s *cb_info = NULL;
2102 g_return_val_if_fail(sockfd > 0, NULL);
2104 cb_info = g_new0(camera_cb_info_s, 1);
2105 if (cb_info == NULL) {
2106 LOGE("cb_info failed");
2110 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2112 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2113 g_mutex_init(&cb_info->api_mutex[i]);
2114 g_cond_init(&cb_info->api_cond[i]);
2117 g_mutex_init(&cb_info->fd_lock);
2118 g_mutex_init(&cb_info->mp_data_mutex);
2120 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2121 g_mutex_init(&cb_info->user_cb_mutex[i]);
2123 /* message handler thread */
2124 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2125 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2126 LOGE("msg_handler_info failed");
2130 /* message handler thread for preview callback */
2131 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2132 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2133 LOGE("preview_cb_info failed");
2137 /* message handler thread for capture callback */
2138 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2139 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2140 LOGE("capture_cb_info failed");
2144 cb_info->fd = sockfd;
2145 cb_info->preview_cb_flag = 0;
2147 /* message receive thread */
2148 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2149 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2150 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2151 if (cb_info->msg_recv_thread == NULL) {
2152 LOGE("message receive thread creation failed");
2156 cb_info->is_server_connected = TRUE;
2162 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2163 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2164 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2166 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2167 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2169 g_mutex_clear(&cb_info->fd_lock);
2170 g_mutex_clear(&cb_info->mp_data_mutex);
2172 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2173 g_mutex_clear(&cb_info->api_mutex[i]);
2174 g_cond_clear(&cb_info->api_cond[i]);
2185 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2189 g_return_if_fail(cb_info != NULL);
2191 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2193 g_thread_join(cb_info->msg_recv_thread);
2194 cb_info->msg_recv_thread = NULL;
2196 LOGD("msg_recv thread removed");
2198 /* destroy msg handler threads */
2199 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2200 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2201 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2203 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2204 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2206 g_mutex_clear(&cb_info->fd_lock);
2207 g_mutex_clear(&cb_info->mp_data_mutex);
2209 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2210 g_mutex_clear(&cb_info->api_mutex[i]);
2211 g_cond_clear(&cb_info->api_cond[i]);
2214 if (cb_info->fd > -1) {
2215 muse_client_close(cb_info->fd);
2219 if (cb_info->bufmgr) {
2220 tbm_bufmgr_deinit(cb_info->bufmgr);
2221 cb_info->bufmgr = NULL;
2223 if (cb_info->pkt_fmt) {
2224 media_format_unref(cb_info->pkt_fmt);
2225 cb_info->pkt_fmt = NULL;
2228 if (cb_info->dp_interface) {
2229 mm_display_interface_deinit(cb_info->dp_interface);
2230 cb_info->dp_interface = NULL;
2233 cb_info->preview_cb_flag = 0;
2242 int _camera_start_evas_rendering(camera_h camera)
2244 camera_cli_s *pc = (camera_cli_s *)camera;
2246 if (!pc || !pc->cb_info) {
2247 LOGE("NULL handle");
2248 return CAMERA_ERROR_INVALID_PARAMETER;
2253 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2254 LOGE("EVAS surface is not set");
2255 return CAMERA_ERROR_NONE;
2258 /* set evas render flag as RUN */
2259 pc->cb_info->run_evas_render = true;
2261 return CAMERA_ERROR_NONE;
2265 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2267 int ret = CAMERA_ERROR_NONE;
2268 camera_cli_s *pc = (camera_cli_s *)camera;
2270 if (!pc || !pc->cb_info) {
2271 LOGE("NULL handle");
2272 return CAMERA_ERROR_INVALID_PARAMETER;
2275 LOGD("stop - keep screen %d", keep_screen);
2277 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2278 LOGE("EVAS surface is not set");
2279 return CAMERA_ERROR_NONE;
2282 /* set evas render flag as STOP and release buffers */
2283 pc->cb_info->run_evas_render = false;
2285 ret = mm_display_interface_evas_flush(pc->cb_info->dp_interface, keep_screen);
2286 if (ret == MM_ERROR_NONE) {
2287 ret = CAMERA_ERROR_NONE;
2289 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2290 ret = CAMERA_ERROR_INVALID_OPERATION;
2297 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2299 int ret = CAMERA_ERROR_NONE;
2302 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2304 /* create muse connection */
2305 if (!key || !value) {
2306 LOGE("NULL pointer");
2307 return CAMERA_ERROR_INVALID_PARAMETER;
2310 sock_fd = muse_client_new();
2312 LOGE("muse_client_new failed");
2313 return CAMERA_ERROR_INVALID_OPERATION;
2316 msg = muse_core_msg_new(api,
2317 MUSE_TYPE_INT, "module", MUSE_CAMERA,
2318 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2322 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2326 ret = muse_core_msg_send(sock_fd, msg);
2328 muse_core_msg_free(msg);
2332 LOGE("send msg failed");
2333 ret = CAMERA_ERROR_INVALID_OPERATION;
2337 ret = muse_core_msg_recv(sock_fd, recv_msg, MUSE_CAMERA_MSG_MAX_LENGTH);
2339 LOGE("recv msg failed %d", errno);
2340 ret = CAMERA_ERROR_INVALID_OPERATION;
2344 if (!muse_camera_msg_get(ret, recv_msg)) {
2345 LOGE("failed to get return value from msg [%s]", recv_msg);
2346 ret = CAMERA_ERROR_INVALID_OPERATION;
2350 if (ret == CAMERA_ERROR_NONE)
2351 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2353 LOGD("api %d - value %d", api, *value);
2357 muse_client_close(sock_fd);
2365 int camera_create(camera_device_e device, camera_h *camera)
2368 char *send_msg = NULL;
2370 int ret = CAMERA_ERROR_NONE;
2372 camera_cli_s *pc = NULL;
2373 tbm_bufmgr bufmgr = NULL;
2375 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2376 muse_core_api_module_e muse_module = MUSE_CAMERA;
2377 int device_type = (int)device;
2380 LOGE("NULL pointer");
2381 return CAMERA_ERROR_INVALID_PARAMETER;
2384 sock_fd = muse_client_new();
2386 LOGE("muse_client_new failed - returned fd %d", sock_fd);
2387 ret = CAMERA_ERROR_INVALID_OPERATION;
2393 send_msg = muse_core_msg_new(api,
2394 MUSE_TYPE_INT, "module", muse_module,
2395 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2396 MUSE_TYPE_INT, "pid", pid,
2401 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2405 send_ret = muse_core_msg_send(sock_fd, send_msg);
2407 muse_core_msg_free(send_msg);
2411 LOGE("send msg failed %d", errno);
2412 ret = CAMERA_ERROR_INVALID_OPERATION;
2416 pc = g_new0(camera_cli_s, 1);
2418 LOGE("camera_cli_s alloc failed");
2419 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2423 bufmgr = tbm_bufmgr_init(-1);
2424 if (bufmgr == NULL) {
2425 LOGE("get tbm bufmgr failed");
2426 ret = CAMERA_ERROR_INVALID_OPERATION;
2430 pc->cb_info = _camera_client_callback_new(sock_fd);
2431 if (pc->cb_info == NULL) {
2432 LOGE("cb_info alloc failed");
2433 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2439 LOGD("cb info : %d", pc->cb_info->fd);
2441 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2443 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2445 if (ret == CAMERA_ERROR_NONE) {
2446 intptr_t handle = 0;
2448 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2450 LOGE("Receiving Handle Failed!!");
2451 ret = CAMERA_ERROR_INVALID_OPERATION;
2455 pc->remote_handle = handle;
2456 pc->cb_info->bufmgr = bufmgr;
2458 ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL);
2459 if (ret != CAMERA_ERROR_NONE) {
2460 LOGE("init display failed 0x%x", ret);
2464 LOGD("camera create 0x%td", pc->remote_handle);
2466 *camera = (camera_h)pc;
2468 /* get display interface handle */
2469 if (mm_display_interface_init(&pc->cb_info->dp_interface) != MM_ERROR_NONE)
2470 LOGW("display interface init failed");
2472 /* get default preview format */
2473 if (camera_get_preview_format(*camera, &pc->cb_info->preview_format) != CAMERA_ERROR_NONE) {
2474 LOGW("get default preview format failed");
2475 pc->cb_info->preview_format = CAMERA_PIXEL_FORMAT_INVALID;
2485 tbm_bufmgr_deinit(bufmgr);
2490 muse_client_close(sock_fd);
2496 int temp_fd = pc->cb_info->fd;
2498 /* pc->cb_info->fd should be closed,
2499 because g_thread_join for msg_recv_thread is not returned
2500 in _camera_client_callback_destroy. */
2502 pc->cb_info->fd = -1;
2503 muse_client_close(temp_fd);
2506 _camera_client_callback_destroy(pc->cb_info);
2513 LOGE("camera create error : 0x%x", ret);
2520 int camera_change_device(camera_h camera, camera_device_e device)
2523 int ret = CAMERA_ERROR_NONE;
2524 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2525 camera_cli_s *pc = (camera_cli_s *)camera;
2526 camera_msg_param param;
2528 if (!pc || !pc->cb_info) {
2529 LOGE("NULL handle");
2530 return CAMERA_ERROR_INVALID_PARAMETER;
2533 CAMERA_MSG_PARAM_SET(param, INT, device);
2535 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2537 if (ret == CAMERA_ERROR_NONE) {
2538 /* reset callback and user data */
2539 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2540 pc->cb_info->user_cb[i] = NULL;
2541 pc->cb_info->user_data[i] = NULL;
2543 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
2550 int camera_destroy(camera_h camera)
2552 int ret = CAMERA_ERROR_NONE;
2553 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2554 camera_cli_s *pc = (camera_cli_s *)camera;
2556 if (!pc || !pc->cb_info) {
2557 LOGE("NULL handle");
2558 return CAMERA_ERROR_INVALID_PARAMETER;
2563 if (pc->cb_info->is_server_connected)
2564 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2566 LOGW("server disconnected. release resource without send message.");
2568 if (ret == CAMERA_ERROR_NONE) {
2569 _camera_deactivate_idle_event_all(pc->cb_info);
2570 _camera_client_callback_destroy(pc->cb_info);
2577 LOGD("ret : 0x%x", ret);
2582 int camera_start_preview(camera_h camera)
2584 int ret = CAMERA_ERROR_NONE;
2585 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2586 camera_cli_s *pc = (camera_cli_s *)camera;
2588 if (!pc || !pc->cb_info) {
2589 LOGE("NULL handle");
2590 return CAMERA_ERROR_INVALID_PARAMETER;
2593 LOGD("Enter : preview format %d, display type %d",
2594 pc->cb_info->preview_format, pc->cb_info->dp_type);
2596 if (pc->cb_info->preview_format == CAMERA_PIXEL_FORMAT_INVZ &&
2597 pc->cb_info->dp_type != CAMERA_DISPLAY_TYPE_NONE) {
2598 LOGE("CAMERA_DISPLAY_TYPE_NONE[current %d] should be set with INVZ format",
2599 pc->cb_info->dp_type);
2600 return CAMERA_ERROR_INVALID_OPERATION;
2603 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2604 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2605 ret = _camera_start_evas_rendering(camera);
2606 if (ret != CAMERA_ERROR_NONE) {
2607 LOGE("stop preview because of error");
2608 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, pc->cb_info, NULL, 0);
2612 LOGD("ret : 0x%x", ret);
2618 int camera_stop_preview(camera_h camera)
2620 int ret = CAMERA_ERROR_NONE;
2621 camera_cli_s *pc = (camera_cli_s *)camera;
2622 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2623 camera_state_e current_state = CAMERA_STATE_NONE;
2625 if (!pc || !pc->cb_info) {
2626 LOGE("NULL handle");
2627 return CAMERA_ERROR_INVALID_PARAMETER;
2633 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2634 ret = camera_get_state(camera, ¤t_state);
2635 if (ret != CAMERA_ERROR_NONE) {
2636 LOGE("failed to get current state 0x%x", ret);
2640 if (current_state == CAMERA_STATE_PREVIEW) {
2641 ret = _camera_stop_evas_rendering(camera, false);
2642 if (ret != CAMERA_ERROR_NONE)
2647 /* send stop preview message */
2648 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2650 if (ret != CAMERA_ERROR_NONE &&
2651 current_state == CAMERA_STATE_PREVIEW) {
2652 LOGW("restart evas rendering");
2653 _camera_start_evas_rendering(camera);
2656 LOGD("ret : 0x%x", ret);
2662 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2664 int ret = CAMERA_ERROR_NONE;
2665 camera_cli_s *pc = (camera_cli_s *)camera;
2666 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2668 if (!pc || !pc->cb_info) {
2669 LOGE("NULL handle");
2670 return CAMERA_ERROR_INVALID_PARAMETER;
2675 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2676 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2678 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2679 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2681 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2683 LOGD("ret : 0x%x", ret);
2689 bool camera_is_supported_continuous_capture(camera_h camera)
2691 int ret = CAMERA_ERROR_NONE;
2692 camera_cli_s *pc = (camera_cli_s *)camera;
2693 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2695 if (!pc || !pc->cb_info) {
2696 LOGE("NULL handle");
2697 return CAMERA_ERROR_INVALID_PARAMETER;
2702 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2705 LOGE("error is occurred 0x%x", ret);
2709 LOGD("ret : %d", ret);
2715 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)
2717 int ret = CAMERA_ERROR_NONE;
2718 camera_cli_s *pc = (camera_cli_s *)camera;
2719 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2720 camera_msg_param param;
2723 if (!pc || !pc->cb_info) {
2724 LOGE("NULL handle");
2725 return CAMERA_ERROR_INVALID_PARAMETER;
2730 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2731 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2733 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2734 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2736 value = (count << 16) | interval;
2737 CAMERA_MSG_PARAM_SET(param, INT, value);
2739 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2741 LOGD("ret : 0x%x", ret);
2747 int camera_stop_continuous_capture(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_STOP_CONTINUOUS_CAPTURE;
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);
2762 LOGD("ret : 0x%x", ret);
2768 bool camera_is_supported_face_detection(camera_h camera)
2770 int ret = CAMERA_ERROR_NONE;
2771 camera_cli_s *pc = (camera_cli_s *)camera;
2772 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2774 if (!pc || !pc->cb_info) {
2775 LOGE("NULL handle");
2776 return CAMERA_ERROR_INVALID_PARAMETER;
2781 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2784 LOGE("error is occurred 0x%x", ret);
2788 LOGD("ret : %d", ret);
2794 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2796 int ret = CAMERA_ERROR_NONE;
2797 camera_cli_s *pc = (camera_cli_s *)camera;
2798 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2800 if (!pc || !pc->cb_info) {
2801 LOGE("NULL handle");
2802 return CAMERA_ERROR_INVALID_PARAMETER;
2807 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2810 LOGE("error is occurred 0x%x", ret);
2814 LOGD("ret : %d", ret);
2820 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2822 int ret = CAMERA_ERROR_NONE;
2823 camera_cli_s *pc = (camera_cli_s *)camera;
2824 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2826 if (!pc || !pc->cb_info) {
2827 LOGE("NULL handle");
2828 return CAMERA_ERROR_INVALID_PARAMETER;
2833 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2836 LOGE("error is occurred 0x%x", ret);
2840 LOGD("ret : %d", ret);
2845 int camera_get_device_count(camera_h camera, int *device_count)
2847 int ret = CAMERA_ERROR_NONE;
2848 camera_cli_s *pc = (camera_cli_s *)camera;
2849 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2851 if (!pc || !pc->cb_info) {
2852 LOGE("NULL handle");
2853 return CAMERA_ERROR_INVALID_PARAMETER;
2858 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2860 if (ret == CAMERA_ERROR_NONE)
2861 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2863 LOGD("ret : 0x%x", ret);
2868 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2870 int ret = CAMERA_ERROR_NONE;
2871 camera_cli_s *pc = (camera_cli_s *)camera;
2872 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2874 if (!pc || !pc->cb_info) {
2875 LOGE("NULL handle");
2876 return CAMERA_ERROR_INVALID_PARAMETER;
2881 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2883 if (ret == CAMERA_ERROR_NONE) {
2884 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2886 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2887 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2889 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2892 LOGD("ret : 0x%x", ret);
2897 int camera_stop_face_detection(camera_h camera)
2899 int ret = CAMERA_ERROR_NONE;
2900 camera_cli_s *pc = (camera_cli_s *)camera;
2901 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
2903 if (!pc || !pc->cb_info) {
2904 LOGE("NULL handle");
2905 return CAMERA_ERROR_INVALID_PARAMETER;
2910 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2912 if (ret == CAMERA_ERROR_NONE) {
2913 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2915 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
2916 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
2918 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2921 LOGD("ret : 0x%x", ret);
2926 int camera_get_state(camera_h camera, camera_state_e *state)
2928 int ret = CAMERA_ERROR_NONE;
2929 camera_cli_s *pc = (camera_cli_s *)camera;
2930 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
2932 if (!pc || !pc->cb_info || !state) {
2933 LOGE("NULL pointer %p %p", pc, state);
2934 return CAMERA_ERROR_INVALID_PARAMETER;
2939 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2941 if (ret == CAMERA_ERROR_NONE)
2942 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
2944 LOGD("ret : 0x%x", ret);
2949 int camera_start_focusing(camera_h camera, bool continuous)
2951 int ret = CAMERA_ERROR_NONE;
2952 camera_cli_s *pc = (camera_cli_s *)camera;
2953 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
2954 camera_msg_param param;
2955 int is_continuous = (int)continuous;
2957 if (!pc || !pc->cb_info) {
2958 LOGE("NULL handle");
2959 return CAMERA_ERROR_INVALID_PARAMETER;
2964 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
2966 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2968 LOGD("ret : 0x%x", ret);
2973 int camera_cancel_focusing(camera_h camera)
2975 int ret = CAMERA_ERROR_NONE;
2976 camera_cli_s *pc = (camera_cli_s *)camera;
2977 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
2979 if (!pc || !pc->cb_info) {
2980 LOGE("NULL handle");
2981 return CAMERA_ERROR_INVALID_PARAMETER;
2984 LOGD("Enter, remote_handle : %td", pc->remote_handle);
2986 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2988 LOGD("ret : 0x%x", ret);
2993 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
2995 int ret = CAMERA_ERROR_NONE;
2997 camera_cli_s *pc = (camera_cli_s *)camera;
2998 camera_cb_info_s *cb_info = NULL;
2999 camera_state_e current_state = CAMERA_STATE_NONE;
3000 camera_msg_param param0;
3001 camera_msg_param param1;
3002 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
3004 if (!pc || !pc->cb_info) {
3005 LOGE("NULL handle");
3006 return CAMERA_ERROR_INVALID_PARAMETER;
3009 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
3010 LOGE("invalid type %d", type);
3011 return CAMERA_ERROR_INVALID_PARAMETER;
3014 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
3015 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
3016 return CAMERA_ERROR_INVALID_PARAMETER;
3019 cb_info = (camera_cb_info_s *)pc->cb_info;
3021 ret = camera_get_state(camera, ¤t_state);
3022 if (ret != CAMERA_ERROR_NONE) {
3023 LOGE("failed to get current state 0x%x", ret);
3027 if (current_state != CAMERA_STATE_CREATED) {
3028 LOGE("INVALID_STATE : current %d", current_state);
3029 return CAMERA_ERROR_INVALID_STATE;
3032 LOGD("Enter - type : %d, display : %p", type, display);
3034 if (type != CAMERA_DISPLAY_TYPE_NONE) {
3035 /* check display interface handle */
3036 if (!cb_info->dp_interface) {
3037 LOGE("display interface not supported");
3038 return CAMERA_ERROR_NOT_SUPPORTED;
3041 ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &parent_id);
3042 if (ret != MM_ERROR_NONE) {
3043 LOGE("[INVALID_OPERATION] set display failed[0x%x]", ret);
3044 return CAMERA_ERROR_INVALID_OPERATION;
3047 if (type == CAMERA_DISPLAY_TYPE_EVAS) {
3049 camera_flip_e flip = CAMERA_FLIP_NONE;
3050 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3051 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3058 camera_get_display_flip(camera, &flip);
3059 camera_get_display_mode(camera, &mode);
3060 camera_get_display_rotation(camera, &rotation);
3061 camera_is_display_visible(camera, &visible);
3062 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3064 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
3065 flip, mode, rotation, visible, x, y, width, height);
3067 ret = mm_display_interface_evas_set_flip(cb_info->dp_interface, flip);
3068 ret |= mm_display_interface_evas_set_mode(cb_info->dp_interface, mode);
3069 ret |= mm_display_interface_evas_set_rotation(cb_info->dp_interface, rotation);
3070 ret |= mm_display_interface_evas_set_visible(cb_info->dp_interface, visible);
3072 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
3073 ret |= mm_display_interface_evas_set_roi_area(cb_info->dp_interface, x, y, width, height);
3078 CAMERA_MSG_PARAM_SET(param0, INT, type);
3079 CAMERA_MSG_PARAM_SET(param1, INT, parent_id);
3081 _camera_msg_send_param2_int(api, cb_info, &ret,
3082 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
3084 if (ret == CAMERA_ERROR_NONE) {
3085 pc->cb_info->dp_type = type;
3087 if (type == CAMERA_DISPLAY_TYPE_EVAS)
3088 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3095 int camera_set_preview_resolution(camera_h camera, int width, int height)
3097 int ret = CAMERA_ERROR_NONE;
3098 camera_state_e current_state = CAMERA_STATE_NONE;
3099 camera_cli_s *pc = (camera_cli_s *)camera;
3100 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3101 camera_msg_param param;
3104 if (!pc || !pc->cb_info) {
3105 LOGE("NULL handle");
3106 return CAMERA_ERROR_INVALID_PARAMETER;
3109 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3110 ret = camera_get_state(camera, ¤t_state);
3111 if (ret != CAMERA_ERROR_NONE) {
3112 LOGE("failed to get current state 0x%x", ret);
3116 if (current_state == CAMERA_STATE_PREVIEW) {
3117 ret = _camera_stop_evas_rendering(camera, true);
3118 if (ret != CAMERA_ERROR_NONE)
3123 value = (width << 16) | height;
3124 CAMERA_MSG_PARAM_SET(param, INT, value);
3126 LOGD("%dx%d -> 0x%x", width, height, value);
3128 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3130 LOGD("ret : 0x%x", ret);
3132 if (current_state == CAMERA_STATE_PREVIEW) {
3133 LOGW("restart evas rendering");
3134 _camera_start_evas_rendering(camera);
3141 int camera_set_capture_resolution(camera_h camera, int width, int height)
3143 int ret = CAMERA_ERROR_NONE;
3144 camera_cli_s *pc = (camera_cli_s *)camera;
3145 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3146 camera_msg_param param;
3149 if (!pc || !pc->cb_info) {
3150 LOGE("NULL handle");
3151 return CAMERA_ERROR_INVALID_PARAMETER;
3156 value = (width << 16) | height;
3157 CAMERA_MSG_PARAM_SET(param, INT, value);
3159 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3161 LOGD("ret : 0x%x", ret);
3167 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3169 int ret = CAMERA_ERROR_NONE;
3170 int set_format = (int)format;
3171 camera_cli_s *pc = (camera_cli_s *)camera;
3172 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3173 camera_msg_param param;
3175 if (!pc || !pc->cb_info) {
3176 LOGE("NULL handle");
3177 return CAMERA_ERROR_INVALID_PARAMETER;
3180 LOGD("Enter - format %d", set_format);
3182 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3184 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3186 LOGD("ret : 0x%x", ret);
3192 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3194 int ret = CAMERA_ERROR_NONE;
3195 int set_format = (int)format;
3196 camera_msg_param param;
3197 camera_cli_s *pc = (camera_cli_s *)camera;
3198 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3200 if (!pc || !pc->cb_info) {
3201 LOGE("NULL handle");
3202 return CAMERA_ERROR_INVALID_PARAMETER;
3205 LOGD("Enter - capture_format %d", set_format);
3207 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3209 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3211 if (ret == CAMERA_ERROR_NONE)
3212 pc->cb_info->preview_format = set_format;
3214 LOGD("ret : 0x%x", ret);
3220 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3222 int ret = CAMERA_ERROR_NONE;
3223 camera_cli_s *pc = (camera_cli_s *)camera;
3224 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3226 if (!pc || !pc->cb_info || !width || !height) {
3227 LOGE("NULL pointer %p %p %p", pc, width, height);
3228 return CAMERA_ERROR_INVALID_PARAMETER;
3233 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3235 if (ret == CAMERA_ERROR_NONE) {
3236 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3237 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3240 LOGD("ret : 0x%x", ret);
3246 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3248 int ret = CAMERA_ERROR_NONE;
3249 int set_rotation = (int)rotation;
3250 camera_cli_s *pc = (camera_cli_s *)camera;
3251 camera_msg_param param;
3253 if (!pc || !pc->cb_info) {
3254 LOGE("NULL handle");
3255 return CAMERA_ERROR_INVALID_PARAMETER;
3258 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3259 ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
3260 if (ret != MM_ERROR_NONE) {
3261 LOGE("failed to set rotation for evas surface 0x%x", ret);
3262 return CAMERA_ERROR_INVALID_OPERATION;
3266 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3268 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3274 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3276 int ret = CAMERA_ERROR_NONE;
3277 camera_cli_s *pc = (camera_cli_s *)camera;
3279 if (!pc || !pc->cb_info || !rotation) {
3280 LOGE("NULL pointer %p %p", pc, rotation);
3281 return CAMERA_ERROR_INVALID_PARAMETER;
3284 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3286 if (ret == CAMERA_ERROR_NONE)
3287 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3293 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3295 int ret = CAMERA_ERROR_NONE;
3296 int set_flip = (int)flip;
3297 camera_cli_s *pc = (camera_cli_s *)camera;
3298 camera_msg_param param;
3300 if (!pc || !pc->cb_info) {
3301 LOGE("NULL handle");
3302 return CAMERA_ERROR_INVALID_PARAMETER;
3305 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3306 ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
3307 if (ret != MM_ERROR_NONE) {
3308 LOGE("failed to set flip for evas surface 0x%x", ret);
3309 return CAMERA_ERROR_INVALID_OPERATION;
3313 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3315 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3321 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3323 int ret = CAMERA_ERROR_NONE;
3324 camera_cli_s *pc = (camera_cli_s *)camera;
3326 if (!pc || !pc->cb_info || !flip) {
3327 LOGE("NULL pointer %p %p", pc, flip);
3328 return CAMERA_ERROR_INVALID_PARAMETER;
3331 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3333 if (ret == CAMERA_ERROR_NONE)
3334 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3340 int camera_set_display_visible(camera_h camera, bool visible)
3342 int ret = CAMERA_ERROR_NONE;
3343 int set_visible = (int)visible;
3344 camera_cli_s *pc = (camera_cli_s *)camera;
3345 camera_msg_param param;
3347 if (!pc || !pc->cb_info) {
3348 LOGE("NULL handle");
3349 return CAMERA_ERROR_INVALID_PARAMETER;
3352 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3353 ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
3354 if (ret != MM_ERROR_NONE) {
3355 LOGE("failed to set visible for evas surface 0x%x", ret);
3356 return CAMERA_ERROR_INVALID_OPERATION;
3360 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3362 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3368 int camera_is_display_visible(camera_h camera, bool *visible)
3370 int ret = CAMERA_ERROR_NONE;
3371 camera_cli_s *pc = (camera_cli_s *)camera;
3373 if (!pc || !pc->cb_info || !visible) {
3374 LOGE("NULL pointer %p %p", pc, visible);
3375 return CAMERA_ERROR_INVALID_PARAMETER;
3378 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3380 if (ret == CAMERA_ERROR_NONE)
3381 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3387 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3389 int ret = CAMERA_ERROR_NONE;
3390 int set_mode = (int)mode;
3391 camera_cli_s *pc = (camera_cli_s *)camera;
3392 camera_msg_param param;
3394 if (!pc || !pc->cb_info) {
3395 LOGE("NULL handle");
3396 return CAMERA_ERROR_INVALID_PARAMETER;
3399 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3400 ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
3401 if (ret != MM_ERROR_NONE) {
3402 LOGE("failed to set geometry for evas surface 0x%x", ret);
3403 return CAMERA_ERROR_INVALID_OPERATION;
3407 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3409 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3415 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3417 int ret = CAMERA_ERROR_NONE;
3418 camera_cli_s *pc = (camera_cli_s *)camera;
3420 if (!pc || !pc->cb_info || !mode) {
3421 LOGE("NULL pointer %p %p", pc, mode);
3422 return CAMERA_ERROR_INVALID_PARAMETER;
3425 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3427 if (ret == CAMERA_ERROR_NONE)
3428 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3434 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3436 int ret = CAMERA_ERROR_NONE;
3437 int set_hint = (int)hint;
3438 camera_cli_s *pc = (camera_cli_s *)camera;
3439 camera_msg_param param;
3441 if (!pc || !pc->cb_info) {
3442 LOGE("NULL handle");
3443 return CAMERA_ERROR_INVALID_PARAMETER;
3446 LOGD("Enter - hint %d", set_hint);
3448 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3450 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3456 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3458 int ret = CAMERA_ERROR_NONE;
3459 camera_cli_s *pc = (camera_cli_s *)camera;
3460 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3462 if (!pc || !pc->cb_info || !hint) {
3463 LOGE("NULL pointer %p %p", pc, hint);
3464 return CAMERA_ERROR_INVALID_PARAMETER;
3467 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3469 if (ret == CAMERA_ERROR_NONE) {
3470 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3471 LOGD("display reuse hint %d", *hint);
3478 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3480 int ret = CAMERA_ERROR_NONE;
3481 camera_cli_s *pc = (camera_cli_s *)camera;
3482 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3484 if (!pc || !pc->cb_info || !width || !height) {
3485 LOGE("NULL pointer %p %p %p", pc, width, height);
3486 return CAMERA_ERROR_INVALID_PARAMETER;
3491 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3493 if (ret == CAMERA_ERROR_NONE) {
3494 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3495 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3498 LOGD("ret : 0x%x", ret);
3504 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3506 int ret = CAMERA_ERROR_NONE;
3507 camera_cli_s *pc = (camera_cli_s *)camera;
3508 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3510 if (!pc || !pc->cb_info || !format) {
3511 LOGE("NULL pointer %p %p", pc, format);
3512 return CAMERA_ERROR_INVALID_PARAMETER;
3517 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3519 if (ret == CAMERA_ERROR_NONE)
3520 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3522 LOGD("ret : 0x%x", ret);
3528 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3530 int ret = CAMERA_ERROR_NONE;
3531 camera_cli_s *pc = (camera_cli_s *)camera;
3532 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3534 if (!pc || !pc->cb_info || !format) {
3535 LOGE("NULL pointer %p %p", pc, format);
3536 return CAMERA_ERROR_INVALID_PARAMETER;
3541 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3543 if (ret == CAMERA_ERROR_NONE)
3544 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3546 LOGD("ret : 0x%x", ret);
3552 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3554 int ret = CAMERA_ERROR_NONE;
3555 camera_cli_s *pc = (camera_cli_s *)camera;
3556 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3558 if (!pc || !pc->cb_info || !facing_direction) {
3559 LOGE("NULL pointer %p %p", pc, facing_direction);
3560 return CAMERA_ERROR_INVALID_PARAMETER;
3565 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3567 if (ret == CAMERA_ERROR_NONE)
3568 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3570 LOGD("ret : 0x%x", ret);
3576 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3578 int ret = CAMERA_ERROR_NONE;
3579 camera_cli_s *pc = (camera_cli_s *)camera;
3580 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3582 if (!pc || !pc->cb_info || !callback) {
3583 LOGE("NULL pointer %p %p", pc, callback);
3584 return CAMERA_ERROR_INVALID_PARAMETER;
3589 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3591 if (ret == CAMERA_ERROR_NONE) {
3592 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3594 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3595 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3597 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3599 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3602 LOGD("ret : 0x%x", ret);
3608 int camera_unset_preview_cb(camera_h camera)
3610 int ret = CAMERA_ERROR_NONE;
3611 camera_cli_s *pc = (camera_cli_s *)camera;
3612 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3614 if (!pc || !pc->cb_info) {
3615 LOGE("NULL handle");
3616 return CAMERA_ERROR_INVALID_PARAMETER;
3621 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3623 if (ret == CAMERA_ERROR_NONE) {
3624 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3626 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3627 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3629 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3631 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3634 LOGD("ret : 0x%x", ret);
3640 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3642 int ret = CAMERA_ERROR_NONE;
3643 camera_cli_s *pc = (camera_cli_s *)camera;
3644 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3646 if (!pc || !pc->cb_info) {
3647 LOGE("NULL handle");
3648 return CAMERA_ERROR_INVALID_PARAMETER;
3651 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3652 LOGE("NOT SUPPORTED");
3653 return CAMERA_ERROR_NOT_SUPPORTED;
3656 if (callback == NULL) {
3657 LOGE("NULL callback");
3658 return CAMERA_ERROR_INVALID_PARAMETER;
3663 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3665 if (ret == CAMERA_ERROR_NONE) {
3666 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3668 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3669 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3671 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3674 LOGD("ret : 0x%x", ret);
3680 int camera_unset_media_packet_preview_cb(camera_h camera)
3682 int ret = CAMERA_ERROR_NONE;
3683 camera_cli_s *pc = (camera_cli_s *)camera;
3684 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3686 if (!pc || !pc->cb_info) {
3687 LOGE("NULL handle");
3688 return CAMERA_ERROR_INVALID_PARAMETER;
3693 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3695 if (ret == CAMERA_ERROR_NONE) {
3696 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3698 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3699 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3701 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3704 LOGD("ret : 0x%x", ret);
3710 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3712 int ret = CAMERA_ERROR_NONE;
3713 camera_cli_s *pc = (camera_cli_s *)camera;
3714 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3716 if (!pc || !pc->cb_info || !callback) {
3717 LOGE("NULL pointer %p %p", pc, callback);
3718 return CAMERA_ERROR_INVALID_PARAMETER;
3723 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3725 if (ret == CAMERA_ERROR_NONE) {
3726 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3728 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3729 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3731 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3734 LOGD("ret : 0x%x", ret);
3740 int camera_unset_state_changed_cb(camera_h camera)
3742 int ret = CAMERA_ERROR_NONE;
3743 camera_cli_s *pc = (camera_cli_s *)camera;
3744 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3746 if (!pc || !pc->cb_info) {
3747 LOGE("NULL handle");
3748 return CAMERA_ERROR_INVALID_PARAMETER;
3753 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3755 if (ret == CAMERA_ERROR_NONE) {
3756 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3758 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3759 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3761 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3764 LOGD("ret : 0x%x", ret);
3770 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3772 int ret = CAMERA_ERROR_NONE;
3773 camera_cli_s *pc = (camera_cli_s *)camera;
3774 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3776 if (!pc || !pc->cb_info || !callback) {
3777 LOGE("NULL pointer %p %p", pc, callback);
3778 return CAMERA_ERROR_INVALID_PARAMETER;
3783 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3785 if (ret == CAMERA_ERROR_NONE) {
3786 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3788 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3789 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3791 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3794 LOGD("ret : 0x%x", ret);
3800 int camera_unset_interrupted_cb(camera_h camera)
3802 int ret = CAMERA_ERROR_NONE;
3803 camera_cli_s *pc = (camera_cli_s *)camera;
3804 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3806 if (!pc || !pc->cb_info) {
3807 LOGE("NULL handle");
3808 return CAMERA_ERROR_INVALID_PARAMETER;
3813 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3815 if (ret == CAMERA_ERROR_NONE) {
3816 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3818 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3819 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3821 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3824 LOGD("ret : 0x%x", ret);
3830 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
3832 int ret = CAMERA_ERROR_NONE;
3833 camera_cli_s *pc = (camera_cli_s *)camera;
3834 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
3836 if (!pc || !pc->cb_info || !callback) {
3837 LOGE("NULL pointer %p %p", pc, callback);
3838 return CAMERA_ERROR_INVALID_PARAMETER;
3843 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3845 if (ret == CAMERA_ERROR_NONE) {
3846 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3848 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
3849 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
3851 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3854 LOGD("ret : 0x%x", ret);
3860 int camera_unset_interrupt_started_cb(camera_h camera)
3862 int ret = CAMERA_ERROR_NONE;
3863 camera_cli_s *pc = (camera_cli_s *)camera;
3864 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
3866 if (!pc || !pc->cb_info) {
3867 LOGE("NULL handle");
3868 return CAMERA_ERROR_INVALID_PARAMETER;
3873 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3875 if (ret == CAMERA_ERROR_NONE) {
3876 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3878 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3879 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3881 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3884 LOGD("ret : 0x%x", ret);
3890 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
3892 int ret = CAMERA_ERROR_NONE;
3893 camera_cli_s *pc = (camera_cli_s *)camera;
3894 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3896 if (!pc || !pc->cb_info || !callback) {
3897 LOGE("NULL pointer %p %p", pc, callback);
3898 return CAMERA_ERROR_INVALID_PARAMETER;
3903 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3905 if (ret == CAMERA_ERROR_NONE) {
3906 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3908 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3909 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3911 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3914 LOGD("ret : 0x%x", ret);
3920 int camera_unset_focus_changed_cb(camera_h camera)
3922 int ret = CAMERA_ERROR_NONE;
3923 camera_cli_s *pc = (camera_cli_s *)camera;
3924 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
3926 if (!pc || !pc->cb_info) {
3927 LOGE("NULL handle");
3928 return CAMERA_ERROR_INVALID_PARAMETER;
3933 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3935 if (ret == CAMERA_ERROR_NONE) {
3936 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3938 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3939 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3941 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3944 LOGD("ret : 0x%x", ret);
3950 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
3952 int ret = CAMERA_ERROR_NONE;
3953 camera_cli_s *pc = (camera_cli_s *)camera;
3954 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
3956 if (!pc || !pc->cb_info || !callback) {
3957 LOGE("NULL pointer %p %p", pc, callback);
3958 return CAMERA_ERROR_INVALID_PARAMETER;
3963 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3965 if (ret == CAMERA_ERROR_NONE) {
3966 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3968 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
3969 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
3971 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3974 LOGD("ret : 0x%x", ret);
3980 int camera_unset_error_cb(camera_h camera)
3982 int ret = CAMERA_ERROR_NONE;
3983 camera_cli_s *pc = (camera_cli_s *)camera;
3984 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
3986 if (!pc || !pc->cb_info) {
3987 LOGE("NULL handle");
3988 return CAMERA_ERROR_INVALID_PARAMETER;
3993 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3995 if (ret == CAMERA_ERROR_NONE) {
3996 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3998 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
3999 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4001 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4004 LOGD("ret : 0x%x", ret);
4010 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4012 int ret = CAMERA_ERROR_NONE;
4013 camera_cli_s *pc = (camera_cli_s *)camera;
4014 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4016 if (!pc || !pc->cb_info || !foreach_cb) {
4017 LOGE("NULL pointer %p %p", pc, foreach_cb);
4018 return CAMERA_ERROR_INVALID_PARAMETER;
4023 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4024 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4026 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4028 LOGD("ret : 0x%x", ret);
4034 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4036 int ret = CAMERA_ERROR_NONE;
4037 camera_cli_s *pc = (camera_cli_s *)camera;
4038 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4040 if (!pc || !pc->cb_info || !foreach_cb) {
4041 LOGE("NULL pointer %p %p", pc, foreach_cb);
4042 return CAMERA_ERROR_INVALID_PARAMETER;
4047 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4048 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4050 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4052 LOGD("ret : 0x%x", ret);
4058 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4060 int ret = CAMERA_ERROR_NONE;
4061 camera_cli_s *pc = (camera_cli_s *)camera;
4062 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4064 if (!pc || !pc->cb_info || !foreach_cb) {
4065 LOGE("NULL pointer %p %p", pc, foreach_cb);
4066 return CAMERA_ERROR_INVALID_PARAMETER;
4071 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4072 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4074 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4076 LOGD("ret : 0x%x", ret);
4082 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4084 int ret = CAMERA_ERROR_NONE;
4085 camera_cli_s *pc = (camera_cli_s *)camera;
4086 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4088 if (!pc || !pc->cb_info || !foreach_cb) {
4089 LOGE("NULL pointer %p %p", pc, foreach_cb);
4090 return CAMERA_ERROR_INVALID_PARAMETER;
4095 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4096 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4098 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4100 LOGD("ret : 0x%x", ret);
4106 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4108 int ret = CAMERA_ERROR_NONE;
4109 camera_cli_s *pc = (camera_cli_s *)camera;
4110 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4112 if (!pc || !pc->cb_info || !width || !height) {
4113 LOGE("NULL pointer %p %p %p", pc, width, height);
4114 return CAMERA_ERROR_INVALID_PARAMETER;
4118 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4120 if (ret == CAMERA_ERROR_NONE) {
4121 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4122 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4125 LOGD("ret : 0x%x", ret);
4131 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4133 int ret = CAMERA_ERROR_NONE;
4134 camera_cli_s *pc = (camera_cli_s *)camera;
4135 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4137 if (!pc || !pc->cb_info || !angle) {
4138 LOGE("NULL pointer %p %p", pc, angle);
4139 return CAMERA_ERROR_INVALID_PARAMETER;
4144 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4146 if (ret == CAMERA_ERROR_NONE)
4147 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4149 LOGD("ret : 0x%x", ret);
4155 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4157 int ret = CAMERA_ERROR_NONE;
4158 camera_cli_s *pc = (camera_cli_s *)camera;
4159 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4160 camera_msg_param param;
4161 int set_mode = (int)mode;
4163 if (!pc || !pc->cb_info) {
4164 LOGE("NULL handle");
4165 return CAMERA_ERROR_INVALID_PARAMETER;
4170 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4172 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4174 LOGD("ret : 0x%x", ret);
4180 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4182 int ret = CAMERA_ERROR_NONE;
4183 camera_cli_s *pc = (camera_cli_s *)camera;
4184 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4186 if (!pc || !pc->cb_info || !mode) {
4187 LOGE("NULL pointer %p %p", pc, mode);
4188 return CAMERA_ERROR_INVALID_PARAMETER;
4193 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4195 if (ret == CAMERA_ERROR_NONE)
4196 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4198 LOGD("ret : 0x%x", ret);
4204 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4206 int ret = CAMERA_ERROR_NONE;
4207 camera_cli_s *pc = (camera_cli_s *)camera;
4208 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4210 if (!pc || !pc->cb_info || !foreach_cb) {
4211 LOGE("NULL pointer %p %p", pc, foreach_cb);
4212 return CAMERA_ERROR_INVALID_PARAMETER;
4217 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4218 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4220 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4222 LOGD("Finish, return :%x", ret);
4228 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4230 int ret = CAMERA_ERROR_NONE;
4231 camera_cli_s *pc = (camera_cli_s *)camera;
4232 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4233 camera_msg_param param;
4234 int set_fps = (int)fps;
4236 if (!pc || !pc->cb_info) {
4237 LOGE("NULL handle");
4238 return CAMERA_ERROR_INVALID_PARAMETER;
4243 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4245 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4247 LOGD("ret : 0x%x", ret);
4253 int camera_attr_set_image_quality(camera_h camera, int quality)
4255 int ret = CAMERA_ERROR_NONE;
4256 camera_cli_s *pc = (camera_cli_s *)camera;
4257 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4258 camera_msg_param param;
4260 if (!pc || !pc->cb_info) {
4261 LOGE("NULL handle");
4262 return CAMERA_ERROR_INVALID_PARAMETER;
4267 CAMERA_MSG_PARAM_SET(param, INT, quality);
4269 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4271 LOGD("ret : 0x%x", ret);
4277 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4279 int ret = CAMERA_ERROR_NONE;
4280 camera_cli_s *pc = (camera_cli_s *)camera;
4281 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4283 if (!pc || !pc->cb_info || !fps) {
4284 LOGE("NULL pointer %p %p", pc, fps);
4285 return CAMERA_ERROR_INVALID_PARAMETER;
4290 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4292 if (ret == CAMERA_ERROR_NONE)
4293 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4295 LOGD("ret : 0x%x", ret);
4301 int camera_attr_get_image_quality(camera_h camera, int *quality)
4303 int ret = CAMERA_ERROR_NONE;
4304 camera_cli_s *pc = (camera_cli_s *)camera;
4305 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4307 if (!pc || !pc->cb_info || !quality) {
4308 LOGE("NULL pointer %p %p", pc, quality);
4309 return CAMERA_ERROR_INVALID_PARAMETER;
4314 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4316 if (ret == CAMERA_ERROR_NONE)
4317 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4319 LOGD("ret : 0x%x", ret);
4325 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4327 int ret = CAMERA_ERROR_NONE;
4328 camera_cli_s *pc = (camera_cli_s *)camera;
4329 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4331 if (!pc || !pc->cb_info || !bitrate) {
4332 LOGE("NULL pointer %p %p", pc, bitrate);
4333 return CAMERA_ERROR_INVALID_PARAMETER;
4338 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4340 if (ret == CAMERA_ERROR_NONE)
4341 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4343 LOGD("ret : 0x%x", ret);
4349 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4351 int ret = CAMERA_ERROR_NONE;
4352 camera_cli_s *pc = (camera_cli_s *)camera;
4353 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4354 camera_msg_param param;
4355 int set_bitrate = bitrate;
4357 if (!pc || !pc->cb_info) {
4358 LOGE("NULL handle");
4359 return CAMERA_ERROR_INVALID_PARAMETER;
4364 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4366 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4368 LOGD("ret : 0x%x", ret);
4374 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4376 int ret = CAMERA_ERROR_NONE;
4377 camera_cli_s *pc = (camera_cli_s *)camera;
4378 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4380 if (!pc || !pc->cb_info || !interval) {
4381 LOGE("NULL pointer %p %p", pc, interval);
4382 return CAMERA_ERROR_INVALID_PARAMETER;
4387 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4389 if (ret == CAMERA_ERROR_NONE)
4390 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4392 LOGD("ret : 0x%x", ret);
4398 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4400 int ret = CAMERA_ERROR_NONE;
4401 camera_cli_s *pc = (camera_cli_s *)camera;
4402 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4403 camera_msg_param param;
4404 int set_gop_interval = interval;
4406 if (!pc || !pc->cb_info) {
4407 LOGE("NULL handle");
4408 return CAMERA_ERROR_INVALID_PARAMETER;
4413 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4415 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4417 LOGD("ret : 0x%x", ret);
4423 int camera_attr_set_zoom(camera_h camera, int zoom)
4425 int ret = CAMERA_ERROR_NONE;
4426 camera_cli_s *pc = (camera_cli_s *)camera;
4427 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4428 camera_msg_param param;
4430 if (!pc || !pc->cb_info) {
4431 LOGE("NULL handle");
4432 return CAMERA_ERROR_INVALID_PARAMETER;
4435 LOGD("Enter, remote_handle : %td", pc->remote_handle);
4437 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4439 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4441 LOGD("ret : 0x%x", ret);
4447 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
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_MODE;
4452 camera_msg_param param;
4453 int set_mode = (int)mode;
4455 if (!pc || !pc->cb_info) {
4456 LOGE("NULL handle");
4457 return CAMERA_ERROR_INVALID_PARAMETER;
4460 LOGD("Enter, remote_handle : %td", pc->remote_handle);
4462 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4464 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4470 int camera_attr_set_af_area(camera_h camera, int x, int y)
4472 int ret = CAMERA_ERROR_NONE;
4473 camera_cli_s *pc = (camera_cli_s *)camera;
4474 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4475 camera_msg_param param;
4478 if (!pc || !pc->cb_info) {
4479 LOGE("NULL handle");
4480 return CAMERA_ERROR_INVALID_PARAMETER;
4483 LOGD("Enter - %d,%d", x, y);
4485 value = (x << 16) | y;
4486 CAMERA_MSG_PARAM_SET(param, INT, value);
4488 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4490 LOGD("ret : 0x%x", ret);
4496 int camera_attr_clear_af_area(camera_h camera)
4498 int ret = CAMERA_ERROR_NONE;
4499 camera_cli_s *pc = (camera_cli_s *)camera;
4500 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4502 if (!pc || !pc->cb_info) {
4503 LOGE("NULL handle");
4504 return CAMERA_ERROR_INVALID_PARAMETER;
4509 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4511 LOGD("ret : 0x%x", ret);
4517 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4519 int ret = CAMERA_ERROR_NONE;
4520 camera_cli_s *pc = (camera_cli_s *)camera;
4521 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4522 camera_msg_param param;
4523 int set_mode = (int)mode;
4525 if (!pc || !pc->cb_info) {
4526 LOGE("NULL handle");
4527 return CAMERA_ERROR_INVALID_PARAMETER;
4532 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4534 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4536 LOGD("ret : 0x%x", ret);
4542 int camera_attr_set_exposure(camera_h camera, int value)
4544 int ret = CAMERA_ERROR_NONE;
4545 camera_cli_s *pc = (camera_cli_s *)camera;
4546 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4547 camera_msg_param param;
4549 if (!pc || !pc->cb_info) {
4550 LOGE("NULL handle");
4551 return CAMERA_ERROR_INVALID_PARAMETER;
4556 CAMERA_MSG_PARAM_SET(param, INT, value);
4558 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4560 LOGD("ret : 0x%x", ret);
4566 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4568 int ret = CAMERA_ERROR_NONE;
4569 camera_cli_s *pc = (camera_cli_s *)camera;
4570 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4571 camera_msg_param param;
4572 int set_iso = (int)iso;
4574 if (!pc || !pc->cb_info) {
4575 LOGE("NULL handle");
4576 return CAMERA_ERROR_INVALID_PARAMETER;
4581 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4583 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4585 LOGD("ret : 0x%x", ret);
4591 int camera_attr_set_brightness(camera_h camera, int level)
4593 int ret = CAMERA_ERROR_NONE;
4594 camera_cli_s *pc = (camera_cli_s *)camera;
4595 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4596 camera_msg_param param;
4598 if (!pc || !pc->cb_info) {
4599 LOGE("NULL handle");
4600 return CAMERA_ERROR_INVALID_PARAMETER;
4605 CAMERA_MSG_PARAM_SET(param, INT, level);
4607 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4609 LOGD("ret : 0x%x", ret);
4615 int camera_attr_set_contrast(camera_h camera, int level)
4617 int ret = CAMERA_ERROR_NONE;
4618 camera_cli_s *pc = (camera_cli_s *)camera;
4619 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4620 camera_msg_param param;
4622 if (!pc || !pc->cb_info) {
4623 LOGE("NULL handle");
4624 return CAMERA_ERROR_INVALID_PARAMETER;
4629 CAMERA_MSG_PARAM_SET(param, INT, level);
4631 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4633 LOGD("ret : 0x%x", ret);
4639 int camera_attr_set_hue(camera_h camera, int level)
4641 int ret = CAMERA_ERROR_NONE;
4642 camera_cli_s *pc = (camera_cli_s *)camera;
4643 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HUE;
4644 camera_msg_param param;
4646 if (!pc || !pc->cb_info) {
4647 LOGE("NULL handle");
4648 return CAMERA_ERROR_INVALID_PARAMETER;
4653 CAMERA_MSG_PARAM_SET(param, INT, level);
4655 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4657 LOGD("ret : 0x%x", ret);
4663 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4665 int ret = CAMERA_ERROR_NONE;
4666 camera_cli_s *pc = (camera_cli_s *)camera;
4667 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4668 camera_msg_param param;
4669 int set_whitebalance = (int)wb;
4671 if (!pc || !pc->cb_info) {
4672 LOGE("NULL handle");
4673 return CAMERA_ERROR_INVALID_PARAMETER;
4678 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4680 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4682 LOGD("ret : 0x%x", ret);
4688 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4690 int ret = CAMERA_ERROR_NONE;
4691 camera_cli_s *pc = (camera_cli_s *)camera;
4692 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4693 camera_msg_param param;
4694 int set_effect = (int)effect;
4696 if (!pc || !pc->cb_info) {
4697 LOGE("NULL handle");
4698 return CAMERA_ERROR_INVALID_PARAMETER;
4703 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4705 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4707 LOGD("ret : 0x%x", ret);
4713 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4715 int ret = CAMERA_ERROR_NONE;
4716 camera_cli_s *pc = (camera_cli_s *)camera;
4717 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4718 camera_msg_param param;
4719 int set_mode = (int)mode;
4721 if (!pc || !pc->cb_info) {
4722 LOGE("NULL handle");
4723 return CAMERA_ERROR_INVALID_PARAMETER;
4728 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4730 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4732 LOGD("ret : 0x%x", ret);
4738 int camera_attr_enable_tag(camera_h camera, bool enable)
4740 int ret = CAMERA_ERROR_NONE;
4741 camera_cli_s *pc = (camera_cli_s *)camera;
4742 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4743 camera_msg_param param;
4744 int set_enable = (int)enable;
4746 if (!pc || !pc->cb_info) {
4747 LOGE("NULL handle");
4748 return CAMERA_ERROR_INVALID_PARAMETER;
4753 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4755 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4757 LOGD("ret : 0x%x", ret);
4763 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4765 int ret = CAMERA_ERROR_NONE;
4766 camera_cli_s *pc = (camera_cli_s *)camera;
4767 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4768 camera_msg_param param;
4770 if (!pc || !pc->cb_info || !description) {
4771 LOGE("NULL pointer %p %p", pc, description);
4772 return CAMERA_ERROR_INVALID_PARAMETER;
4777 CAMERA_MSG_PARAM_SET(param, STRING, description);
4779 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4781 LOGD("ret : 0x%x", ret);
4787 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4789 int ret = CAMERA_ERROR_NONE;
4790 camera_cli_s *pc = (camera_cli_s *)camera;
4791 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4792 camera_msg_param param;
4793 int set_orientation = (int)orientation;
4795 if (!pc || !pc->cb_info) {
4796 LOGE("NULL handle");
4797 return CAMERA_ERROR_INVALID_PARAMETER;
4802 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4804 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4806 LOGD("ret : 0x%x", ret);
4812 int camera_attr_set_tag_software(camera_h camera, const char *software)
4814 int ret = CAMERA_ERROR_NONE;
4815 camera_cli_s *pc = (camera_cli_s *)camera;
4816 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4817 camera_msg_param param;
4819 if (!pc || !pc->cb_info || !software) {
4820 LOGE("NULL pointer %p %p", pc, software);
4821 return CAMERA_ERROR_INVALID_PARAMETER;
4824 LOGD("Enter, remote_handle : %td", pc->remote_handle);
4826 CAMERA_MSG_PARAM_SET(param, STRING, software);
4828 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4830 LOGD("ret : 0x%x", ret);
4836 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4838 int ret = CAMERA_ERROR_NONE;
4839 camera_cli_s *pc = (camera_cli_s *)camera;
4840 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4841 double set_geotag[3] = {latitude, longitude, altitude};
4846 if (!pc || !pc->cb_info) {
4847 LOGE("NULL handle");
4848 return CAMERA_ERROR_INVALID_PARAMETER;
4853 length = sizeof(set_geotag) / sizeof(int) + \
4854 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4856 msg = muse_core_msg_new(api,
4857 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4860 LOGE("msg creation failed: api %d", api);
4861 return CAMERA_ERROR_OUT_OF_MEMORY;
4864 if (pc->cb_info->is_server_connected) {
4865 __camera_update_api_waiting(pc->cb_info, api, 1);
4867 g_mutex_lock(&pc->cb_info->fd_lock);
4868 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
4869 g_mutex_unlock(&pc->cb_info->fd_lock);
4873 LOGE("message send failed");
4874 ret = CAMERA_ERROR_INVALID_OPERATION;
4876 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
4879 __camera_update_api_waiting(pc->cb_info, api, -1);
4881 muse_core_msg_free(msg);
4883 LOGD("ret : 0x%x", ret);
4889 int camera_attr_remove_geotag(camera_h camera)
4891 int ret = CAMERA_ERROR_NONE;
4892 camera_cli_s *pc = (camera_cli_s *)camera;
4893 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4895 if (!pc || !pc->cb_info) {
4896 LOGE("NULL handle");
4897 return CAMERA_ERROR_INVALID_PARAMETER;
4902 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4904 LOGD("ret : 0x%x", ret);
4910 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4912 int ret = CAMERA_ERROR_NONE;
4913 camera_cli_s *pc = (camera_cli_s *)camera;
4914 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
4915 camera_msg_param param;
4916 int set_mode = (int)mode;
4918 if (!pc || !pc->cb_info) {
4919 LOGE("NULL handle");
4920 return CAMERA_ERROR_INVALID_PARAMETER;
4925 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4927 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4929 LOGD("ret : 0x%x", ret);
4935 int camera_attr_get_zoom(camera_h camera, int *zoom)
4937 int ret = CAMERA_ERROR_NONE;
4938 camera_cli_s *pc = (camera_cli_s *)camera;
4939 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4941 if (!pc || !pc->cb_info || !zoom) {
4942 LOGE("NULL pointer %p %p", pc, zoom);
4943 return CAMERA_ERROR_INVALID_PARAMETER;
4948 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4950 if (ret == CAMERA_ERROR_NONE)
4951 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
4953 LOGD("ret : 0x%x", ret);
4959 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
4961 int ret = CAMERA_ERROR_NONE;
4962 camera_cli_s *pc = (camera_cli_s *)camera;
4963 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
4965 if (!pc || !pc->cb_info || !min || !max) {
4966 LOGE("NULL pointer %p %p %p", pc, min, max);
4967 return CAMERA_ERROR_INVALID_PARAMETER;
4972 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4974 if (ret == CAMERA_ERROR_NONE) {
4975 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
4976 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
4979 LOGD("ret : 0x%x", ret);
4985 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
4987 int ret = CAMERA_ERROR_NONE;
4988 camera_cli_s *pc = (camera_cli_s *)camera;
4989 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
4991 if (!pc || !pc->cb_info || !mode) {
4992 LOGE("NULL pointer %p %p", pc, mode);
4993 return CAMERA_ERROR_INVALID_PARAMETER;
4998 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5000 if (ret == CAMERA_ERROR_NONE)
5001 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5003 LOGD("ret : 0x%x", ret);
5009 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5011 int ret = CAMERA_ERROR_NONE;
5012 camera_cli_s *pc = (camera_cli_s *)camera;
5013 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5015 if (!pc || !pc->cb_info || !mode) {
5016 LOGE("NULL pointer %p %p", pc, mode);
5017 return CAMERA_ERROR_INVALID_PARAMETER;
5022 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5024 if (ret == CAMERA_ERROR_NONE)
5025 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5027 LOGD("ret : 0x%x", ret);
5033 int camera_attr_get_exposure(camera_h camera, int *value)
5035 int ret = CAMERA_ERROR_NONE;
5036 camera_cli_s *pc = (camera_cli_s *)camera;
5037 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5039 if (!pc || !pc->cb_info || !value) {
5040 LOGE("NULL pointer %p %p", pc, value);
5041 return CAMERA_ERROR_INVALID_PARAMETER;
5046 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5048 if (ret == CAMERA_ERROR_NONE)
5049 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5051 LOGD("ret : 0x%x", ret);
5057 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5059 int ret = CAMERA_ERROR_NONE;
5060 camera_cli_s *pc = (camera_cli_s *)camera;
5061 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5063 if (!pc || !pc->cb_info || !min || !max) {
5064 LOGE("NULL pointer %p %p %p", pc, min, max);
5065 return CAMERA_ERROR_INVALID_PARAMETER;
5070 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5072 if (ret == CAMERA_ERROR_NONE) {
5073 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5074 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5077 LOGD("ret : 0x%x", ret);
5083 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5085 int ret = CAMERA_ERROR_NONE;
5086 camera_cli_s *pc = (camera_cli_s *)camera;
5087 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5089 if (!pc || !pc->cb_info || !iso) {
5090 LOGE("NULL pointer %p %p", pc, iso);
5091 return CAMERA_ERROR_INVALID_PARAMETER;
5096 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5098 if (ret == CAMERA_ERROR_NONE)
5099 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5101 LOGD("ret : 0x%x", ret);
5107 int camera_attr_get_brightness(camera_h camera, int *level)
5109 int ret = CAMERA_ERROR_NONE;
5110 camera_cli_s *pc = (camera_cli_s *)camera;
5111 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5113 if (!pc || !pc->cb_info || !level) {
5114 LOGE("NULL pointer %p %p", pc, level);
5115 return CAMERA_ERROR_INVALID_PARAMETER;
5120 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5122 if (ret == CAMERA_ERROR_NONE)
5123 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5125 LOGD("ret : 0x%x", ret);
5131 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5133 int ret = CAMERA_ERROR_NONE;
5134 camera_cli_s *pc = (camera_cli_s *)camera;
5135 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5137 if (!pc || !pc->cb_info || !min || !max) {
5138 LOGE("NULL pointer %p %p %p", pc, min, max);
5139 return CAMERA_ERROR_INVALID_PARAMETER;
5144 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5146 if (ret == CAMERA_ERROR_NONE) {
5147 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5148 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5151 LOGD("ret : 0x%x", ret);
5157 int camera_attr_get_contrast(camera_h camera, int *level)
5159 int ret = CAMERA_ERROR_NONE;
5160 camera_cli_s *pc = (camera_cli_s *)camera;
5161 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5163 if (!pc || !pc->cb_info || !level) {
5164 LOGE("NULL pointer %p %p", pc, level);
5165 return CAMERA_ERROR_INVALID_PARAMETER;
5170 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5172 if (ret == CAMERA_ERROR_NONE)
5173 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5175 LOGD("ret : 0x%x", ret);
5181 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5183 int ret = CAMERA_ERROR_NONE;
5184 camera_cli_s *pc = (camera_cli_s *)camera;
5185 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5187 if (!pc || !pc->cb_info || !min || !max) {
5188 LOGE("NULL pointer %p %p %p", pc, min, max);
5189 return CAMERA_ERROR_INVALID_PARAMETER;
5194 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5196 if (ret == CAMERA_ERROR_NONE) {
5197 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5198 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5199 LOGD("min %d, max %d", *min, *max);
5202 LOGD("ret : 0x%x", ret);
5208 int camera_attr_get_hue(camera_h camera, int *level)
5210 int ret = CAMERA_ERROR_NONE;
5211 camera_cli_s *pc = (camera_cli_s *)camera;
5212 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE;
5214 if (!pc || !pc->cb_info || !level) {
5215 LOGE("NULL pointer %p %p", pc, level);
5216 return CAMERA_ERROR_INVALID_PARAMETER;
5221 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5223 if (ret == CAMERA_ERROR_NONE)
5224 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HUE];
5226 LOGD("ret : 0x%x", ret);
5232 int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
5234 int ret = CAMERA_ERROR_NONE;
5235 camera_cli_s *pc = (camera_cli_s *)camera;
5236 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE_RANGE;
5238 if (!pc || !pc->cb_info || !min || !max) {
5239 LOGE("NULL pointer %p %p %p", pc, min, max);
5240 return CAMERA_ERROR_INVALID_PARAMETER;
5245 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5247 if (ret == CAMERA_ERROR_NONE) {
5248 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][0];
5249 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][1];
5250 LOGD("min %d, max %d", *min, *max);
5253 LOGD("ret : 0x%x", ret);
5259 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5261 int ret = CAMERA_ERROR_NONE;
5262 camera_cli_s *pc = (camera_cli_s *)camera;
5263 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5265 if (!pc || !pc->cb_info || !wb) {
5266 LOGE("NULL pointer %p %p", pc, wb);
5267 return CAMERA_ERROR_INVALID_PARAMETER;
5272 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5274 if (ret == CAMERA_ERROR_NONE)
5275 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5277 LOGD("ret : 0x%x", ret);
5283 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5285 int ret = CAMERA_ERROR_NONE;
5286 camera_cli_s *pc = (camera_cli_s *)camera;
5287 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5289 if (!pc || !pc->cb_info || !effect) {
5290 LOGE("NULL pointer %p %p", pc, effect);
5291 return CAMERA_ERROR_INVALID_PARAMETER;
5296 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5298 if (ret == CAMERA_ERROR_NONE)
5299 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5301 LOGD("ret : 0x%x", ret);
5307 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5309 int ret = CAMERA_ERROR_NONE;
5310 camera_cli_s *pc = (camera_cli_s *)camera;
5311 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5313 if (!pc || !pc->cb_info || !mode) {
5314 LOGE("NULL pointer %p %p", pc, mode);
5315 return CAMERA_ERROR_INVALID_PARAMETER;
5320 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5322 if (ret == CAMERA_ERROR_NONE)
5323 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5325 LOGD("ret : 0x%x", ret);
5331 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5333 int ret = CAMERA_ERROR_NONE;
5334 camera_cli_s *pc = (camera_cli_s *)camera;
5335 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5337 if (!pc || !pc->cb_info || !enable) {
5338 LOGE("NULL pointer %p %p", pc, enable);
5339 return CAMERA_ERROR_INVALID_PARAMETER;
5344 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5346 if (ret == CAMERA_ERROR_NONE)
5347 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5349 LOGD("ret : 0x%x", ret);
5355 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5357 int ret = CAMERA_ERROR_NONE;
5358 camera_cli_s *pc = (camera_cli_s *)camera;
5359 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5361 if (!pc || !pc->cb_info || !description) {
5362 LOGE("NULL pointer %p %p", pc, description);
5363 return CAMERA_ERROR_INVALID_PARAMETER;
5368 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5370 if (ret == CAMERA_ERROR_NONE)
5371 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5373 LOGD("ret : 0x%x", ret);
5379 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5381 int ret = CAMERA_ERROR_NONE;
5382 camera_cli_s *pc = (camera_cli_s *)camera;
5383 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5385 if (!pc || !pc->cb_info || !orientation) {
5386 LOGE("NULL pointer %p %p", pc, orientation);
5387 return CAMERA_ERROR_INVALID_PARAMETER;
5392 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5394 if (ret == CAMERA_ERROR_NONE)
5395 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5397 LOGD("ret : 0x%x", ret);
5403 int camera_attr_get_tag_software(camera_h camera, char **software)
5405 int ret = CAMERA_ERROR_NONE;
5406 camera_cli_s *pc = (camera_cli_s *)camera;
5407 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5409 if (!pc || !pc->cb_info || !software) {
5410 LOGE("NULL pointer %p %p", pc, software);
5411 return CAMERA_ERROR_INVALID_PARAMETER;
5416 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5418 if (ret == CAMERA_ERROR_NONE)
5419 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5421 LOGD("ret : 0x%x", ret);
5427 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5429 int ret = CAMERA_ERROR_NONE;
5430 camera_cli_s *pc = (camera_cli_s *)camera;
5431 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5433 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5434 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5435 return CAMERA_ERROR_INVALID_PARAMETER;
5440 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5442 if (ret == CAMERA_ERROR_NONE) {
5443 *latitude = pc->cb_info->get_geotag[0];
5444 *longitude = pc->cb_info->get_geotag[1];
5445 *altitude = pc->cb_info->get_geotag[2];
5448 LOGD("ret : 0x%x", ret);
5454 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5456 int ret = CAMERA_ERROR_NONE;
5457 camera_cli_s *pc = (camera_cli_s *)camera;
5458 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5460 if (!pc || !pc->cb_info || !mode) {
5461 LOGE("NULL pointer %p %p", pc, mode);
5462 return CAMERA_ERROR_INVALID_PARAMETER;
5467 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5469 if (ret == CAMERA_ERROR_NONE)
5470 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5472 LOGD("ret : 0x%x", ret);
5478 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5480 int ret = CAMERA_ERROR_NONE;
5481 int get_flash_state = 0;
5484 LOGE("NULL pointer");
5485 return CAMERA_ERROR_INVALID_PARAMETER;
5488 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5489 (int)device, "get_flash_state", &get_flash_state);
5491 if (ret == CAMERA_ERROR_NONE) {
5492 *state = (camera_flash_state_e)get_flash_state;
5493 LOGD("flash state %d", *state);
5495 LOGE("failed 0x%x", ret);
5502 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5504 int ret = CAMERA_ERROR_NONE;
5505 camera_cli_s *pc = (camera_cli_s *)camera;
5506 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5508 if (!pc || !pc->cb_info || !foreach_cb) {
5509 LOGE("NULL pointer %p %p", pc, foreach_cb);
5510 return CAMERA_ERROR_INVALID_PARAMETER;
5515 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5516 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5518 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5520 LOGD("ret : 0x%x", ret);
5526 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5528 int ret = CAMERA_ERROR_NONE;
5529 camera_cli_s *pc = (camera_cli_s *)camera;
5530 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5532 if (!pc || !pc->cb_info || !foreach_cb) {
5533 LOGE("NULL pointer %p %p", pc, foreach_cb);
5534 return CAMERA_ERROR_INVALID_PARAMETER;
5539 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5540 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5542 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5544 LOGD("ret : 0x%x", ret);
5550 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5552 int ret = CAMERA_ERROR_NONE;
5553 camera_cli_s *pc = (camera_cli_s *)camera;
5554 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5556 if (!pc || !pc->cb_info || !foreach_cb) {
5557 LOGE("NULL pointer %p %p", pc, foreach_cb);
5558 return CAMERA_ERROR_INVALID_PARAMETER;
5563 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5564 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5566 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5568 LOGD("ret : 0x%x", ret);
5574 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5576 int ret = CAMERA_ERROR_NONE;
5577 camera_cli_s *pc = (camera_cli_s *)camera;
5578 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5580 if (!pc || !pc->cb_info || !foreach_cb) {
5581 LOGE("NULL pointer %p %p", pc, foreach_cb);
5582 return CAMERA_ERROR_INVALID_PARAMETER;
5587 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5588 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5590 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5592 LOGD("ret : 0x%x", ret);
5598 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5600 int ret = CAMERA_ERROR_NONE;
5601 camera_cli_s *pc = (camera_cli_s *)camera;
5602 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5604 if (!pc || !pc->cb_info || !foreach_cb) {
5605 LOGE("NULL pointer %p %p", pc, foreach_cb);
5606 return CAMERA_ERROR_INVALID_PARAMETER;
5611 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5612 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5614 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5616 LOGD("ret : 0x%x", ret);
5622 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5624 int ret = CAMERA_ERROR_NONE;
5625 camera_cli_s *pc = (camera_cli_s *)camera;
5626 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5628 if (!pc || !pc->cb_info || !foreach_cb) {
5629 LOGE("NULL pointer %p %p", pc, foreach_cb);
5630 return CAMERA_ERROR_INVALID_PARAMETER;
5635 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5636 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5638 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5640 LOGD("ret : 0x%x", ret);
5646 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5648 int ret = CAMERA_ERROR_NONE;
5649 camera_cli_s *pc = (camera_cli_s *)camera;
5650 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5652 if (!pc || !pc->cb_info || !foreach_cb) {
5653 LOGE("NULL pointer %p %p", pc, foreach_cb);
5654 return CAMERA_ERROR_INVALID_PARAMETER;
5659 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5660 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5662 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5664 LOGD("ret : 0x%x", ret);
5670 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5672 int ret = CAMERA_ERROR_NONE;
5673 camera_cli_s *pc = (camera_cli_s *)camera;
5674 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5676 if (!pc || !pc->cb_info || !foreach_cb) {
5677 LOGE("NULL pointer %p %p", pc, foreach_cb);
5678 return CAMERA_ERROR_INVALID_PARAMETER;
5683 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5684 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5686 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5688 LOGD("Enter, handle :%td", pc->remote_handle);
5694 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)
5696 int ret = CAMERA_ERROR_NONE;
5697 camera_cli_s *pc = (camera_cli_s *)camera;
5698 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5699 camera_msg_param param;
5702 if (!pc || !pc->cb_info || !foreach_cb) {
5703 LOGE("NULL pointer %p %p", pc, foreach_cb);
5704 return CAMERA_ERROR_INVALID_PARAMETER;
5709 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5710 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5712 value = (width << 16) | height;
5713 CAMERA_MSG_PARAM_SET(param, INT, value);
5715 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5717 LOGD("ret : 0x%x", ret);
5723 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5725 int ret = CAMERA_ERROR_NONE;
5726 camera_cli_s *pc = (camera_cli_s *)camera;
5727 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5729 if (!pc || !pc->cb_info || !foreach_cb) {
5730 LOGE("NULL pointer %p %p", pc, foreach_cb);
5731 return CAMERA_ERROR_INVALID_PARAMETER;
5736 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5737 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5739 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5741 LOGD("ret : 0x%x", ret);
5747 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5749 int ret = CAMERA_ERROR_NONE;
5750 camera_cli_s *pc = (camera_cli_s *)camera;
5751 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5753 if (!pc || !pc->cb_info || !foreach_cb) {
5754 LOGE("NULL pointer %p %p", pc, foreach_cb);
5755 return CAMERA_ERROR_INVALID_PARAMETER;
5760 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5761 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5763 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5765 LOGD("ret : 0x%x", ret);
5771 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5773 int ret = CAMERA_ERROR_NONE;
5774 camera_cli_s *pc = (camera_cli_s *)camera;
5775 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5776 camera_msg_param param;
5777 int set_rotation = (int)rotation;
5779 if (!pc || !pc->cb_info) {
5780 LOGE("NULL handle");
5781 return CAMERA_ERROR_INVALID_PARAMETER;
5786 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5788 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5790 LOGD("ret : 0x%x", ret);
5796 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5798 int ret = CAMERA_ERROR_NONE;
5799 camera_cli_s *pc = (camera_cli_s *)camera;
5800 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5802 if (!pc || !pc->cb_info || !rotation) {
5803 LOGE("NULL pointer %p %p", pc, rotation);
5804 return CAMERA_ERROR_INVALID_PARAMETER;
5809 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5811 if (ret == CAMERA_ERROR_NONE)
5812 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5814 LOGD("ret : 0x%x", ret);
5820 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5822 int ret = CAMERA_ERROR_NONE;
5823 camera_cli_s *pc = (camera_cli_s *)camera;
5824 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5825 camera_msg_param param;
5826 int set_flip = (int)flip;
5828 if (!pc || !pc->cb_info) {
5829 LOGE("NULL handle");
5830 return CAMERA_ERROR_INVALID_PARAMETER;
5835 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5837 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5839 LOGD("ret : 0x%x", ret);
5845 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
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_GET_STREAM_FLIP;
5851 if (!pc || !pc->cb_info || !flip) {
5852 LOGE("NULL pointer %p %p", pc, flip);
5853 return CAMERA_ERROR_INVALID_PARAMETER;
5858 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5860 if (ret == CAMERA_ERROR_NONE)
5861 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5863 LOGD("ret : 0x%x", ret);
5868 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5870 int ret = CAMERA_ERROR_NONE;
5871 camera_cli_s *pc = (camera_cli_s *)camera;
5872 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5873 camera_msg_param param;
5874 int set_mode = (int)mode;
5876 if (!pc || !pc->cb_info) {
5877 LOGE("NULL handle");
5878 return CAMERA_ERROR_INVALID_PARAMETER;
5883 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5885 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5887 LOGD("ret : 0x%x", ret);
5893 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5895 int ret = CAMERA_ERROR_NONE;
5896 camera_cli_s *pc = (camera_cli_s *)camera;
5897 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5899 if (!pc || !pc->cb_info || !mode) {
5900 LOGE("NULL pointer %p %p", pc, mode);
5901 return CAMERA_ERROR_INVALID_PARAMETER;
5906 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5908 if (ret == CAMERA_ERROR_NONE)
5909 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
5911 LOGD("ret : 0x%x", ret);
5917 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5919 int ret = CAMERA_ERROR_NONE;
5920 camera_cli_s *pc = (camera_cli_s *)camera;
5921 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
5923 if (!pc || !pc->cb_info) {
5924 LOGE("NULL handle");
5925 return CAMERA_ERROR_INVALID_PARAMETER;
5930 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5933 LOGE("error is occurred 0x%x", ret);
5937 LOGD("ret : %d", ret);
5943 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5945 int ret = CAMERA_ERROR_NONE;
5946 camera_cli_s *pc = (camera_cli_s *)camera;
5947 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5949 if (!pc || !pc->cb_info) {
5950 LOGE("NULL handle");
5951 return CAMERA_ERROR_INVALID_PARAMETER;
5956 if (!camera_attr_is_supported_hdr_capture(camera)) {
5957 LOGE("HDR not supported");
5958 return CAMERA_ERROR_NOT_SUPPORTED;
5962 LOGE("NULL callback");
5963 return CAMERA_ERROR_INVALID_PARAMETER;
5966 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5968 if (ret == CAMERA_ERROR_NONE) {
5969 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5971 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5972 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5974 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5977 LOGD("ret : 0x%x", ret);
5983 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5985 int ret = CAMERA_ERROR_NONE;
5986 camera_cli_s *pc = (camera_cli_s *)camera;
5987 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5989 if (!pc || !pc->cb_info) {
5990 LOGE("NULL handle");
5991 return CAMERA_ERROR_INVALID_PARAMETER;
5996 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5998 if (ret == CAMERA_ERROR_NONE) {
5999 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6001 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6002 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6004 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6007 LOGD("ret : 0x%x", ret);
6013 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6015 int ret = CAMERA_ERROR_NONE;
6016 camera_cli_s *pc = (camera_cli_s *)camera;
6017 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
6018 camera_msg_param param;
6019 int set_enable = (int)enable;
6021 if (!pc || !pc->cb_info) {
6022 LOGE("NULL handle");
6023 return CAMERA_ERROR_INVALID_PARAMETER;
6028 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6030 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6032 LOGD("ret : 0x%x", ret);
6038 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6040 int ret = CAMERA_ERROR_NONE;
6041 camera_cli_s *pc = (camera_cli_s *)camera;
6042 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6044 if (!pc || !pc->cb_info || !enabled) {
6045 LOGE("NULL pointer %p %p", pc, enabled);
6046 return CAMERA_ERROR_INVALID_PARAMETER;
6051 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6053 if (ret == CAMERA_ERROR_NONE)
6054 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6056 LOGD("ret : 0x%x", ret);
6062 bool camera_attr_is_supported_anti_shake(camera_h camera)
6064 int ret = CAMERA_ERROR_NONE;
6065 camera_cli_s *pc = (camera_cli_s *)camera;
6066 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6068 if (!pc || !pc->cb_info) {
6069 LOGE("NULL handle");
6070 return CAMERA_ERROR_INVALID_PARAMETER;
6075 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6078 LOGE("error is occurred 0x%x", ret);
6082 LOGD("ret : %d", ret);
6088 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6090 int ret = CAMERA_ERROR_NONE;
6091 camera_cli_s *pc = (camera_cli_s *)camera;
6092 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6093 camera_msg_param param;
6094 int set_enable = (int)enable;
6096 if (!pc || !pc->cb_info) {
6097 LOGE("NULL handle");
6098 return CAMERA_ERROR_INVALID_PARAMETER;
6103 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6105 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6107 LOGD("ret : 0x%x", ret);
6113 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6115 int ret = CAMERA_ERROR_NONE;
6116 camera_cli_s *pc = (camera_cli_s *)camera;
6117 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6119 if (!pc || !pc->cb_info || !enabled) {
6120 LOGE("NULL pointer %p %p", pc, enabled);
6121 return CAMERA_ERROR_INVALID_PARAMETER;
6126 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6128 if (ret == CAMERA_ERROR_NONE)
6129 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6131 LOGD("ret : 0x%x", ret);
6137 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6139 int ret = CAMERA_ERROR_NONE;
6140 camera_cli_s *pc = (camera_cli_s *)camera;
6141 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6143 if (!pc || !pc->cb_info) {
6144 LOGE("NULL handle");
6145 return CAMERA_ERROR_INVALID_PARAMETER;
6150 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6153 LOGE("error is occurred 0x%x", ret);
6157 LOGD("ret : %d", ret);
6163 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6165 int ret = CAMERA_ERROR_NONE;
6166 camera_cli_s *pc = (camera_cli_s *)camera;
6167 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6168 camera_msg_param param;
6169 int set_enable = (int)enable;
6171 if (!pc || !pc->cb_info) {
6172 LOGE("NULL handle");
6173 return CAMERA_ERROR_INVALID_PARAMETER;
6178 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6180 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6182 LOGD("ret : 0x%x", ret);
6188 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6190 int ret = CAMERA_ERROR_NONE;
6191 camera_cli_s *pc = (camera_cli_s *)camera;
6192 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6194 if (!pc || !pc->cb_info || !enabled) {
6195 LOGE("NULL pointer %p %p", pc, enabled);
6196 return CAMERA_ERROR_INVALID_PARAMETER;
6201 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6203 if (ret == CAMERA_ERROR_NONE)
6204 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6206 LOGD("ret : 0x%x", ret);
6212 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6214 int ret = CAMERA_ERROR_NONE;
6215 camera_cli_s *pc = (camera_cli_s *)camera;
6216 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6218 if (!pc || !pc->cb_info) {
6219 LOGE("NULL handle");
6220 return CAMERA_ERROR_INVALID_PARAMETER;
6225 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6228 LOGE("error is occurred 0x%x", ret);
6232 LOGD("ret : %d", ret);
6238 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6240 int ret = CAMERA_ERROR_NONE;
6241 camera_cli_s *pc = (camera_cli_s *)camera;
6242 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6243 camera_msg_param param;
6244 int set_disable = (int)disable;
6246 if (!pc || !pc->cb_info) {
6247 LOGE("NULL handle");
6248 return CAMERA_ERROR_INVALID_PARAMETER;
6253 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6255 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6257 LOGD("ret : 0x%x", ret);
6263 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6265 int ret = CAMERA_ERROR_NONE;
6266 camera_cli_s *pc = (camera_cli_s *)camera;
6267 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6268 camera_msg_param param;
6269 int set_move_type = (int)move_type;
6272 if (!pc || !pc->cb_info) {
6273 LOGE("NULL handle");
6274 return CAMERA_ERROR_INVALID_PARAMETER;
6279 value = (set_move_type << 16) | pan_step;
6280 CAMERA_MSG_PARAM_SET(param, INT, value);
6282 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6284 LOGD("ret : 0x%x", ret);
6290 int camera_attr_get_pan(camera_h camera, int *pan_step)
6292 int ret = CAMERA_ERROR_NONE;
6293 camera_cli_s *pc = (camera_cli_s *)camera;
6294 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6296 if (!pc || !pc->cb_info || !pan_step) {
6297 LOGE("NULL pointer %p %p", pc, pan_step);
6298 return CAMERA_ERROR_INVALID_PARAMETER;
6303 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6305 if (ret == CAMERA_ERROR_NONE)
6306 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6308 LOGD("ret : 0x%x", ret);
6314 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6316 int ret = CAMERA_ERROR_NONE;
6317 camera_cli_s *pc = (camera_cli_s *)camera;
6318 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6320 if (!pc || !pc->cb_info || !min || !max) {
6321 LOGE("NULL pointer %p %p %p", pc, min, max);
6322 return CAMERA_ERROR_INVALID_PARAMETER;
6327 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6329 if (ret == CAMERA_ERROR_NONE) {
6330 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6331 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6334 LOGD("ret : 0x%x", ret);
6340 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6342 int ret = CAMERA_ERROR_NONE;
6343 camera_cli_s *pc = (camera_cli_s *)camera;
6344 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6345 camera_msg_param param;
6346 int set_move_type = (int)move_type;
6349 if (!pc || !pc->cb_info) {
6350 LOGE("NULL handle");
6351 return CAMERA_ERROR_INVALID_PARAMETER;
6356 value = (set_move_type << 16) | tilt_step;
6357 CAMERA_MSG_PARAM_SET(param, INT, value);
6359 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6361 LOGD("ret : 0x%x", ret);
6367 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6369 int ret = CAMERA_ERROR_NONE;
6370 camera_cli_s *pc = (camera_cli_s *)camera;
6371 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6373 if (!pc || !pc->cb_info || !tilt_step) {
6374 LOGE("NULL pointer %p %p", pc, tilt_step);
6375 return CAMERA_ERROR_INVALID_PARAMETER;
6380 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6382 if (ret == CAMERA_ERROR_NONE)
6383 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6385 LOGD("ret : 0x%x", ret);
6391 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6393 int ret = CAMERA_ERROR_NONE;
6394 camera_cli_s *pc = (camera_cli_s *)camera;
6395 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6397 if (!pc || !pc->cb_info || !min || !max) {
6398 LOGE("NULL pointer %p %p %p", pc, min, max);
6399 return CAMERA_ERROR_INVALID_PARAMETER;
6404 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6406 if (ret == CAMERA_ERROR_NONE) {
6407 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6408 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6411 LOGD("ret : 0x%x", ret);
6417 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6419 int ret = CAMERA_ERROR_NONE;
6420 camera_cli_s *pc = (camera_cli_s *)camera;
6421 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6422 camera_msg_param param;
6423 int set_ptz_type = (int)ptz_type;
6425 if (!pc || !pc->cb_info) {
6426 LOGE("NULL handle");
6427 return CAMERA_ERROR_INVALID_PARAMETER;
6432 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6434 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6436 LOGD("ret : 0x%x", ret);
6442 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6444 int ret = CAMERA_ERROR_NONE;
6445 camera_cli_s *pc = (camera_cli_s *)camera;
6446 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6448 if (!pc || !pc->cb_info || !foreach_cb) {
6449 LOGE("NULL pointer %p %p", pc, foreach_cb);
6450 return CAMERA_ERROR_INVALID_PARAMETER;
6455 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6456 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6458 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6460 LOGD("ret : 0x%x", ret);
6466 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6468 int ret = CAMERA_ERROR_NONE;
6469 camera_cli_s *pc = (camera_cli_s *)camera;
6470 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6471 int set_display_roi_area[4] = {x, y, width, height};
6476 if (!pc || !pc->cb_info) {
6477 LOGE("NULL handle");
6478 return CAMERA_ERROR_INVALID_PARAMETER;
6483 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6484 ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
6485 if (ret != MM_ERROR_NONE) {
6486 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6487 return CAMERA_ERROR_INVALID_OPERATION;
6491 length = sizeof(set_display_roi_area) / sizeof(int) + \
6492 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6494 msg = muse_core_msg_new(api,
6495 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6498 LOGE("msg creation failed: api %d", api);
6499 return CAMERA_ERROR_OUT_OF_MEMORY;
6502 if (pc->cb_info->is_server_connected) {
6503 __camera_update_api_waiting(pc->cb_info, api, 1);
6505 g_mutex_lock(&pc->cb_info->fd_lock);
6506 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
6507 g_mutex_unlock(&pc->cb_info->fd_lock);
6511 LOGE("message send failed");
6512 ret = CAMERA_ERROR_INVALID_OPERATION;
6514 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6517 __camera_update_api_waiting(pc->cb_info, api, -1);
6519 muse_core_msg_free(msg);
6521 LOGD("ret : 0x%x", ret);
6527 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6529 camera_cli_s *pc = (camera_cli_s *)camera;
6530 int ret = CAMERA_ERROR_NONE;
6531 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6533 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6534 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6535 return CAMERA_ERROR_INVALID_PARAMETER;
6540 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6542 if (ret == CAMERA_ERROR_NONE) {
6543 *x = pc->cb_info->get_display_roi_area[0];
6544 *y = pc->cb_info->get_display_roi_area[1];
6545 *width = pc->cb_info->get_display_roi_area[2];
6546 *height = pc->cb_info->get_display_roi_area[3];
6549 LOGD("ret : 0x%x", ret);
6555 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6557 int ret = CAMERA_ERROR_NONE;
6558 int get_device_state = 0;
6561 LOGE("NULL pointer");
6562 return CAMERA_ERROR_INVALID_PARAMETER;
6565 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6566 (int)device, "get_device_state", &get_device_state);
6568 if (ret == CAMERA_ERROR_NONE) {
6569 *state = (camera_device_state_e)get_device_state;
6570 LOGD("device state %d", *state);
6572 LOGE("failed 0x%x", ret);
6579 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6581 int ret = CAMERA_ERROR_NONE;
6582 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6583 camera_cb_info *info = NULL;
6585 if (!callback || !cb_id) {
6586 LOGE("invalid pointer %p %p", callback, cb_id);
6587 return CAMERA_ERROR_INVALID_PARAMETER;
6590 /* check camera support */
6591 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6592 if (ret != CAMERA_ERROR_NONE) {
6593 LOGE("get device state failed");
6597 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6599 info = g_new0(camera_cb_info, 1);
6601 LOGE("info failed");
6602 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6606 info->id = ++g_cam_dev_state_changed_cb_id;
6607 info->callback = (void *)callback;
6608 info->user_data = user_data;
6612 /* subscribe dbus signal for camera state change */
6613 if (!g_cam_dev_state_changed_cb_conn) {
6614 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6615 if (!g_cam_dev_state_changed_cb_conn) {
6616 LOGE("failed to get gdbus connection");
6617 ret = CAMERA_ERROR_INVALID_OPERATION;
6621 LOGD("subscribe signal %s - %s - %s",
6622 MM_CAMCORDER_DBUS_OBJECT,
6623 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6624 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6626 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6627 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6628 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6629 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6630 LOGE("failed to get gdbus connection");
6631 ret = CAMERA_ERROR_INVALID_OPERATION;
6635 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6638 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6640 LOGD("callback id %d", info->id);
6643 if (ret != CAMERA_ERROR_NONE) {
6649 if (g_cam_dev_state_changed_cb_conn) {
6650 g_object_unref(g_cam_dev_state_changed_cb_conn);
6651 g_cam_dev_state_changed_cb_conn = NULL;
6655 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6661 int camera_remove_device_state_changed_cb(int cb_id)
6663 int ret = CAMERA_ERROR_NONE;
6664 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6665 GList *tmp_list = NULL;
6666 camera_cb_info *info = NULL;
6668 /* check camera support */
6669 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6670 if (ret != CAMERA_ERROR_NONE) {
6671 LOGE("get device state failed");
6675 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6677 if (!g_cam_dev_state_changed_cb_list) {
6678 LOGE("there is no callback info");
6679 ret = CAMERA_ERROR_INVALID_OPERATION;
6683 tmp_list = g_cam_dev_state_changed_cb_list;
6686 info = tmp_list->data;
6687 tmp_list = tmp_list->next;
6694 if (info->id == cb_id) {
6695 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6700 if (!g_cam_dev_state_changed_cb_list) {
6701 /* no remained callback */
6702 if (g_cam_dev_state_changed_cb_conn) {
6703 /* unsubscribe signal */
6704 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6705 g_cam_dev_state_changed_cb_subscribe_id = 0;
6707 /* unref connection */
6708 g_object_unref(g_cam_dev_state_changed_cb_conn);
6709 g_cam_dev_state_changed_cb_conn = NULL;
6713 LOGD("id %d callback removed", cb_id);
6714 ret = CAMERA_ERROR_NONE;
6720 LOGE("id %d callback not found", cb_id);
6721 ret = CAMERA_ERROR_INVALID_PARAMETER;
6724 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);