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"
37 #define MODULE_NAME "camera"
39 /* for device changed callback */
40 static GMutex g_cam_dev_state_changed_cb_lock;
41 static GList *g_cam_dev_state_changed_cb_list;
42 static int g_cam_dev_state_changed_cb_id;
43 static GDBusConnection *g_cam_dev_state_changed_cb_conn;
44 static guint g_cam_dev_state_changed_cb_subscribe_id;
45 static GMutex g_cam_idle_event_lock;
47 static void _camera_msg_send(int api, camera_cb_info_s *cb_info,
48 int *ret, int timeout);
49 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
50 int *ret, camera_msg_param *param, int timeout);
51 static void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
52 int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout);
53 static int _camera_import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle);
54 static void _camera_release_imported_bo(tbm_bo *bo);
55 static void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_key,
56 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame);
57 static int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
58 camera_media_packet_data *mp_data, media_packet_h *packet);
59 static int _camera_media_packet_data_create(int tbm_key, int num_buffer_key, tbm_bo bo,
60 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data);
61 static void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info);
64 static void __camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value)
67 api < 0 || api >= MUSE_CAMERA_API_MAX) {
68 LOGE("invalid param %p %d", cb_info, api);
72 g_mutex_lock(&(cb_info->api_mutex[api]));
73 cb_info->api_waiting[api] += value;
74 g_mutex_unlock(&(cb_info->api_mutex[api]));
76 /*LOGD("api %d, value %d, waiting %d",
77 api, value, cb_info->api_waiting[api]);*/
83 static void __camera_device_state_changed_cb(GDBusConnection *connection,
84 const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
85 const gchar *signal_name, GVariant *param, gpointer user_data)
88 camera_device_e device = CAMERA_DEVICE_CAMERA0;
89 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
90 GList *tmp_list = NULL;
91 camera_cb_info *info = NULL;
93 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
95 if (!g_cam_dev_state_changed_cb_list || !param) {
96 LOGW("no callback or NULL param %p", param);
100 /* get device and state */
101 g_variant_get(param, "(i)", &value);
103 device = value >> 16;
104 state = 0x0000ffff & value;
106 LOGD("device %d, state %d", device, state);
108 tmp_list = g_cam_dev_state_changed_cb_list;
111 info = (camera_cb_info *)tmp_list->data;
114 if (info->callback) {
115 LOGD("start id[%d] callback", info->id);
116 ((camera_device_state_changed_cb)info->callback)(device, state, info->user_data);
117 LOGD("returned id[%d] callback", info->id);
119 LOGW("NULL callback for id %d", info->id);
123 tmp_list = tmp_list->next;
127 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
133 static void __camera_event_handler_preview(camera_cb_info_s *cb_info, char *recv_msg)
137 int num_buffer_key = 0;
138 int buffer_key[BUFFER_MAX_PLANE_NUM] = {0, };
141 unsigned char *buf_pos = NULL;
142 camera_msg_param param;
145 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
146 tbm_bo_handle bo_handle = {.ptr = NULL};
147 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
148 tbm_bo data_bo = NULL;
149 tbm_bo_handle data_bo_handle = {.ptr = NULL};
151 camera_preview_data_s frame;
152 camera_stream_data_s *stream = NULL;
153 camera_media_packet_data *mp_data = NULL;
154 media_packet_h pkt = NULL;
155 media_packet_h pkt_evas = NULL;
157 if (!cb_info || !recv_msg) {
158 LOGE("invalid param %p %p", cb_info, recv_msg);
162 muse_camera_msg_get(tbm_key, recv_msg);
163 muse_camera_msg_get(num_buffer_key, recv_msg);
164 muse_camera_msg_get_array(buffer_key, recv_msg);
165 muse_camera_msg_get(data_key, recv_msg);
167 memset(&frame, 0x0, sizeof(camera_preview_data_s));
170 LOGE("invalid key %d", tbm_key);
174 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
176 if (num_buffer_key < 0 || num_buffer_key > BUFFER_MAX_PLANE_NUM) {
177 LOGE("invalid num buffer key %d", num_buffer_key);
178 goto _PREVIEW_CB_HANDLER_DONE;
182 /* import tbm data_bo and get virtual address */
183 if (!_camera_import_tbm_key(cb_info->bufmgr, data_key, &data_bo, &data_bo_handle)) {
184 LOGE("failed to import data key %d", data_key);
185 goto _PREVIEW_CB_HANDLER_DONE;
189 /* import tbm bo and get virtual address */
190 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
191 LOGE("failed to import key %d", tbm_key);
192 goto _PREVIEW_CB_HANDLER_DONE;
195 buf_pos = (unsigned char *)bo_handle.ptr;
197 /* get stream info */
198 stream = (camera_stream_data_s *)buf_pos;
200 for (i = 0 ; i < num_buffer_key ; i++) {
201 /* import buffer bo and get virtual address */
202 if (!_camera_import_tbm_key(cb_info->bufmgr, buffer_key[i], &buffer_bo[i], &buffer_bo_handle[i])) {
203 LOGE("failed to import buffer key %d", buffer_key[i]);
204 goto _PREVIEW_CB_HANDLER_DONE;
208 /* call preview callback */
209 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
210 _camera_preview_frame_create(stream, num_buffer_key, buffer_bo_handle, &data_bo_handle, &frame);
212 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
213 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
216 if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
217 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
219 if (ret == CAMERA_ERROR_NONE) {
220 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt_evas);
221 if (ret != CAMERA_ERROR_NONE) {
222 LOGE("create pkt for evas failed");
223 _camera_media_packet_data_release(mp_data, cb_info);
229 /* call media packet callback */
230 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
231 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
233 if (ret == CAMERA_ERROR_NONE) {
234 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt);
236 if (ret == CAMERA_ERROR_NONE) {
237 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
238 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
240 _camera_media_packet_data_release(mp_data, cb_info);
246 /* call evas renderer */
248 if (cb_info->run_evas_render) {
249 mm_display_interface_evas_render(cb_info->dp_interface, pkt_evas);
251 LOGW("evas renderer is stopped, skip this buffer...");
252 media_packet_destroy(pkt_evas);
257 /* send message for preview callback return */
258 if (!CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS))
259 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info, NULL, 0);
261 _PREVIEW_CB_HANDLER_DONE:
262 if (mp_data == NULL) {
263 /* release imported bo */
264 for (i = 0 ; i < num_buffer_key && i < BUFFER_MAX_PLANE_NUM ; i++)
265 _camera_release_imported_bo(&buffer_bo[i]);
267 /* unmap and unref tbm bo */
268 _camera_release_imported_bo(&data_bo);
269 _camera_release_imported_bo(&bo);
272 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
274 /*LOGD("return buffer Done");*/
281 static void __camera_event_handler_capture(camera_cb_info_s *cb_info, char *recv_msg)
284 int tbm_key_main = 0;
285 int tbm_key_post = 0;
286 int tbm_key_thumb = 0;
287 unsigned char *buf_pos = NULL;
289 camera_msg_param param;
290 camera_image_data_s *rImage = NULL;
291 camera_image_data_s *rPostview = NULL;
292 camera_image_data_s *rThumbnail = NULL;
294 tbm_bo bo_main = NULL;
295 tbm_bo bo_post = NULL;
296 tbm_bo bo_thumb = NULL;
297 tbm_bo_handle bo_main_handle = {.ptr = NULL};
298 tbm_bo_handle bo_post_handle = {.ptr = NULL};
299 tbm_bo_handle bo_thumb_handle = {.ptr = NULL};
301 if (!cb_info || !recv_msg) {
302 LOGE("invalid param %p %p", cb_info, recv_msg);
306 muse_camera_msg_get(tbm_key_main, recv_msg);
307 muse_camera_msg_get(tbm_key_post, recv_msg);
308 muse_camera_msg_get(tbm_key_thumb, recv_msg);
311 LOGD("camera capture callback came in. tbm_key_main %d, tbm_key_post %d, tbm_key_thumb %d",
312 tbm_key_main, tbm_key_post, tbm_key_thumb);
315 if (tbm_key_main <= 0) {
316 LOGE("invalid key %d", tbm_key_main);
317 goto _CAPTURE_CB_HANDLER_DONE;
320 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] == NULL) {
321 LOGW("NULL callback");
322 goto _CAPTURE_CB_HANDLER_DONE;
325 /* import tbm bo and get virtual address */
326 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_main, &bo_main, &bo_main_handle)) {
327 LOGE("failed to import key [%d] for main", tbm_key_main);
328 goto _CAPTURE_CB_HANDLER_DONE;
331 buf_pos = (unsigned char *)bo_main_handle.ptr;
332 rImage = (camera_image_data_s *)buf_pos;
333 rImage->data = buf_pos + sizeof(camera_image_data_s);
334 if (rImage->exif && rImage->exif_size > 0) {
335 rImage->exif = rImage->data + rImage->size;
338 rImage->exif_size = 0;
341 LOGD("image info %dx%d, size %d, EXIF info %p, size %d",
342 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
344 if (tbm_key_post > 0) {
345 /* import tbm bo and get virtual address */
346 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key_post, &bo_post, &bo_post_handle)) {
347 buf_pos = (unsigned char *)bo_post_handle.ptr;
348 rPostview = (camera_image_data_s *)buf_pos;
349 LOGD("rPostview->size : %d", rPostview->size);
350 rPostview->data = buf_pos + sizeof(camera_image_data_s);
352 LOGE("failed to import key [%d] for postview", tbm_key_post);
356 if (tbm_key_thumb > 0) {
357 /* import tbm bo and get virtual address */
358 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key_thumb, &bo_thumb, &bo_thumb_handle)) {
359 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
360 rThumbnail = (camera_image_data_s *)buf_pos;
361 LOGD("rThumbnail->size : %d", rThumbnail->size);
362 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
364 LOGE("failed to import key [%d] for thumbnail", tbm_key_thumb);
368 ((camera_capturing_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE])(rImage,
369 rPostview, rThumbnail, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE]);
371 _CAPTURE_CB_HANDLER_DONE:
373 if (tbm_key_main > 0) {
374 _camera_release_imported_bo(&bo_main);
376 tbm_key = tbm_key_main;
377 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
379 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
382 if (tbm_key_post > 0) {
383 _camera_release_imported_bo(&bo_post);
385 tbm_key = tbm_key_post;
386 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
388 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
391 if (tbm_key_thumb > 0) {
392 _camera_release_imported_bo(&bo_thumb);
394 tbm_key = tbm_key_thumb;
395 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
397 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
400 LOGD("return buffer done");
406 static void __camera_event_handler_face_detection(camera_cb_info_s *cb_info, char *recv_msg)
410 camera_detected_face_s *faces = NULL;
411 camera_msg_param param;
414 tbm_bo_handle bo_handle = {.ptr = NULL};
416 if (!cb_info || !recv_msg) {
417 LOGE("invalid param %p %p", cb_info, recv_msg);
421 muse_camera_msg_get(count, recv_msg);
422 muse_camera_msg_get(tbm_key, recv_msg);
424 if (count >= 0 && cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]) {
425 LOGD("FACE_DETECTION - count %d, tbm_key %d", count, tbm_key);
429 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
431 faces = bo_handle.ptr;
435 ((camera_face_detected_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION])(faces,
436 count, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
439 _camera_release_imported_bo(&bo);
441 LOGW("skip face detection message [count %d, key %d, cb %p",
442 count, tbm_key, cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
447 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
448 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
449 /*LOGD("return buffer done");*/
456 static int _camera_import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle)
458 tbm_bo tmp_bo = NULL;
459 tbm_bo_handle tmp_bo_handle = {NULL, };
461 if (!bufmgr || !bo || !bo_handle || !tbm_key) {
462 LOGE("invalid parameter - %p %p %p, key %d",
463 bufmgr, bo, bo_handle, tbm_key);
467 tmp_bo = tbm_bo_import(bufmgr, tbm_key);
468 if (tmp_bo == NULL) {
469 LOGE("import failed - key %d", tbm_key);
473 tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
474 if (tmp_bo_handle.ptr == NULL) {
475 LOGE("map failed %p", tmp_bo);
476 tbm_bo_unref(tmp_bo);
481 tbm_bo_unmap(tmp_bo);
483 /* set bo and bo_handle */
485 *bo_handle = tmp_bo_handle;
490 static void _camera_release_imported_bo(tbm_bo *bo)
503 static int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
505 int ret = CAMERA_ERROR_NONE;
508 /*LOGD("Enter api : %d", api);*/
510 if (!cb_info->is_server_connected) {
511 LOGE("server is disconnected");
512 return CAMERA_ERROR_SERVICE_DISCONNECTED;
515 g_mutex_lock(&(cb_info->api_mutex[api]));
517 if (cb_info->api_activating[api] == 0) {
518 if (time_out == CAMERA_CB_NO_TIMEOUT) {
519 LOGW("wait for api %d", api);
520 g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
521 ret = cb_info->api_ret[api];
522 cb_info->api_activating[api] = 0;
523 LOGW("api %d returned 0x%x", api, ret);
525 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
526 if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
527 ret = cb_info->api_ret[api];
528 cb_info->api_activating[api] = 0;
529 /*LOGD("return value : 0x%x", ret);*/
531 ret = CAMERA_ERROR_INVALID_OPERATION;
532 LOGE("api %d was TIMED OUT!", api);
536 ret = cb_info->api_ret[api];
537 cb_info->api_activating[api] = 0;
539 /*LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);*/
542 g_mutex_unlock(&(cb_info->api_mutex[api]));
544 if (ret != CAMERA_ERROR_NONE)
545 LOGE("api %d : error 0x%x", api, ret);
551 static void _camera_msg_send(int api, camera_cb_info_s *cb_info,
552 int *ret, int timeout)
558 LOGE("NULL info - api %d", api);
561 *ret = CAMERA_ERROR_INVALID_PARAMETER;
566 msg = muse_core_msg_new(api, NULL);
568 LOGE("msg failed: api %d", api);
571 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
576 /*LOGD("send msg %s", msg);*/
578 if (cb_info->is_server_connected) {
579 __camera_update_api_waiting(cb_info, api, 1);
581 g_mutex_lock(&cb_info->fd_lock);
582 send_ret = muse_core_msg_send(cb_info->fd, msg);
583 g_mutex_unlock(&cb_info->fd_lock);
587 LOGE("msg send failed");
589 *ret = CAMERA_ERROR_INVALID_OPERATION;
592 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
595 __camera_update_api_waiting(cb_info, api, -1);
597 muse_core_msg_free(msg);
603 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
604 int *ret, camera_msg_param *param, int timeout)
609 if (!cb_info || !param) {
610 LOGE("invalid pointer : api %d - %p %p", api, cb_info, param);
613 *ret = CAMERA_ERROR_INVALID_PARAMETER;
618 /*LOGD("type %d, name %s", param->type, param->name);*/
620 switch (param->type) {
622 msg = muse_core_msg_new(api,
623 param->type, param->name, param->value.value_INT,
626 case MUSE_TYPE_STRING:
627 msg = muse_core_msg_new(api,
628 param->type, param->name, param->value.value_STRING,
632 LOGE("unknown type %d", param->type);
637 LOGE("msg failed: api %d", api);
640 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
645 /*LOGD("send msg %s", msg);*/
647 if (cb_info->is_server_connected) {
648 __camera_update_api_waiting(cb_info, api, 1);
650 g_mutex_lock(&cb_info->fd_lock);
651 send_ret = muse_core_msg_send(cb_info->fd, msg);
652 g_mutex_unlock(&cb_info->fd_lock);
656 LOGE("msg send failed");
659 *ret = CAMERA_ERROR_INVALID_OPERATION;
662 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
665 __camera_update_api_waiting(cb_info, api, -1);
667 muse_core_msg_free(msg);
673 static void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
674 int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout)
676 int func_ret = CAMERA_ERROR_NONE;
680 if (!cb_info || !param0 || !param1) {
681 LOGE("invalid ptr %p %p %p : api %d",
682 cb_info, param0, param1, api);
683 func_ret = CAMERA_ERROR_INVALID_PARAMETER;
684 goto _SEND_PARAM2_INT_DONE;
687 /*LOGD("api %d, param0 [%s:%d], param1 [%s:%d]",
689 param0->name, param0->value.value_INT,
690 param1->name, param1->value.value_INT);*/
692 msg = muse_core_msg_new(api,
693 param0->type, param0->name, param0->value.value_INT,
694 param1->type, param1->name, param1->value.value_INT,
697 LOGE("msg failed: api %d", api);
698 func_ret = CAMERA_ERROR_OUT_OF_MEMORY;
699 goto _SEND_PARAM2_INT_DONE;
702 /*LOGD("send msg [%s]", msg);*/
704 if (cb_info->is_server_connected) {
705 __camera_update_api_waiting(cb_info, api, 1);
707 g_mutex_lock(&cb_info->fd_lock);
708 send_ret = muse_core_msg_send(cb_info->fd, msg);
709 g_mutex_unlock(&cb_info->fd_lock);
713 LOGE("msg send failed");
715 func_ret = CAMERA_ERROR_INVALID_OPERATION;
717 func_ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
720 __camera_update_api_waiting(cb_info, api, -1);
722 muse_core_msg_free(msg);
724 _SEND_PARAM2_INT_DONE:
732 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
734 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
735 in_format >= MM_PIXEL_FORMAT_NUM ||
736 out_format == NULL) {
737 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
738 return CAMERA_ERROR_INVALID_PARAMETER;
742 case MM_PIXEL_FORMAT_NV12:
743 case MM_PIXEL_FORMAT_NV12T:
744 *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;
785 return CAMERA_ERROR_NONE;
789 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
791 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
792 in_format >= MM_PIXEL_FORMAT_NUM ||
794 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
795 return CAMERA_ERROR_INVALID_PARAMETER;
799 case MM_PIXEL_FORMAT_NV12:
800 case MM_PIXEL_FORMAT_NV12T:
801 *mimetype = MEDIA_FORMAT_NV12;
803 case MM_PIXEL_FORMAT_NV16:
804 *mimetype = MEDIA_FORMAT_NV16;
806 case MM_PIXEL_FORMAT_NV21:
807 *mimetype = MEDIA_FORMAT_NV21;
809 case MM_PIXEL_FORMAT_YUYV:
810 *mimetype = MEDIA_FORMAT_YUYV;
812 case MM_PIXEL_FORMAT_UYVY:
813 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
814 *mimetype = MEDIA_FORMAT_UYVY;
816 case MM_PIXEL_FORMAT_422P:
817 *mimetype = MEDIA_FORMAT_422P;
819 case MM_PIXEL_FORMAT_I420:
820 *mimetype = MEDIA_FORMAT_I420;
822 case MM_PIXEL_FORMAT_YV12:
823 *mimetype = MEDIA_FORMAT_YV12;
825 case MM_PIXEL_FORMAT_RGB565:
826 *mimetype = MEDIA_FORMAT_RGB565;
828 case MM_PIXEL_FORMAT_RGB888:
829 *mimetype = MEDIA_FORMAT_RGB888;
831 case MM_PIXEL_FORMAT_RGBA:
832 *mimetype = MEDIA_FORMAT_RGBA;
834 case MM_PIXEL_FORMAT_ARGB:
835 *mimetype = MEDIA_FORMAT_ARGB;
838 LOGE("invalid in_format %d", in_format);
839 return CAMERA_ERROR_INVALID_PARAMETER;
842 return CAMERA_ERROR_NONE;
845 static void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_key,
846 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame)
849 unsigned char *buf_pos = NULL;
851 if (stream == NULL || buffer_bo_handle == NULL || frame == NULL) {
852 LOGE("invalid parameter - stream:%p, buffer_bo_handle:%p", stream, buffer_bo_handle);
857 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
858 frame->format = MM_PIXEL_FORMAT_UYVY;
860 frame->format = stream->format;
862 frame->width = stream->width;
863 frame->height = stream->height;
864 frame->timestamp = stream->timestamp;
865 frame->num_of_planes = stream->num_planes;
867 if (num_buffer_key == 0) {
869 if (!data_bo_handle || !data_bo_handle->ptr) {
870 LOGE("NULL pointer");
874 buf_pos = data_bo_handle->ptr;
876 if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) {
877 frame->data.encoded_plane.data = buf_pos;
878 frame->data.encoded_plane.size = stream->data.encoded.length_data;
879 total_size = stream->data.encoded.length_data;
880 } else if (stream->format == MM_PIXEL_FORMAT_INVZ) {
881 frame->data.depth_plane.data = buf_pos;
882 frame->data.depth_plane.size = stream->data.depth.length_data;
883 total_size = stream->data.depth.length_data;
884 } else if (stream->format == MM_PIXEL_FORMAT_RGBA ||
885 stream->format == MM_PIXEL_FORMAT_ARGB) {
886 frame->data.rgb_plane.data = buf_pos;
887 frame->data.rgb_plane.size = stream->data.rgb.length_data;
888 total_size = stream->data.rgb.length_data;
890 switch (stream->num_planes) {
892 frame->data.single_plane.yuv = buf_pos;
893 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
894 total_size = stream->data.yuv420.length_yuv;
897 frame->data.double_plane.y = buf_pos;
898 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
899 buf_pos += stream->data.yuv420sp.length_y;
900 frame->data.double_plane.uv = buf_pos;
901 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
902 total_size = stream->data.yuv420sp.length_y + \
903 stream->data.yuv420sp.length_uv;
906 frame->data.triple_plane.y = buf_pos;
907 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
908 buf_pos += stream->data.yuv420p.length_y;
909 frame->data.triple_plane.u = buf_pos;
910 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
911 buf_pos += stream->data.yuv420p.length_u;
912 frame->data.triple_plane.v = buf_pos;
913 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
914 total_size = stream->data.yuv420p.length_y + \
915 stream->data.yuv420p.length_u + \
916 stream->data.yuv420p.length_v;
924 switch (stream->num_planes) {
926 frame->data.single_plane.yuv = buffer_bo_handle[0].ptr;
927 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
928 total_size = stream->data.yuv420.length_yuv;
931 frame->data.double_plane.y = buffer_bo_handle[0].ptr;
932 if (stream->num_planes == (unsigned int)num_buffer_key)
933 frame->data.double_plane.uv = buffer_bo_handle[1].ptr;
935 frame->data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
936 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
937 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
938 total_size = stream->data.yuv420sp.length_y + \
939 stream->data.yuv420sp.length_uv;
942 frame->data.triple_plane.y = buffer_bo_handle[0].ptr;
943 if (stream->num_planes == (unsigned int)num_buffer_key) {
944 frame->data.triple_plane.u = buffer_bo_handle[1].ptr;
945 frame->data.triple_plane.v = buffer_bo_handle[2].ptr;
947 frame->data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y;
948 frame->data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u;
950 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
951 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
952 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
953 total_size = stream->data.yuv420p.length_y + \
954 stream->data.yuv420p.length_u + \
955 stream->data.yuv420p.length_v;
963 LOGD("format %d, %dx%d, size %d plane num %d",
964 frame.format, frame.width, frame.height, total_size, frame.num_of_planes);
970 static int _camera_media_packet_data_create(int tbm_key, int num_buffer_key, tbm_bo bo,
971 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
974 int ret = CAMERA_ERROR_NONE;
975 camera_media_packet_data *tmp_mp_data = NULL;
977 if (*mp_data == NULL) {
978 tmp_mp_data = g_new0(camera_media_packet_data, 1);
980 tmp_mp_data->tbm_key = tbm_key;
981 tmp_mp_data->num_buffer_key = num_buffer_key;
982 tmp_mp_data->bo = bo;
983 tmp_mp_data->data_bo = data_bo;
984 tmp_mp_data->ref_cnt++;
986 for (i = 0 ; i < num_buffer_key ; i++)
987 tmp_mp_data->buffer_bo[i] = buffer_bo[i];
989 *mp_data = tmp_mp_data;
990 /*LOGD("mp_data %p", tmp_mp_data);*/
992 ret = CAMERA_ERROR_OUT_OF_MEMORY;
993 LOGE("failed to alloc media packet data");
996 ((camera_media_packet_data *)*mp_data)->ref_cnt++;
1002 static void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
1006 camera_msg_param param;
1008 if (!mp_data || !cb_info) {
1009 LOGE("NULL pointer %p %p", mp_data, cb_info);
1013 if (mp_data->ref_cnt > 1) {
1015 LOGD("ref count %d", mp_data->ref_cnt);
1017 /* release imported bo */
1018 for (i = 0 ; i < mp_data->num_buffer_key ; i++) {
1019 tbm_bo_unref(mp_data->buffer_bo[i]);
1020 mp_data->buffer_bo[i] = NULL;
1024 _camera_release_imported_bo(&mp_data->bo);
1025 _camera_release_imported_bo(&mp_data->data_bo);
1028 tbm_key = mp_data->tbm_key;
1030 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1032 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1041 static int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
1042 camera_media_packet_data *mp_data, media_packet_h *packet)
1044 media_packet_h pkt = NULL;
1045 bool make_pkt_fmt = false;
1046 tbm_surface_h tsurf = NULL;
1047 tbm_surface_info_s tsurf_info;
1048 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
1049 uint32_t bo_format = 0;
1052 int num_buffer_key = 0;
1053 tbm_bo *buffer_bo = NULL;
1055 if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) {
1056 LOGE("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p",
1057 cb_info, stream, mp_data, packet);
1058 return CAMERA_ERROR_INVALID_PARAMETER;
1061 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
1062 buffer_bo = mp_data->buffer_bo;
1063 num_buffer_key = mp_data->num_buffer_key;
1065 /* create tbm surface */
1066 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
1067 tsurf_info.planes[i].stride = stream->stride[i];
1069 /* get tbm surface format */
1070 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
1071 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
1073 if (ret == CAMERA_ERROR_NONE) {
1074 tsurf_info.width = stream->width;
1075 tsurf_info.height = stream->height;
1076 tsurf_info.format = bo_format;
1077 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
1078 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
1080 if (num_buffer_key > 0) {
1081 switch (bo_format) {
1082 case TBM_FORMAT_NV12:
1083 case TBM_FORMAT_NV21:
1084 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1085 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1086 tsurf_info.planes[0].offset = 0;
1087 if (num_buffer_key == 1)
1088 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1089 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1091 case TBM_FORMAT_YUV420:
1092 case TBM_FORMAT_YVU420:
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[2].size = stream->stride[2] * stream->elevation[2];
1096 tsurf_info.planes[0].offset = 0;
1097 if (num_buffer_key == 1) {
1098 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1099 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1101 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1103 case TBM_FORMAT_UYVY:
1104 case TBM_FORMAT_YUYV:
1105 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
1106 tsurf_info.planes[0].offset = 0;
1107 tsurf_info.size = tsurf_info.planes[0].size;
1113 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_key);
1114 } else if (mp_data->data_bo) {
1115 switch (bo_format) {
1116 case TBM_FORMAT_NV12:
1117 case TBM_FORMAT_NV21:
1118 tsurf_info.planes[0].size = stream->width * stream->height;
1119 tsurf_info.planes[1].size = (tsurf_info.planes[0].size) >> 1;
1120 tsurf_info.planes[0].offset = 0;
1121 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1122 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1124 case TBM_FORMAT_YUV420:
1125 case TBM_FORMAT_YVU420:
1126 tsurf_info.planes[0].size = stream->width * stream->height;
1127 tsurf_info.planes[1].size = (stream->width >> 1) * (stream->height >> 1);
1128 tsurf_info.planes[2].size = tsurf_info.planes[1].size;
1129 tsurf_info.planes[0].offset = 0;
1130 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1131 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1132 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1134 case TBM_FORMAT_UYVY:
1135 case TBM_FORMAT_YUYV:
1136 tsurf_info.planes[0].size = (stream->width * stream->height) << 1;
1137 tsurf_info.planes[0].offset = 0;
1138 tsurf_info.size = tsurf_info.planes[0].size;
1144 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1);
1146 /*LOGD("tbm surface %p", tsurf);*/
1150 /* check media packet format */
1151 if (cb_info->pkt_fmt) {
1152 int pkt_fmt_width = 0;
1153 int pkt_fmt_height = 0;
1154 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
1156 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
1157 if (pkt_fmt_mimetype != mimetype ||
1158 pkt_fmt_width != stream->width ||
1159 pkt_fmt_height != stream->height) {
1160 LOGW("change fmt: current 0x%x, %dx%d",
1161 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
1162 media_format_unref(cb_info->pkt_fmt);
1163 cb_info->pkt_fmt = NULL;
1164 make_pkt_fmt = true;
1167 make_pkt_fmt = true;
1170 /* create packet format */
1172 LOGW("make new pkt_fmt - 0x%x, %dx%d", mimetype, stream->width, stream->height);
1173 ret = media_format_create(&cb_info->pkt_fmt);
1174 if (ret == MEDIA_FORMAT_ERROR_NONE) {
1175 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
1176 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
1177 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
1178 LOGW("media_format_set : 0x%x", ret);
1180 LOGW("media_format_create failed 0x%x", ret);
1184 /* create media packet */
1185 ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt,
1186 tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
1187 (void *)cb_info, &pkt);
1188 if (ret != MEDIA_PACKET_ERROR_NONE) {
1189 LOGE("media_packet_create failed 0x%x", ret);
1190 tbm_surface_destroy(tsurf);
1194 LOGE("tbm surface failed. %dx%d, format %d, num_buffer_key %d, data_bo %p",
1195 stream->width, stream->height, stream->format, num_buffer_key, mp_data->data_bo);
1199 /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
1200 /* set media packet data */
1201 ret = media_packet_set_extra(pkt, (void *)mp_data);
1202 if (ret != MEDIA_PACKET_ERROR_NONE) {
1203 LOGE("media_packet_set_extra failed");
1205 _camera_media_packet_data_release(mp_data, cb_info);
1208 media_packet_destroy(pkt);
1211 /* set timestamp : msec -> nsec */
1212 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
1213 LOGW("media_packet_set_pts failed");
1222 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
1225 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1226 camera_media_packet_data *mp_data = NULL;
1227 tbm_surface_h tsurf = NULL;
1229 if (!pkt || !cb_info) {
1230 LOGE("NULL pointer %p %p", pkt, cb_info);
1231 return MEDIA_PACKET_FINALIZE;
1234 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1235 if (ret != MEDIA_PACKET_ERROR_NONE) {
1236 LOGE("media_packet_get_extra failed 0x%x", ret);
1237 return MEDIA_PACKET_FINALIZE;
1240 /*LOGD("mp_data %p", mp_data);*/
1242 g_mutex_lock(&cb_info->mp_data_mutex);
1244 _camera_media_packet_data_release(mp_data, cb_info);
1247 g_mutex_unlock(&cb_info->mp_data_mutex);
1249 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1250 if (ret != MEDIA_PACKET_ERROR_NONE)
1251 LOGE("get tbm_surface failed 0x%x", ret);
1254 tbm_surface_destroy(tsurf);
1258 return MEDIA_PACKET_FINALIZE;
1261 static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event)
1266 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1267 LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event);
1271 /*LOGD("get camera msg %s, event %d", recv_msg, event);*/
1273 g_mutex_lock(&cb_info->user_cb_mutex[event]);
1275 if (cb_info->user_cb[event] == NULL) {
1276 if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
1277 event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
1278 event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
1279 event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1280 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1281 LOGW("NULL callback for event %d, return here", event);
1285 /* return buffer message should be sent for some events.
1286 - MUSE_CAMERA_EVENT_TYPE_PREVIEW
1287 - MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW
1288 - MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION
1289 - MUSE_CAMERA_EVENT_TYPE_CAPTURE
1294 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1300 muse_camera_msg_get(previous, recv_msg);
1301 muse_camera_msg_get(current, recv_msg);
1302 muse_camera_msg_get(by_policy, recv_msg);
1304 LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
1305 previous, current, by_policy);
1307 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1308 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1311 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1315 muse_camera_msg_get(state, recv_msg);
1317 LOGD("FOCUS state - %d", state);
1319 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1322 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1323 LOGD("CAPTURE_COMPLETED");
1324 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1326 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1327 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1328 __camera_event_handler_preview(cb_info, recv_msg);
1330 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1334 muse_camera_msg_get(percent, recv_msg);
1336 LOGD("HDR progress - %d %%", percent);
1338 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1341 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1347 muse_camera_msg_get(policy, recv_msg);
1348 muse_camera_msg_get(previous, recv_msg);
1349 muse_camera_msg_get(current, recv_msg);
1351 LOGW("INTERRUPTED - policy %d, state %d -> %d", policy, previous, current);
1353 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1354 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1357 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1362 muse_camera_msg_get(policy, recv_msg);
1363 muse_camera_msg_get(state, recv_msg);
1365 LOGW("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1367 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1368 (camera_state_e)state, cb_info->user_data[event]);
1371 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1372 __camera_event_handler_face_detection(cb_info, recv_msg);
1374 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1377 int current_state = 0;
1379 muse_camera_msg_get(error, recv_msg);
1380 muse_camera_msg_get(current_state, recv_msg);
1382 LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
1384 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1385 (camera_state_e)current_state, cb_info->user_data[event]);
1388 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1390 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1391 muse_camera_msg_get(param1, recv_msg);
1392 muse_camera_msg_get(param2, recv_msg);
1394 /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/
1396 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1397 cb_info->user_cb[event] = NULL;
1398 cb_info->user_data[event] = NULL;
1399 LOGW("stop foreach callback for event %d", event);
1402 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1404 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1406 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1408 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1410 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1412 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1414 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1416 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1418 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1420 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1422 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1424 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1426 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1428 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1430 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1431 muse_camera_msg_get(param1, recv_msg);
1433 /*LOGD("event %d SUPPORTED %d ", event, param1);*/
1435 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1436 cb_info->user_cb[event] = NULL;
1437 cb_info->user_data[event] = NULL;
1438 LOGW("stop foreach callback for event %d", event);
1441 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1442 __camera_event_handler_capture(cb_info, recv_msg);
1445 LOGW("unhandled event %d", event);
1449 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1454 static gboolean _camera_idle_event_callback(gpointer data)
1456 camera_cb_info_s *cb_info = NULL;
1457 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1459 if (cam_idle_event == NULL) {
1460 LOGE("cam_idle_event is NULL");
1465 g_mutex_lock(&g_cam_idle_event_lock);
1467 cb_info = cam_idle_event->cb_info;
1468 if (cb_info == NULL) {
1469 LOGW("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1470 g_mutex_unlock(&g_cam_idle_event_lock);
1471 goto IDLE_EVENT_CALLBACK_DONE;
1474 /* remove event from list */
1475 if (cb_info->idle_event_list)
1476 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1478 g_mutex_unlock(&g_cam_idle_event_lock);
1481 _camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
1483 IDLE_EVENT_CALLBACK_DONE:
1485 g_free(cam_idle_event);
1486 cam_idle_event = NULL;
1491 static void *_camera_msg_handler_func(gpointer data)
1495 camera_message_s *cam_msg = NULL;
1496 camera_idle_event_s *cam_idle_event = NULL;
1497 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1498 camera_cb_info_s *cb_info = NULL;
1500 if (!handler_info || !handler_info->cb_info) {
1501 LOGE("NULL handler %p", handler_info);
1505 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1506 type = handler_info->type;
1508 LOGD("t:%d start", type);
1510 g_mutex_lock(&handler_info->mutex);
1512 while (g_atomic_int_get(&handler_info->running)) {
1513 if (g_queue_is_empty(handler_info->queue)) {
1514 /*LOGD("t:%d signal wait...", type);*/
1515 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1516 /*LOGD("t:%d signal received", type);*/
1518 if (g_atomic_int_get(&handler_info->running) == 0) {
1519 LOGD("t:%d stop event thread", type);
1524 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1526 g_mutex_unlock(&handler_info->mutex);
1528 if (cam_msg == NULL) {
1529 LOGE("t:%d NULL message", type);
1530 g_mutex_lock(&handler_info->mutex);
1536 if (api < MUSE_CAMERA_API_MAX) {
1539 g_mutex_lock(&cb_info->api_mutex[api]);
1541 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1542 if (cb_info->api_waiting[api] > 0) {
1543 cb_info->api_ret[api] = ret;
1544 cb_info->api_activating[api] = 1;
1546 /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
1548 g_cond_signal(&cb_info->api_cond[api]);
1550 LOGW("no waiting for this api [%d]", api);
1553 LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1556 g_mutex_unlock(&cb_info->api_mutex[api]);
1557 } else if (api == MUSE_CAMERA_CB_EVENT) {
1558 switch (cam_msg->event_class) {
1559 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1560 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event);
1562 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1563 cam_idle_event = g_new0(camera_idle_event_s, 1);
1564 if (cam_idle_event == NULL) {
1565 LOGE("t:%d cam_idle_event alloc failed", type);
1569 cam_idle_event->event = cam_msg->event;
1570 cam_idle_event->cb_info = cb_info;
1572 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg) - 1);
1574 /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, cam_msg->event, cam_idle_event);*/
1576 g_mutex_lock(&g_cam_idle_event_lock);
1577 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1578 g_mutex_unlock(&g_cam_idle_event_lock);
1580 g_idle_add_full(G_PRIORITY_DEFAULT,
1581 (GSourceFunc)_camera_idle_event_callback,
1582 (gpointer)cam_idle_event,
1586 LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
1590 LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1596 g_mutex_lock(&handler_info->mutex);
1599 /* remove remained event */
1600 while (!g_queue_is_empty(handler_info->queue)) {
1601 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1603 LOGD("t:%d remove camera message %p", type, cam_msg);
1607 LOGW("t:%d NULL camera message", type);
1611 g_mutex_unlock(&handler_info->mutex);
1613 LOGD("t:%d return", type);
1619 static void _camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1621 camera_idle_event_s *cam_idle_event = NULL;
1624 if (cb_info == NULL) {
1625 LOGE("cb_info is NULL");
1629 g_mutex_lock(&g_cam_idle_event_lock);
1631 if (cb_info->idle_event_list == NULL) {
1632 LOGD("No remained idle event");
1633 g_mutex_unlock(&g_cam_idle_event_lock);
1637 list = cb_info->idle_event_list;
1640 cam_idle_event = list->data;
1641 list = g_list_next(list);
1643 if (!cam_idle_event) {
1644 LOGW("Fail to remove idle event. The event is NULL");
1648 if (g_idle_remove_by_data(cam_idle_event)) {
1649 LOGW("remove idle event %p done", cam_idle_event);
1651 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1653 g_free(cam_idle_event);
1654 cam_idle_event = NULL;
1659 LOGW("set NULL cb_info for event %p %d, it will be freed on idle callback",
1660 cam_idle_event, cam_idle_event->event);
1662 cam_idle_event->cb_info = NULL;
1664 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1667 g_list_free(cb_info->idle_event_list);
1668 cb_info->idle_event_list = NULL;
1670 g_mutex_unlock(&g_cam_idle_event_lock);
1676 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg)
1678 camera_message_s *cam_msg = NULL;
1680 if (!cb_info || !msg) {
1681 LOGE("NULL pointer %p %p", cb_info, msg);
1685 cam_msg = g_new0(camera_message_s, 1);
1687 LOGE("failed to alloc cam_msg for [%s]", msg);
1692 cam_msg->event = event;
1693 cam_msg->event_class = event_class;
1695 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1697 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1699 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1700 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1701 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1702 g_cond_signal(&cb_info->preview_cb_info.cond);
1703 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1704 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1705 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1706 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1707 g_cond_signal(&cb_info->capture_cb_info.cond);
1708 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1710 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1711 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1712 g_cond_signal(&cb_info->msg_handler_info.cond);
1713 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1722 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg)
1724 int ret = CAMERA_ERROR_NONE;
1728 int event_class = -1;
1732 if (!cb_info || !msg) {
1733 LOGE("invalid ptr %p %p", cb_info, msg);
1737 /*LOGD("msg [%s]", msg);*/
1739 if (!muse_camera_msg_get(api, msg)) {
1740 LOGE("failed to get camera api");
1744 if (api == MUSE_CAMERA_CB_EVENT) {
1745 if (!muse_camera_msg_get(event, msg) ||
1746 !muse_camera_msg_get(event_class, msg)) {
1747 LOGE("failed to get camera event or event_class [%s]", msg);
1751 if (!muse_camera_msg_get(api_class, msg)) {
1752 LOGE("failed to get camera api_class [%s]", msg);
1757 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1758 if (api >= MUSE_CAMERA_API_MAX) {
1759 LOGE("invalid api %d", api);
1763 if (!muse_camera_msg_get(ret, msg)) {
1764 LOGE("failed to get camera ret");
1768 g_mutex_lock(&cb_info->api_mutex[api]);
1771 case MUSE_CAMERA_API_CREATE:
1772 if (ret != CAMERA_ERROR_NONE) {
1773 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1774 LOGE("camera create error 0x%x. close client cb handler", ret);
1777 case MUSE_CAMERA_API_DESTROY:
1778 if (ret == CAMERA_ERROR_NONE) {
1779 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1780 LOGD("camera destroy done. close client cb handler");
1784 muse_camera_msg_get(get_type, msg);
1785 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1786 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1787 muse_camera_msg_get(get_index, msg);
1790 case MUSE_CAMERA_GET_TYPE_INT:
1791 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
1793 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1794 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
1795 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
1797 case MUSE_CAMERA_GET_TYPE_ARRAY:
1798 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
1799 muse_core_msg_deserialize("get_value",
1800 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
1801 LOGD("get display roi %d,%d,%dx%d",
1802 cb_info->get_display_roi_area[0],
1803 cb_info->get_display_roi_area[1],
1804 cb_info->get_display_roi_area[2],
1805 cb_info->get_display_roi_area[3]);
1807 muse_core_msg_deserialize("get_value",
1808 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
1809 LOGD("get geotag %lf, %lf, %lf",
1810 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
1813 case MUSE_CAMERA_GET_TYPE_STRING:
1814 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
1817 LOGW("unknown type %d", get_type);
1824 if (cb_info->api_waiting[api] > 0) {
1825 cb_info->api_ret[api] = ret;
1826 cb_info->api_activating[api] = 1;
1828 g_cond_signal(&cb_info->api_cond[api]);
1830 LOGW("no waiting for this api [%d]", api);
1833 g_mutex_unlock(&cb_info->api_mutex[api]);
1834 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
1835 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg);
1837 LOGW("unknown camera api %d, class %d", api, api_class);
1844 static void *_camera_msg_recv_func(gpointer data)
1846 int recv_length = 0;
1847 int single_length = 0;
1848 int remained_length = 0;
1849 char *recv_msg = NULL;
1850 char *single_msg = NULL;
1851 char *remained_msg = NULL;
1855 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
1858 LOGE("cb_info NULL");
1862 LOGD("start - fd : %d", cb_info->fd);
1864 single_msg = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
1866 LOGE("single_msg malloc failed");
1870 recv_msg = cb_info->recv_msg;
1872 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
1873 recv_length = muse_core_msg_recv(cb_info->fd, recv_msg, MUSE_MSG_MAX_LENGTH);
1874 if (recv_length <= 0) {
1875 cb_info->is_server_connected = FALSE;
1876 LOGE("receive msg failed - server disconnected");
1884 /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
1886 /* Need to split the combined entering msgs */
1887 for (cur_pos = 0 ; cur_pos < recv_length ; cur_pos++) {
1888 if (recv_msg[cur_pos] == '}') {
1889 single_length = cur_pos - prev_pos + 1;
1891 if (single_length < MUSE_CAMERA_MSG_MAX_LENGTH) {
1892 /* check remained msg */
1893 if (remained_length > 0) {
1895 strncpy(single_msg, remained_msg, remained_length);
1896 strncpy(single_msg + remained_length, recv_msg + prev_pos, single_length);
1897 single_msg[remained_length + single_length] = '\0';
1900 remained_msg = NULL;
1902 strncpy(single_msg, recv_msg + prev_pos, single_length);
1903 single_msg[single_length] = '\0';
1904 LOGE("lost msg [%s], skip...", single_msg);
1907 remained_length = 0;
1909 strncpy(single_msg, recv_msg + prev_pos, single_length);
1910 single_msg[single_length] = '\0';
1913 if (single_msg[0] == '{') {
1915 /*LOGD("splitted msg : [%s], Index : %d", single_msg, num_msg);*/
1916 /* process each message */
1917 __camera_process_msg(cb_info, single_msg);
1919 LOGE("invalid msg [%s]", single_msg);
1922 LOGE("too long message [len %d] skip...", single_length);
1925 prev_pos = cur_pos + 1;
1929 /* check incompleted message */
1930 if (recv_msg[recv_length - 1] != '}') {
1931 remained_length = recv_length - prev_pos;
1933 LOGW("incompleted message [len %d]", remained_length);
1937 remained_msg = NULL;
1940 remained_msg = (char *)malloc(remained_length + 1);
1942 strncpy(remained_msg, recv_msg + prev_pos, remained_length);
1943 remained_msg[remained_length] = '\0';
1945 LOGE("failed to alloc for remained msg");
1948 remained_length = 0;
1952 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
1954 if (!cb_info->is_server_connected) {
1955 char *error_msg = NULL;
1957 if (cb_info->fd < 0) {
1958 LOGE("fd is closed in client side");
1959 goto CB_HANDLER_EXIT;
1962 /* send error msg for server disconnection */
1963 error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
1964 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
1965 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
1969 LOGE("error_msg failed");
1970 goto CB_HANDLER_EXIT;
1973 __camera_add_msg_to_queue(cb_info,
1974 MUSE_CAMERA_CB_EVENT,
1975 MUSE_CAMERA_EVENT_TYPE_ERROR,
1976 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
1979 muse_core_msg_free(error_msg);
1982 LOGE("add error msg for service disconnection done");
1993 remained_msg = NULL;
2000 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2001 int type, const char *thread_name, camera_cb_info_s *cb_info)
2003 if (!handler_info || !thread_name || !cb_info) {
2004 LOGE("t:%d NULL %p %p %p",
2005 type, handler_info, thread_name, cb_info);
2011 handler_info->type = type;
2012 handler_info->queue = g_queue_new();
2013 if (handler_info->queue == NULL) {
2014 LOGE("t:%d queue failed", type);
2018 g_mutex_init(&handler_info->mutex);
2019 g_cond_init(&handler_info->cond);
2021 handler_info->cb_info = (void *)cb_info;
2022 g_atomic_int_set(&handler_info->running, 1);
2024 handler_info->thread = g_thread_try_new(thread_name,
2025 _camera_msg_handler_func, (gpointer)handler_info, NULL);
2026 if (handler_info->thread == NULL) {
2027 LOGE("t:%d thread failed", type);
2029 g_mutex_clear(&handler_info->mutex);
2030 g_cond_clear(&handler_info->cond);
2031 g_queue_free(handler_info->queue);
2032 handler_info->queue = NULL;
2037 LOGD("t:%d done", type);
2043 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2047 if (!handler_info) {
2048 LOGE("NULL handler");
2052 if (!handler_info->thread) {
2053 LOGW("thread is not created");
2057 type = handler_info->type;
2059 LOGD("t:%d thread %p", type, handler_info->thread);
2061 g_mutex_lock(&handler_info->mutex);
2062 g_atomic_int_set(&handler_info->running, 0);
2063 g_cond_signal(&handler_info->cond);
2064 g_mutex_unlock(&handler_info->mutex);
2066 g_thread_join(handler_info->thread);
2067 handler_info->thread = NULL;
2069 g_mutex_clear(&handler_info->mutex);
2070 g_cond_clear(&handler_info->cond);
2071 g_queue_free(handler_info->queue);
2072 handler_info->queue = NULL;
2074 LOGD("t:%d done", type);
2080 static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
2082 camera_cb_info_s *cb_info = NULL;
2085 g_return_val_if_fail(sockfd > 0, NULL);
2087 cb_info = g_new0(camera_cb_info_s, 1);
2088 if (cb_info == NULL) {
2089 LOGE("cb_info failed");
2093 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2095 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2096 g_mutex_init(&cb_info->api_mutex[i]);
2097 g_cond_init(&cb_info->api_cond[i]);
2100 g_mutex_init(&cb_info->fd_lock);
2101 g_mutex_init(&cb_info->mp_data_mutex);
2103 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2104 g_mutex_init(&cb_info->user_cb_mutex[i]);
2106 /* message handler thread */
2107 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2108 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2109 LOGE("msg_handler_info failed");
2113 /* message handler thread for preview callback */
2114 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2115 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2116 LOGE("preview_cb_info failed");
2120 /* message handler thread for capture callback */
2121 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2122 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2123 LOGE("capture_cb_info failed");
2127 cb_info->fd = sockfd;
2128 cb_info->preview_cb_flag = 0;
2130 /* message receive thread */
2131 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2132 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2133 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2134 if (cb_info->msg_recv_thread == NULL) {
2135 LOGE("message receive thread creation failed");
2139 cb_info->is_server_connected = TRUE;
2145 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2146 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2147 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2149 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2150 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2152 g_mutex_clear(&cb_info->fd_lock);
2153 g_mutex_clear(&cb_info->mp_data_mutex);
2155 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2156 g_mutex_clear(&cb_info->api_mutex[i]);
2157 g_cond_clear(&cb_info->api_cond[i]);
2167 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2171 g_return_if_fail(cb_info != NULL);
2173 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2175 g_thread_join(cb_info->msg_recv_thread);
2176 cb_info->msg_recv_thread = NULL;
2178 LOGD("msg_recv thread removed");
2180 /* destroy msg handler threads */
2181 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2182 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2183 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2185 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2186 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2188 g_mutex_clear(&cb_info->fd_lock);
2189 g_mutex_clear(&cb_info->mp_data_mutex);
2191 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2192 g_mutex_clear(&cb_info->api_mutex[i]);
2193 g_cond_clear(&cb_info->api_cond[i]);
2196 if (cb_info->fd > -1) {
2197 muse_client_close(cb_info->fd);
2201 if (cb_info->bufmgr) {
2202 tbm_bufmgr_deinit(cb_info->bufmgr);
2203 cb_info->bufmgr = NULL;
2205 if (cb_info->pkt_fmt) {
2206 media_format_unref(cb_info->pkt_fmt);
2207 cb_info->pkt_fmt = NULL;
2210 if (cb_info->dp_interface) {
2211 mm_display_interface_deinit(cb_info->dp_interface);
2212 cb_info->dp_interface = NULL;
2215 cb_info->preview_cb_flag = 0;
2224 int _camera_start_evas_rendering(camera_h camera)
2226 camera_cli_s *pc = (camera_cli_s *)camera;
2228 if (!pc || !pc->cb_info) {
2229 LOGE("NULL handle");
2230 return CAMERA_ERROR_INVALID_PARAMETER;
2235 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2236 LOGE("EVAS surface is not set");
2237 return CAMERA_ERROR_NONE;
2240 /* set evas render flag as RUN */
2241 pc->cb_info->run_evas_render = true;
2243 return CAMERA_ERROR_NONE;
2247 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2249 int ret = CAMERA_ERROR_NONE;
2250 camera_cli_s *pc = (camera_cli_s *)camera;
2252 if (!pc || !pc->cb_info) {
2253 LOGE("NULL handle");
2254 return CAMERA_ERROR_INVALID_PARAMETER;
2257 LOGD("stop - keep screen %d", keep_screen);
2259 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2260 LOGE("EVAS surface is not set");
2261 return CAMERA_ERROR_NONE;
2264 /* set evas render flag as STOP and release buffers */
2265 pc->cb_info->run_evas_render = false;
2267 ret = mm_display_interface_evas_flush(pc->cb_info->dp_interface, keep_screen);
2268 if (ret == MM_ERROR_NONE) {
2269 ret = CAMERA_ERROR_NONE;
2271 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2272 ret = CAMERA_ERROR_INVALID_OPERATION;
2279 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2281 int ret = CAMERA_ERROR_NONE;
2283 int module_index = -1;
2285 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2287 /* create muse connection */
2288 if (!key || !value) {
2289 LOGE("NULL pointer");
2290 return CAMERA_ERROR_INVALID_PARAMETER;
2293 sock_fd = muse_client_new();
2295 LOGE("muse_client_new failed");
2296 return CAMERA_ERROR_INVALID_OPERATION;
2299 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2300 LOGE("muse client get module index failed");
2301 ret = CAMERA_ERROR_INVALID_OPERATION;
2305 msg = muse_core_msg_new(api,
2306 MUSE_TYPE_INT, "module", module_index,
2307 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2311 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2315 ret = muse_core_msg_send(sock_fd, msg);
2317 muse_core_msg_free(msg);
2321 LOGE("send msg failed");
2322 ret = CAMERA_ERROR_INVALID_OPERATION;
2326 ret = muse_core_msg_recv(sock_fd, recv_msg, MUSE_CAMERA_MSG_MAX_LENGTH);
2328 LOGE("recv msg failed %d", errno);
2329 ret = CAMERA_ERROR_INVALID_OPERATION;
2333 if (!muse_camera_msg_get(ret, recv_msg)) {
2334 LOGE("failed to get return value from msg [%s]", recv_msg);
2335 ret = CAMERA_ERROR_INVALID_OPERATION;
2339 if (ret == CAMERA_ERROR_NONE)
2340 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2342 LOGD("api %d - value %d", api, *value);
2346 muse_client_close(sock_fd);
2354 int camera_create(camera_device_e device, camera_h *camera)
2357 char *send_msg = NULL;
2359 int ret = CAMERA_ERROR_NONE;
2361 camera_cli_s *pc = NULL;
2362 tbm_bufmgr bufmgr = NULL;
2364 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2365 int module_index = -1;
2366 int device_type = (int)device;
2369 LOGE("NULL pointer");
2370 return CAMERA_ERROR_INVALID_PARAMETER;
2373 sock_fd = muse_client_new();
2375 LOGE("muse_client_new failed - returned fd %d", sock_fd);
2376 ret = CAMERA_ERROR_INVALID_OPERATION;
2382 if (muse_client_get_module_index(MODULE_NAME, &module_index) != MM_ERROR_NONE) {
2383 LOGE("muse client get module index failed");
2384 ret = CAMERA_ERROR_INVALID_OPERATION;
2388 send_msg = muse_core_msg_new(api,
2389 MUSE_TYPE_INT, "module", module_index,
2390 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2391 MUSE_TYPE_INT, "pid", pid,
2396 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2400 send_ret = muse_core_msg_send(sock_fd, send_msg);
2402 muse_core_msg_free(send_msg);
2406 LOGE("send msg failed %d", errno);
2407 ret = CAMERA_ERROR_INVALID_OPERATION;
2411 pc = g_new0(camera_cli_s, 1);
2413 LOGE("camera_cli_s alloc failed");
2414 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2418 bufmgr = tbm_bufmgr_init(-1);
2419 if (bufmgr == NULL) {
2420 LOGE("get tbm bufmgr failed");
2421 ret = CAMERA_ERROR_INVALID_OPERATION;
2425 pc->cb_info = _camera_client_callback_new(sock_fd);
2426 if (pc->cb_info == NULL) {
2427 LOGE("cb_info alloc failed");
2428 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2434 LOGD("cb info : %d", pc->cb_info->fd);
2436 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2438 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2440 if (ret == CAMERA_ERROR_NONE) {
2441 intptr_t handle = 0;
2443 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2445 LOGE("Receiving Handle Failed!!");
2446 ret = CAMERA_ERROR_INVALID_OPERATION;
2450 pc->remote_handle = handle;
2451 pc->cb_info->bufmgr = bufmgr;
2453 ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL);
2454 if (ret != CAMERA_ERROR_NONE) {
2455 LOGE("init display failed 0x%x", ret);
2459 LOGD("camera create 0x%td", pc->remote_handle);
2461 *camera = (camera_h)pc;
2463 /* get display interface handle */
2464 if (mm_display_interface_init(&pc->cb_info->dp_interface) != MM_ERROR_NONE)
2465 LOGW("display interface init failed");
2467 /* get default preview format */
2468 if (camera_get_preview_format(*camera, &pc->cb_info->preview_format) != CAMERA_ERROR_NONE) {
2469 LOGW("get default preview format failed");
2470 pc->cb_info->preview_format = CAMERA_PIXEL_FORMAT_INVALID;
2480 tbm_bufmgr_deinit(bufmgr);
2485 muse_client_close(sock_fd);
2491 int temp_fd = pc->cb_info->fd;
2493 /* pc->cb_info->fd should be closed,
2494 because g_thread_join for msg_recv_thread is not returned
2495 in _camera_client_callback_destroy. */
2497 pc->cb_info->fd = -1;
2498 muse_client_close(temp_fd);
2501 _camera_client_callback_destroy(pc->cb_info);
2508 LOGE("camera create error : 0x%x", ret);
2514 int camera_change_device(camera_h camera, camera_device_e device)
2517 int ret = CAMERA_ERROR_NONE;
2518 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2519 camera_cli_s *pc = (camera_cli_s *)camera;
2520 camera_msg_param param;
2522 if (!pc || !pc->cb_info) {
2523 LOGE("NULL handle");
2524 return CAMERA_ERROR_INVALID_PARAMETER;
2527 CAMERA_MSG_PARAM_SET(param, INT, device);
2529 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2531 if (ret == CAMERA_ERROR_NONE) {
2532 /* reset callback and user data */
2533 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2534 pc->cb_info->user_cb[i] = NULL;
2535 pc->cb_info->user_data[i] = NULL;
2537 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
2544 int camera_destroy(camera_h camera)
2546 int ret = CAMERA_ERROR_NONE;
2547 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2548 camera_cli_s *pc = (camera_cli_s *)camera;
2550 if (!pc || !pc->cb_info) {
2551 LOGE("NULL handle");
2552 return CAMERA_ERROR_INVALID_PARAMETER;
2557 if (pc->cb_info->is_server_connected)
2558 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2560 LOGW("server disconnected. release resource without send message.");
2562 if (ret == CAMERA_ERROR_NONE) {
2563 _camera_deactivate_idle_event_all(pc->cb_info);
2564 _camera_client_callback_destroy(pc->cb_info);
2571 LOGD("ret : 0x%x", ret);
2576 int camera_start_preview(camera_h camera)
2578 int ret = CAMERA_ERROR_NONE;
2579 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2580 camera_cli_s *pc = (camera_cli_s *)camera;
2582 if (!pc || !pc->cb_info) {
2583 LOGE("NULL handle");
2584 return CAMERA_ERROR_INVALID_PARAMETER;
2587 LOGD("Enter : preview format %d, display type %d",
2588 pc->cb_info->preview_format, pc->cb_info->dp_type);
2590 if (pc->cb_info->preview_format == CAMERA_PIXEL_FORMAT_INVZ &&
2591 pc->cb_info->dp_type != CAMERA_DISPLAY_TYPE_NONE) {
2592 LOGE("CAMERA_DISPLAY_TYPE_NONE[current %d] should be set with INVZ format",
2593 pc->cb_info->dp_type);
2594 return CAMERA_ERROR_INVALID_OPERATION;
2597 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2598 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2599 ret = _camera_start_evas_rendering(camera);
2600 if (ret != CAMERA_ERROR_NONE) {
2601 LOGE("stop preview because of error");
2602 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, pc->cb_info, NULL, 0);
2606 LOGD("ret : 0x%x", ret);
2612 int camera_stop_preview(camera_h camera)
2614 int ret = CAMERA_ERROR_NONE;
2615 camera_cli_s *pc = (camera_cli_s *)camera;
2616 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2617 camera_state_e current_state = CAMERA_STATE_NONE;
2619 if (!pc || !pc->cb_info) {
2620 LOGE("NULL handle");
2621 return CAMERA_ERROR_INVALID_PARAMETER;
2626 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2627 ret = camera_get_state(camera, ¤t_state);
2628 if (ret != CAMERA_ERROR_NONE) {
2629 LOGE("failed to get current state 0x%x", ret);
2633 if (current_state == CAMERA_STATE_PREVIEW) {
2634 ret = _camera_stop_evas_rendering(camera, false);
2635 if (ret != CAMERA_ERROR_NONE)
2640 /* send stop preview message */
2641 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2643 if (ret != CAMERA_ERROR_NONE &&
2644 current_state == CAMERA_STATE_PREVIEW) {
2645 LOGW("restart evas rendering");
2646 _camera_start_evas_rendering(camera);
2649 LOGD("ret : 0x%x", ret);
2655 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2657 int ret = CAMERA_ERROR_NONE;
2658 camera_cli_s *pc = (camera_cli_s *)camera;
2659 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2661 if (!pc || !pc->cb_info) {
2662 LOGE("NULL handle");
2663 return CAMERA_ERROR_INVALID_PARAMETER;
2668 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2669 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2671 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2672 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2674 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2676 LOGD("ret : 0x%x", ret);
2682 bool camera_is_supported_continuous_capture(camera_h camera)
2684 int ret = CAMERA_ERROR_NONE;
2685 camera_cli_s *pc = (camera_cli_s *)camera;
2686 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2688 if (!pc || !pc->cb_info) {
2689 LOGE("NULL handle");
2690 return CAMERA_ERROR_INVALID_PARAMETER;
2695 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2698 LOGE("error is occurred 0x%x", ret);
2702 LOGD("ret : %d", ret);
2708 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)
2710 int ret = CAMERA_ERROR_NONE;
2711 camera_cli_s *pc = (camera_cli_s *)camera;
2712 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2713 camera_msg_param param;
2716 if (!pc || !pc->cb_info) {
2717 LOGE("NULL handle");
2718 return CAMERA_ERROR_INVALID_PARAMETER;
2723 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2724 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2726 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2727 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2729 value = (count << 16) | interval;
2730 CAMERA_MSG_PARAM_SET(param, INT, value);
2732 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2734 LOGD("ret : 0x%x", ret);
2740 int camera_stop_continuous_capture(camera_h camera)
2742 int ret = CAMERA_ERROR_NONE;
2743 camera_cli_s *pc = (camera_cli_s *)camera;
2744 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2746 if (!pc || !pc->cb_info) {
2747 LOGE("NULL handle");
2748 return CAMERA_ERROR_INVALID_PARAMETER;
2753 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2755 LOGD("ret : 0x%x", ret);
2761 bool camera_is_supported_face_detection(camera_h camera)
2763 int ret = CAMERA_ERROR_NONE;
2764 camera_cli_s *pc = (camera_cli_s *)camera;
2765 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2767 if (!pc || !pc->cb_info) {
2768 LOGE("NULL handle");
2769 return CAMERA_ERROR_INVALID_PARAMETER;
2774 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2777 LOGE("error is occurred 0x%x", ret);
2781 LOGD("ret : %d", ret);
2787 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2789 int ret = CAMERA_ERROR_NONE;
2790 camera_cli_s *pc = (camera_cli_s *)camera;
2791 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2793 if (!pc || !pc->cb_info) {
2794 LOGE("NULL handle");
2795 return CAMERA_ERROR_INVALID_PARAMETER;
2800 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2803 LOGE("error is occurred 0x%x", ret);
2807 LOGD("ret : %d", ret);
2813 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2815 int ret = CAMERA_ERROR_NONE;
2816 camera_cli_s *pc = (camera_cli_s *)camera;
2817 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2819 if (!pc || !pc->cb_info) {
2820 LOGE("NULL handle");
2821 return CAMERA_ERROR_INVALID_PARAMETER;
2826 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2829 LOGE("error is occurred 0x%x", ret);
2833 LOGD("ret : %d", ret);
2838 int camera_get_device_count(camera_h camera, int *device_count)
2840 int ret = CAMERA_ERROR_NONE;
2841 camera_cli_s *pc = (camera_cli_s *)camera;
2842 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2844 if (!pc || !pc->cb_info) {
2845 LOGE("NULL handle");
2846 return CAMERA_ERROR_INVALID_PARAMETER;
2851 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2853 if (ret == CAMERA_ERROR_NONE)
2854 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2856 LOGD("ret : 0x%x", ret);
2861 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2863 int ret = CAMERA_ERROR_NONE;
2864 camera_cli_s *pc = (camera_cli_s *)camera;
2865 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2867 if (!pc || !pc->cb_info) {
2868 LOGE("NULL handle");
2869 return CAMERA_ERROR_INVALID_PARAMETER;
2874 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2876 if (ret == CAMERA_ERROR_NONE) {
2877 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2879 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2880 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2882 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2885 LOGD("ret : 0x%x", ret);
2890 int camera_stop_face_detection(camera_h camera)
2892 int ret = CAMERA_ERROR_NONE;
2893 camera_cli_s *pc = (camera_cli_s *)camera;
2894 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
2896 if (!pc || !pc->cb_info) {
2897 LOGE("NULL handle");
2898 return CAMERA_ERROR_INVALID_PARAMETER;
2903 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2905 if (ret == CAMERA_ERROR_NONE) {
2906 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2908 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
2909 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
2911 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2914 LOGD("ret : 0x%x", ret);
2919 int camera_get_state(camera_h camera, camera_state_e *state)
2921 int ret = CAMERA_ERROR_NONE;
2922 camera_cli_s *pc = (camera_cli_s *)camera;
2923 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
2925 if (!pc || !pc->cb_info || !state) {
2926 LOGE("NULL pointer %p %p", pc, state);
2927 return CAMERA_ERROR_INVALID_PARAMETER;
2932 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2934 if (ret == CAMERA_ERROR_NONE)
2935 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
2937 LOGD("ret : 0x%x", ret);
2942 int camera_start_focusing(camera_h camera, bool continuous)
2944 int ret = CAMERA_ERROR_NONE;
2945 camera_cli_s *pc = (camera_cli_s *)camera;
2946 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
2947 camera_msg_param param;
2948 int is_continuous = (int)continuous;
2950 if (!pc || !pc->cb_info) {
2951 LOGE("NULL handle");
2952 return CAMERA_ERROR_INVALID_PARAMETER;
2957 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
2959 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2961 LOGD("ret : 0x%x", ret);
2966 int camera_cancel_focusing(camera_h camera)
2968 int ret = CAMERA_ERROR_NONE;
2969 camera_cli_s *pc = (camera_cli_s *)camera;
2970 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
2972 if (!pc || !pc->cb_info) {
2973 LOGE("NULL handle");
2974 return CAMERA_ERROR_INVALID_PARAMETER;
2977 LOGD("Enter, remote_handle : %td", pc->remote_handle);
2979 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2981 LOGD("ret : 0x%x", ret);
2986 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
2988 int ret = CAMERA_ERROR_NONE;
2990 camera_cli_s *pc = (camera_cli_s *)camera;
2991 camera_cb_info_s *cb_info = NULL;
2992 camera_state_e current_state = CAMERA_STATE_NONE;
2993 camera_msg_param param0;
2994 camera_msg_param param1;
2995 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
2997 if (!pc || !pc->cb_info) {
2998 LOGE("NULL handle");
2999 return CAMERA_ERROR_INVALID_PARAMETER;
3002 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
3003 LOGE("invalid type %d", type);
3004 return CAMERA_ERROR_INVALID_PARAMETER;
3007 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
3008 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
3009 return CAMERA_ERROR_INVALID_PARAMETER;
3012 cb_info = (camera_cb_info_s *)pc->cb_info;
3014 ret = camera_get_state(camera, ¤t_state);
3015 if (ret != CAMERA_ERROR_NONE) {
3016 LOGE("failed to get current state 0x%x", ret);
3020 if (current_state != CAMERA_STATE_CREATED) {
3021 LOGE("INVALID_STATE : current %d", current_state);
3022 return CAMERA_ERROR_INVALID_STATE;
3025 LOGD("Enter - type : %d, display : %p", type, display);
3027 if (type != CAMERA_DISPLAY_TYPE_NONE) {
3028 /* check display interface handle */
3029 if (!cb_info->dp_interface) {
3030 LOGE("display interface not supported");
3031 return CAMERA_ERROR_NOT_SUPPORTED;
3034 ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &parent_id);
3035 if (ret != MM_ERROR_NONE) {
3036 LOGE("[INVALID_OPERATION] set display failed[0x%x]", ret);
3037 return CAMERA_ERROR_INVALID_OPERATION;
3040 if (type == CAMERA_DISPLAY_TYPE_EVAS) {
3041 camera_flip_e flip = CAMERA_FLIP_NONE;
3042 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3043 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3050 camera_get_display_flip(camera, &flip);
3051 camera_get_display_mode(camera, &mode);
3052 camera_get_display_rotation(camera, &rotation);
3053 camera_is_display_visible(camera, &visible);
3054 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3056 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
3057 flip, mode, rotation, visible, x, y, width, height);
3059 ret = mm_display_interface_evas_set_flip(cb_info->dp_interface, flip);
3060 ret |= mm_display_interface_evas_set_mode(cb_info->dp_interface, mode);
3061 ret |= mm_display_interface_evas_set_rotation(cb_info->dp_interface, rotation);
3062 ret |= mm_display_interface_evas_set_visible(cb_info->dp_interface, visible);
3064 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
3065 ret |= mm_display_interface_evas_set_roi_area(cb_info->dp_interface, x, y, width, height);
3069 CAMERA_MSG_PARAM_SET(param0, INT, type);
3070 CAMERA_MSG_PARAM_SET(param1, INT, parent_id);
3072 _camera_msg_send_param2_int(api, cb_info, &ret,
3073 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
3075 if (ret == CAMERA_ERROR_NONE) {
3076 pc->cb_info->dp_type = type;
3078 if (type == CAMERA_DISPLAY_TYPE_EVAS)
3079 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3086 int camera_set_preview_resolution(camera_h camera, int width, int height)
3088 int ret = CAMERA_ERROR_NONE;
3089 camera_state_e current_state = CAMERA_STATE_NONE;
3090 camera_cli_s *pc = (camera_cli_s *)camera;
3091 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3092 camera_msg_param param;
3095 if (!pc || !pc->cb_info) {
3096 LOGE("NULL handle");
3097 return CAMERA_ERROR_INVALID_PARAMETER;
3100 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3101 ret = camera_get_state(camera, ¤t_state);
3102 if (ret != CAMERA_ERROR_NONE) {
3103 LOGE("failed to get current state 0x%x", ret);
3107 if (current_state == CAMERA_STATE_PREVIEW) {
3108 ret = _camera_stop_evas_rendering(camera, true);
3109 if (ret != CAMERA_ERROR_NONE)
3114 value = (width << 16) | height;
3115 CAMERA_MSG_PARAM_SET(param, INT, value);
3117 LOGD("%dx%d -> 0x%x", width, height, value);
3119 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3121 LOGD("ret : 0x%x", ret);
3123 if (current_state == CAMERA_STATE_PREVIEW) {
3124 LOGW("restart evas rendering");
3125 _camera_start_evas_rendering(camera);
3132 int camera_set_capture_resolution(camera_h camera, int width, int height)
3134 int ret = CAMERA_ERROR_NONE;
3135 camera_cli_s *pc = (camera_cli_s *)camera;
3136 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3137 camera_msg_param param;
3140 if (!pc || !pc->cb_info) {
3141 LOGE("NULL handle");
3142 return CAMERA_ERROR_INVALID_PARAMETER;
3147 value = (width << 16) | height;
3148 CAMERA_MSG_PARAM_SET(param, INT, value);
3150 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3152 LOGD("ret : 0x%x", ret);
3158 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3160 int ret = CAMERA_ERROR_NONE;
3161 int set_format = (int)format;
3162 camera_cli_s *pc = (camera_cli_s *)camera;
3163 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3164 camera_msg_param param;
3166 if (!pc || !pc->cb_info) {
3167 LOGE("NULL handle");
3168 return CAMERA_ERROR_INVALID_PARAMETER;
3171 LOGD("Enter - format %d", set_format);
3173 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3175 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3177 LOGD("ret : 0x%x", ret);
3183 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3185 int ret = CAMERA_ERROR_NONE;
3186 int set_format = (int)format;
3187 camera_msg_param param;
3188 camera_cli_s *pc = (camera_cli_s *)camera;
3189 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3191 if (!pc || !pc->cb_info) {
3192 LOGE("NULL handle");
3193 return CAMERA_ERROR_INVALID_PARAMETER;
3196 LOGD("Enter - capture_format %d", set_format);
3198 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3200 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3202 if (ret == CAMERA_ERROR_NONE)
3203 pc->cb_info->preview_format = set_format;
3205 LOGD("ret : 0x%x", ret);
3211 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3213 int ret = CAMERA_ERROR_NONE;
3214 camera_cli_s *pc = (camera_cli_s *)camera;
3215 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3217 if (!pc || !pc->cb_info || !width || !height) {
3218 LOGE("NULL pointer %p %p %p", pc, width, height);
3219 return CAMERA_ERROR_INVALID_PARAMETER;
3224 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3226 if (ret == CAMERA_ERROR_NONE) {
3227 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3228 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3231 LOGD("ret : 0x%x", ret);
3237 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3239 int ret = CAMERA_ERROR_NONE;
3240 int set_rotation = (int)rotation;
3241 camera_cli_s *pc = (camera_cli_s *)camera;
3242 camera_msg_param param;
3244 if (!pc || !pc->cb_info) {
3245 LOGE("NULL handle");
3246 return CAMERA_ERROR_INVALID_PARAMETER;
3249 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3250 ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
3251 if (ret != MM_ERROR_NONE) {
3252 LOGE("failed to set rotation for evas surface 0x%x", ret);
3253 return CAMERA_ERROR_INVALID_OPERATION;
3257 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3259 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3265 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3267 int ret = CAMERA_ERROR_NONE;
3268 camera_cli_s *pc = (camera_cli_s *)camera;
3270 if (!pc || !pc->cb_info || !rotation) {
3271 LOGE("NULL pointer %p %p", pc, rotation);
3272 return CAMERA_ERROR_INVALID_PARAMETER;
3275 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3277 if (ret == CAMERA_ERROR_NONE)
3278 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3284 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3286 int ret = CAMERA_ERROR_NONE;
3287 int set_flip = (int)flip;
3288 camera_cli_s *pc = (camera_cli_s *)camera;
3289 camera_msg_param param;
3291 if (!pc || !pc->cb_info) {
3292 LOGE("NULL handle");
3293 return CAMERA_ERROR_INVALID_PARAMETER;
3296 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3297 ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
3298 if (ret != MM_ERROR_NONE) {
3299 LOGE("failed to set flip for evas surface 0x%x", ret);
3300 return CAMERA_ERROR_INVALID_OPERATION;
3304 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3306 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3312 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3314 int ret = CAMERA_ERROR_NONE;
3315 camera_cli_s *pc = (camera_cli_s *)camera;
3317 if (!pc || !pc->cb_info || !flip) {
3318 LOGE("NULL pointer %p %p", pc, flip);
3319 return CAMERA_ERROR_INVALID_PARAMETER;
3322 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3324 if (ret == CAMERA_ERROR_NONE)
3325 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3331 int camera_set_display_visible(camera_h camera, bool visible)
3333 int ret = CAMERA_ERROR_NONE;
3334 int set_visible = (int)visible;
3335 camera_cli_s *pc = (camera_cli_s *)camera;
3336 camera_msg_param param;
3338 if (!pc || !pc->cb_info) {
3339 LOGE("NULL handle");
3340 return CAMERA_ERROR_INVALID_PARAMETER;
3343 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3344 ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
3345 if (ret != MM_ERROR_NONE) {
3346 LOGE("failed to set visible for evas surface 0x%x", ret);
3347 return CAMERA_ERROR_INVALID_OPERATION;
3351 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3353 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3359 int camera_is_display_visible(camera_h camera, bool *visible)
3361 int ret = CAMERA_ERROR_NONE;
3362 camera_cli_s *pc = (camera_cli_s *)camera;
3364 if (!pc || !pc->cb_info || !visible) {
3365 LOGE("NULL pointer %p %p", pc, visible);
3366 return CAMERA_ERROR_INVALID_PARAMETER;
3369 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3371 if (ret == CAMERA_ERROR_NONE)
3372 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3378 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3380 int ret = CAMERA_ERROR_NONE;
3381 int set_mode = (int)mode;
3382 camera_cli_s *pc = (camera_cli_s *)camera;
3383 camera_msg_param param;
3385 if (!pc || !pc->cb_info) {
3386 LOGE("NULL handle");
3387 return CAMERA_ERROR_INVALID_PARAMETER;
3390 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3391 ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
3392 if (ret != MM_ERROR_NONE) {
3393 LOGE("failed to set geometry for evas surface 0x%x", ret);
3394 return CAMERA_ERROR_INVALID_OPERATION;
3398 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3400 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3406 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3408 int ret = CAMERA_ERROR_NONE;
3409 camera_cli_s *pc = (camera_cli_s *)camera;
3411 if (!pc || !pc->cb_info || !mode) {
3412 LOGE("NULL pointer %p %p", pc, mode);
3413 return CAMERA_ERROR_INVALID_PARAMETER;
3416 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3418 if (ret == CAMERA_ERROR_NONE)
3419 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3425 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3427 int ret = CAMERA_ERROR_NONE;
3428 int set_hint = (int)hint;
3429 camera_cli_s *pc = (camera_cli_s *)camera;
3430 camera_msg_param param;
3432 if (!pc || !pc->cb_info) {
3433 LOGE("NULL handle");
3434 return CAMERA_ERROR_INVALID_PARAMETER;
3437 LOGD("Enter - hint %d", set_hint);
3439 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3441 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3447 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3449 int ret = CAMERA_ERROR_NONE;
3450 camera_cli_s *pc = (camera_cli_s *)camera;
3451 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3453 if (!pc || !pc->cb_info || !hint) {
3454 LOGE("NULL pointer %p %p", pc, hint);
3455 return CAMERA_ERROR_INVALID_PARAMETER;
3458 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3460 if (ret == CAMERA_ERROR_NONE) {
3461 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3462 LOGD("display reuse hint %d", *hint);
3469 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3471 int ret = CAMERA_ERROR_NONE;
3472 camera_cli_s *pc = (camera_cli_s *)camera;
3473 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3475 if (!pc || !pc->cb_info || !width || !height) {
3476 LOGE("NULL pointer %p %p %p", pc, width, height);
3477 return CAMERA_ERROR_INVALID_PARAMETER;
3482 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3484 if (ret == CAMERA_ERROR_NONE) {
3485 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3486 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3489 LOGD("ret : 0x%x", ret);
3495 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3497 int ret = CAMERA_ERROR_NONE;
3498 camera_cli_s *pc = (camera_cli_s *)camera;
3499 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3501 if (!pc || !pc->cb_info || !format) {
3502 LOGE("NULL pointer %p %p", pc, format);
3503 return CAMERA_ERROR_INVALID_PARAMETER;
3508 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3510 if (ret == CAMERA_ERROR_NONE)
3511 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3513 LOGD("ret : 0x%x", ret);
3519 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3521 int ret = CAMERA_ERROR_NONE;
3522 camera_cli_s *pc = (camera_cli_s *)camera;
3523 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3525 if (!pc || !pc->cb_info || !format) {
3526 LOGE("NULL pointer %p %p", pc, format);
3527 return CAMERA_ERROR_INVALID_PARAMETER;
3532 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3534 if (ret == CAMERA_ERROR_NONE)
3535 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3537 LOGD("ret : 0x%x", ret);
3543 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3545 int ret = CAMERA_ERROR_NONE;
3546 camera_cli_s *pc = (camera_cli_s *)camera;
3547 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3549 if (!pc || !pc->cb_info || !facing_direction) {
3550 LOGE("NULL pointer %p %p", pc, facing_direction);
3551 return CAMERA_ERROR_INVALID_PARAMETER;
3556 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3558 if (ret == CAMERA_ERROR_NONE)
3559 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3561 LOGD("ret : 0x%x", ret);
3567 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3569 int ret = CAMERA_ERROR_NONE;
3570 camera_cli_s *pc = (camera_cli_s *)camera;
3571 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3573 if (!pc || !pc->cb_info || !callback) {
3574 LOGE("NULL pointer %p %p", pc, callback);
3575 return CAMERA_ERROR_INVALID_PARAMETER;
3580 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3582 if (ret == CAMERA_ERROR_NONE) {
3583 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3585 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3586 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3588 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3590 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3593 LOGD("ret : 0x%x", ret);
3599 int camera_unset_preview_cb(camera_h camera)
3601 int ret = CAMERA_ERROR_NONE;
3602 camera_cli_s *pc = (camera_cli_s *)camera;
3603 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3605 if (!pc || !pc->cb_info) {
3606 LOGE("NULL handle");
3607 return CAMERA_ERROR_INVALID_PARAMETER;
3612 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3614 if (ret == CAMERA_ERROR_NONE) {
3615 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3617 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3618 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3620 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3622 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3625 LOGD("ret : 0x%x", ret);
3631 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3633 int ret = CAMERA_ERROR_NONE;
3634 camera_cli_s *pc = (camera_cli_s *)camera;
3635 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3637 if (!pc || !pc->cb_info) {
3638 LOGE("NULL handle");
3639 return CAMERA_ERROR_INVALID_PARAMETER;
3642 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3643 LOGE("NOT SUPPORTED");
3644 return CAMERA_ERROR_NOT_SUPPORTED;
3647 if (callback == NULL) {
3648 LOGE("NULL callback");
3649 return CAMERA_ERROR_INVALID_PARAMETER;
3654 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3656 if (ret == CAMERA_ERROR_NONE) {
3657 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3659 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3660 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3662 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3665 LOGD("ret : 0x%x", ret);
3671 int camera_unset_media_packet_preview_cb(camera_h camera)
3673 int ret = CAMERA_ERROR_NONE;
3674 camera_cli_s *pc = (camera_cli_s *)camera;
3675 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3677 if (!pc || !pc->cb_info) {
3678 LOGE("NULL handle");
3679 return CAMERA_ERROR_INVALID_PARAMETER;
3684 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3686 if (ret == CAMERA_ERROR_NONE) {
3687 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3689 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3690 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3692 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3695 LOGD("ret : 0x%x", ret);
3701 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3703 int ret = CAMERA_ERROR_NONE;
3704 camera_cli_s *pc = (camera_cli_s *)camera;
3705 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3707 if (!pc || !pc->cb_info || !callback) {
3708 LOGE("NULL pointer %p %p", pc, callback);
3709 return CAMERA_ERROR_INVALID_PARAMETER;
3714 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3716 if (ret == CAMERA_ERROR_NONE) {
3717 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3719 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3720 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3722 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3725 LOGD("ret : 0x%x", ret);
3731 int camera_unset_state_changed_cb(camera_h camera)
3733 int ret = CAMERA_ERROR_NONE;
3734 camera_cli_s *pc = (camera_cli_s *)camera;
3735 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3737 if (!pc || !pc->cb_info) {
3738 LOGE("NULL handle");
3739 return CAMERA_ERROR_INVALID_PARAMETER;
3744 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3746 if (ret == CAMERA_ERROR_NONE) {
3747 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3749 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3750 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3752 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3755 LOGD("ret : 0x%x", ret);
3761 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3763 int ret = CAMERA_ERROR_NONE;
3764 camera_cli_s *pc = (camera_cli_s *)camera;
3765 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3767 if (!pc || !pc->cb_info || !callback) {
3768 LOGE("NULL pointer %p %p", pc, callback);
3769 return CAMERA_ERROR_INVALID_PARAMETER;
3774 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3776 if (ret == CAMERA_ERROR_NONE) {
3777 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3779 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3780 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3782 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3785 LOGD("ret : 0x%x", ret);
3791 int camera_unset_interrupted_cb(camera_h camera)
3793 int ret = CAMERA_ERROR_NONE;
3794 camera_cli_s *pc = (camera_cli_s *)camera;
3795 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3797 if (!pc || !pc->cb_info) {
3798 LOGE("NULL handle");
3799 return CAMERA_ERROR_INVALID_PARAMETER;
3804 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3806 if (ret == CAMERA_ERROR_NONE) {
3807 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3809 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3810 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3812 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3815 LOGD("ret : 0x%x", ret);
3821 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
3823 int ret = CAMERA_ERROR_NONE;
3824 camera_cli_s *pc = (camera_cli_s *)camera;
3825 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
3827 if (!pc || !pc->cb_info || !callback) {
3828 LOGE("NULL pointer %p %p", pc, callback);
3829 return CAMERA_ERROR_INVALID_PARAMETER;
3834 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3836 if (ret == CAMERA_ERROR_NONE) {
3837 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3839 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
3840 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
3842 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3845 LOGD("ret : 0x%x", ret);
3851 int camera_unset_interrupt_started_cb(camera_h camera)
3853 int ret = CAMERA_ERROR_NONE;
3854 camera_cli_s *pc = (camera_cli_s *)camera;
3855 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
3857 if (!pc || !pc->cb_info) {
3858 LOGE("NULL handle");
3859 return CAMERA_ERROR_INVALID_PARAMETER;
3864 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3866 if (ret == CAMERA_ERROR_NONE) {
3867 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3869 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3870 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3872 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3875 LOGD("ret : 0x%x", ret);
3881 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
3883 int ret = CAMERA_ERROR_NONE;
3884 camera_cli_s *pc = (camera_cli_s *)camera;
3885 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3887 if (!pc || !pc->cb_info || !callback) {
3888 LOGE("NULL pointer %p %p", pc, callback);
3889 return CAMERA_ERROR_INVALID_PARAMETER;
3894 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3896 if (ret == CAMERA_ERROR_NONE) {
3897 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3899 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3900 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3902 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3905 LOGD("ret : 0x%x", ret);
3911 int camera_unset_focus_changed_cb(camera_h camera)
3913 int ret = CAMERA_ERROR_NONE;
3914 camera_cli_s *pc = (camera_cli_s *)camera;
3915 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
3917 if (!pc || !pc->cb_info) {
3918 LOGE("NULL handle");
3919 return CAMERA_ERROR_INVALID_PARAMETER;
3924 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3926 if (ret == CAMERA_ERROR_NONE) {
3927 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3929 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3930 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3932 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3935 LOGD("ret : 0x%x", ret);
3941 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
3943 int ret = CAMERA_ERROR_NONE;
3944 camera_cli_s *pc = (camera_cli_s *)camera;
3945 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
3947 if (!pc || !pc->cb_info || !callback) {
3948 LOGE("NULL pointer %p %p", pc, callback);
3949 return CAMERA_ERROR_INVALID_PARAMETER;
3954 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3956 if (ret == CAMERA_ERROR_NONE) {
3957 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3959 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
3960 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
3962 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3965 LOGD("ret : 0x%x", ret);
3971 int camera_unset_error_cb(camera_h camera)
3973 int ret = CAMERA_ERROR_NONE;
3974 camera_cli_s *pc = (camera_cli_s *)camera;
3975 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
3977 if (!pc || !pc->cb_info) {
3978 LOGE("NULL handle");
3979 return CAMERA_ERROR_INVALID_PARAMETER;
3984 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3986 if (ret == CAMERA_ERROR_NONE) {
3987 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3989 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
3990 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
3992 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3995 LOGD("ret : 0x%x", ret);
4001 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4003 int ret = CAMERA_ERROR_NONE;
4004 camera_cli_s *pc = (camera_cli_s *)camera;
4005 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4007 if (!pc || !pc->cb_info || !foreach_cb) {
4008 LOGE("NULL pointer %p %p", pc, foreach_cb);
4009 return CAMERA_ERROR_INVALID_PARAMETER;
4014 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4015 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4017 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4019 LOGD("ret : 0x%x", ret);
4025 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4027 int ret = CAMERA_ERROR_NONE;
4028 camera_cli_s *pc = (camera_cli_s *)camera;
4029 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4031 if (!pc || !pc->cb_info || !foreach_cb) {
4032 LOGE("NULL pointer %p %p", pc, foreach_cb);
4033 return CAMERA_ERROR_INVALID_PARAMETER;
4038 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4039 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4041 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4043 LOGD("ret : 0x%x", ret);
4049 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4051 int ret = CAMERA_ERROR_NONE;
4052 camera_cli_s *pc = (camera_cli_s *)camera;
4053 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4055 if (!pc || !pc->cb_info || !foreach_cb) {
4056 LOGE("NULL pointer %p %p", pc, foreach_cb);
4057 return CAMERA_ERROR_INVALID_PARAMETER;
4062 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4063 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4065 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4067 LOGD("ret : 0x%x", ret);
4073 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4075 int ret = CAMERA_ERROR_NONE;
4076 camera_cli_s *pc = (camera_cli_s *)camera;
4077 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4079 if (!pc || !pc->cb_info || !foreach_cb) {
4080 LOGE("NULL pointer %p %p", pc, foreach_cb);
4081 return CAMERA_ERROR_INVALID_PARAMETER;
4086 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4087 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4089 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4091 LOGD("ret : 0x%x", ret);
4097 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4099 int ret = CAMERA_ERROR_NONE;
4100 camera_cli_s *pc = (camera_cli_s *)camera;
4101 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4103 if (!pc || !pc->cb_info || !width || !height) {
4104 LOGE("NULL pointer %p %p %p", pc, width, height);
4105 return CAMERA_ERROR_INVALID_PARAMETER;
4109 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4111 if (ret == CAMERA_ERROR_NONE) {
4112 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4113 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4116 LOGD("ret : 0x%x", ret);
4122 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4124 int ret = CAMERA_ERROR_NONE;
4125 camera_cli_s *pc = (camera_cli_s *)camera;
4126 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4128 if (!pc || !pc->cb_info || !angle) {
4129 LOGE("NULL pointer %p %p", pc, angle);
4130 return CAMERA_ERROR_INVALID_PARAMETER;
4135 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4137 if (ret == CAMERA_ERROR_NONE)
4138 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4140 LOGD("ret : 0x%x", ret);
4146 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4148 int ret = CAMERA_ERROR_NONE;
4149 camera_cli_s *pc = (camera_cli_s *)camera;
4150 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4151 camera_msg_param param;
4152 int set_mode = (int)mode;
4154 if (!pc || !pc->cb_info) {
4155 LOGE("NULL handle");
4156 return CAMERA_ERROR_INVALID_PARAMETER;
4161 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4163 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4165 LOGD("ret : 0x%x", ret);
4171 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4173 int ret = CAMERA_ERROR_NONE;
4174 camera_cli_s *pc = (camera_cli_s *)camera;
4175 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4177 if (!pc || !pc->cb_info || !mode) {
4178 LOGE("NULL pointer %p %p", pc, mode);
4179 return CAMERA_ERROR_INVALID_PARAMETER;
4184 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4186 if (ret == CAMERA_ERROR_NONE)
4187 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4189 LOGD("ret : 0x%x", ret);
4195 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4197 int ret = CAMERA_ERROR_NONE;
4198 camera_cli_s *pc = (camera_cli_s *)camera;
4199 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4201 if (!pc || !pc->cb_info || !foreach_cb) {
4202 LOGE("NULL pointer %p %p", pc, foreach_cb);
4203 return CAMERA_ERROR_INVALID_PARAMETER;
4208 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4209 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4211 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4213 LOGD("Finish, return :%x", ret);
4219 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4221 int ret = CAMERA_ERROR_NONE;
4222 camera_cli_s *pc = (camera_cli_s *)camera;
4223 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4224 camera_msg_param param;
4225 int set_fps = (int)fps;
4227 if (!pc || !pc->cb_info) {
4228 LOGE("NULL handle");
4229 return CAMERA_ERROR_INVALID_PARAMETER;
4234 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4236 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4238 LOGD("ret : 0x%x", ret);
4244 int camera_attr_set_image_quality(camera_h camera, int quality)
4246 int ret = CAMERA_ERROR_NONE;
4247 camera_cli_s *pc = (camera_cli_s *)camera;
4248 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4249 camera_msg_param param;
4251 if (!pc || !pc->cb_info) {
4252 LOGE("NULL handle");
4253 return CAMERA_ERROR_INVALID_PARAMETER;
4258 CAMERA_MSG_PARAM_SET(param, INT, quality);
4260 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4262 LOGD("ret : 0x%x", ret);
4268 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4270 int ret = CAMERA_ERROR_NONE;
4271 camera_cli_s *pc = (camera_cli_s *)camera;
4272 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4274 if (!pc || !pc->cb_info || !fps) {
4275 LOGE("NULL pointer %p %p", pc, fps);
4276 return CAMERA_ERROR_INVALID_PARAMETER;
4281 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4283 if (ret == CAMERA_ERROR_NONE)
4284 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4286 LOGD("ret : 0x%x", ret);
4292 int camera_attr_get_image_quality(camera_h camera, int *quality)
4294 int ret = CAMERA_ERROR_NONE;
4295 camera_cli_s *pc = (camera_cli_s *)camera;
4296 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4298 if (!pc || !pc->cb_info || !quality) {
4299 LOGE("NULL pointer %p %p", pc, quality);
4300 return CAMERA_ERROR_INVALID_PARAMETER;
4305 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4307 if (ret == CAMERA_ERROR_NONE)
4308 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4310 LOGD("ret : 0x%x", ret);
4316 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4318 int ret = CAMERA_ERROR_NONE;
4319 camera_cli_s *pc = (camera_cli_s *)camera;
4320 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4322 if (!pc || !pc->cb_info || !bitrate) {
4323 LOGE("NULL pointer %p %p", pc, bitrate);
4324 return CAMERA_ERROR_INVALID_PARAMETER;
4329 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4331 if (ret == CAMERA_ERROR_NONE)
4332 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4334 LOGD("ret : 0x%x", ret);
4340 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4342 int ret = CAMERA_ERROR_NONE;
4343 camera_cli_s *pc = (camera_cli_s *)camera;
4344 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4345 camera_msg_param param;
4346 int set_bitrate = bitrate;
4348 if (!pc || !pc->cb_info) {
4349 LOGE("NULL handle");
4350 return CAMERA_ERROR_INVALID_PARAMETER;
4355 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4357 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4359 LOGD("ret : 0x%x", ret);
4365 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4367 int ret = CAMERA_ERROR_NONE;
4368 camera_cli_s *pc = (camera_cli_s *)camera;
4369 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4371 if (!pc || !pc->cb_info || !interval) {
4372 LOGE("NULL pointer %p %p", pc, interval);
4373 return CAMERA_ERROR_INVALID_PARAMETER;
4378 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4380 if (ret == CAMERA_ERROR_NONE)
4381 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4383 LOGD("ret : 0x%x", ret);
4389 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4391 int ret = CAMERA_ERROR_NONE;
4392 camera_cli_s *pc = (camera_cli_s *)camera;
4393 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4394 camera_msg_param param;
4395 int set_gop_interval = interval;
4397 if (!pc || !pc->cb_info) {
4398 LOGE("NULL handle");
4399 return CAMERA_ERROR_INVALID_PARAMETER;
4404 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4406 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4408 LOGD("ret : 0x%x", ret);
4414 int camera_attr_set_zoom(camera_h camera, int zoom)
4416 int ret = CAMERA_ERROR_NONE;
4417 camera_cli_s *pc = (camera_cli_s *)camera;
4418 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4419 camera_msg_param param;
4421 if (!pc || !pc->cb_info) {
4422 LOGE("NULL handle");
4423 return CAMERA_ERROR_INVALID_PARAMETER;
4426 LOGD("Enter, remote_handle : %td", pc->remote_handle);
4428 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4430 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4432 LOGD("ret : 0x%x", ret);
4438 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4440 int ret = CAMERA_ERROR_NONE;
4441 camera_cli_s *pc = (camera_cli_s *)camera;
4442 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4443 camera_msg_param param;
4444 int set_mode = (int)mode;
4446 if (!pc || !pc->cb_info) {
4447 LOGE("NULL handle");
4448 return CAMERA_ERROR_INVALID_PARAMETER;
4451 LOGD("Enter, remote_handle : %td", pc->remote_handle);
4453 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4455 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4461 int camera_attr_set_af_area(camera_h camera, int x, int y)
4463 int ret = CAMERA_ERROR_NONE;
4464 camera_cli_s *pc = (camera_cli_s *)camera;
4465 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4466 camera_msg_param param;
4469 if (!pc || !pc->cb_info) {
4470 LOGE("NULL handle");
4471 return CAMERA_ERROR_INVALID_PARAMETER;
4474 LOGD("Enter - %d,%d", x, y);
4476 value = (x << 16) | y;
4477 CAMERA_MSG_PARAM_SET(param, INT, value);
4479 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4481 LOGD("ret : 0x%x", ret);
4487 int camera_attr_clear_af_area(camera_h camera)
4489 int ret = CAMERA_ERROR_NONE;
4490 camera_cli_s *pc = (camera_cli_s *)camera;
4491 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4493 if (!pc || !pc->cb_info) {
4494 LOGE("NULL handle");
4495 return CAMERA_ERROR_INVALID_PARAMETER;
4500 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4502 LOGD("ret : 0x%x", ret);
4508 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4510 int ret = CAMERA_ERROR_NONE;
4511 camera_cli_s *pc = (camera_cli_s *)camera;
4512 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4513 camera_msg_param param;
4514 int set_mode = (int)mode;
4516 if (!pc || !pc->cb_info) {
4517 LOGE("NULL handle");
4518 return CAMERA_ERROR_INVALID_PARAMETER;
4523 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4525 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4527 LOGD("ret : 0x%x", ret);
4533 int camera_attr_set_exposure(camera_h camera, int value)
4535 int ret = CAMERA_ERROR_NONE;
4536 camera_cli_s *pc = (camera_cli_s *)camera;
4537 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4538 camera_msg_param param;
4540 if (!pc || !pc->cb_info) {
4541 LOGE("NULL handle");
4542 return CAMERA_ERROR_INVALID_PARAMETER;
4547 CAMERA_MSG_PARAM_SET(param, INT, value);
4549 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4551 LOGD("ret : 0x%x", ret);
4557 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4559 int ret = CAMERA_ERROR_NONE;
4560 camera_cli_s *pc = (camera_cli_s *)camera;
4561 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4562 camera_msg_param param;
4563 int set_iso = (int)iso;
4565 if (!pc || !pc->cb_info) {
4566 LOGE("NULL handle");
4567 return CAMERA_ERROR_INVALID_PARAMETER;
4572 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4574 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4576 LOGD("ret : 0x%x", ret);
4582 int camera_attr_set_brightness(camera_h camera, int level)
4584 int ret = CAMERA_ERROR_NONE;
4585 camera_cli_s *pc = (camera_cli_s *)camera;
4586 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4587 camera_msg_param param;
4589 if (!pc || !pc->cb_info) {
4590 LOGE("NULL handle");
4591 return CAMERA_ERROR_INVALID_PARAMETER;
4596 CAMERA_MSG_PARAM_SET(param, INT, level);
4598 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4600 LOGD("ret : 0x%x", ret);
4606 int camera_attr_set_contrast(camera_h camera, int level)
4608 int ret = CAMERA_ERROR_NONE;
4609 camera_cli_s *pc = (camera_cli_s *)camera;
4610 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4611 camera_msg_param param;
4613 if (!pc || !pc->cb_info) {
4614 LOGE("NULL handle");
4615 return CAMERA_ERROR_INVALID_PARAMETER;
4620 CAMERA_MSG_PARAM_SET(param, INT, level);
4622 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4624 LOGD("ret : 0x%x", ret);
4630 int camera_attr_set_hue(camera_h camera, int level)
4632 int ret = CAMERA_ERROR_NONE;
4633 camera_cli_s *pc = (camera_cli_s *)camera;
4634 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HUE;
4635 camera_msg_param param;
4637 if (!pc || !pc->cb_info) {
4638 LOGE("NULL handle");
4639 return CAMERA_ERROR_INVALID_PARAMETER;
4644 CAMERA_MSG_PARAM_SET(param, INT, level);
4646 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4648 LOGD("ret : 0x%x", ret);
4654 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4656 int ret = CAMERA_ERROR_NONE;
4657 camera_cli_s *pc = (camera_cli_s *)camera;
4658 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4659 camera_msg_param param;
4660 int set_whitebalance = (int)wb;
4662 if (!pc || !pc->cb_info) {
4663 LOGE("NULL handle");
4664 return CAMERA_ERROR_INVALID_PARAMETER;
4669 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4671 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4673 LOGD("ret : 0x%x", ret);
4679 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4681 int ret = CAMERA_ERROR_NONE;
4682 camera_cli_s *pc = (camera_cli_s *)camera;
4683 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4684 camera_msg_param param;
4685 int set_effect = (int)effect;
4687 if (!pc || !pc->cb_info) {
4688 LOGE("NULL handle");
4689 return CAMERA_ERROR_INVALID_PARAMETER;
4694 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4696 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4698 LOGD("ret : 0x%x", ret);
4704 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4706 int ret = CAMERA_ERROR_NONE;
4707 camera_cli_s *pc = (camera_cli_s *)camera;
4708 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4709 camera_msg_param param;
4710 int set_mode = (int)mode;
4712 if (!pc || !pc->cb_info) {
4713 LOGE("NULL handle");
4714 return CAMERA_ERROR_INVALID_PARAMETER;
4719 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4721 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4723 LOGD("ret : 0x%x", ret);
4729 int camera_attr_enable_tag(camera_h camera, bool enable)
4731 int ret = CAMERA_ERROR_NONE;
4732 camera_cli_s *pc = (camera_cli_s *)camera;
4733 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4734 camera_msg_param param;
4735 int set_enable = (int)enable;
4737 if (!pc || !pc->cb_info) {
4738 LOGE("NULL handle");
4739 return CAMERA_ERROR_INVALID_PARAMETER;
4744 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4746 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4748 LOGD("ret : 0x%x", ret);
4754 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4756 int ret = CAMERA_ERROR_NONE;
4757 camera_cli_s *pc = (camera_cli_s *)camera;
4758 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4759 camera_msg_param param;
4761 if (!pc || !pc->cb_info || !description) {
4762 LOGE("NULL pointer %p %p", pc, description);
4763 return CAMERA_ERROR_INVALID_PARAMETER;
4768 CAMERA_MSG_PARAM_SET(param, STRING, description);
4770 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4772 LOGD("ret : 0x%x", ret);
4778 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4780 int ret = CAMERA_ERROR_NONE;
4781 camera_cli_s *pc = (camera_cli_s *)camera;
4782 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4783 camera_msg_param param;
4784 int set_orientation = (int)orientation;
4786 if (!pc || !pc->cb_info) {
4787 LOGE("NULL handle");
4788 return CAMERA_ERROR_INVALID_PARAMETER;
4793 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4795 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4797 LOGD("ret : 0x%x", ret);
4803 int camera_attr_set_tag_software(camera_h camera, const char *software)
4805 int ret = CAMERA_ERROR_NONE;
4806 camera_cli_s *pc = (camera_cli_s *)camera;
4807 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4808 camera_msg_param param;
4810 if (!pc || !pc->cb_info || !software) {
4811 LOGE("NULL pointer %p %p", pc, software);
4812 return CAMERA_ERROR_INVALID_PARAMETER;
4815 LOGD("Enter, remote_handle : %td", pc->remote_handle);
4817 CAMERA_MSG_PARAM_SET(param, STRING, software);
4819 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4821 LOGD("ret : 0x%x", ret);
4827 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4829 int ret = CAMERA_ERROR_NONE;
4830 camera_cli_s *pc = (camera_cli_s *)camera;
4831 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4832 double set_geotag[3] = {latitude, longitude, altitude};
4837 if (!pc || !pc->cb_info) {
4838 LOGE("NULL handle");
4839 return CAMERA_ERROR_INVALID_PARAMETER;
4844 length = sizeof(set_geotag) / sizeof(int) + \
4845 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4847 msg = muse_core_msg_new(api,
4848 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4851 LOGE("msg creation failed: api %d", api);
4852 return CAMERA_ERROR_OUT_OF_MEMORY;
4855 if (pc->cb_info->is_server_connected) {
4856 __camera_update_api_waiting(pc->cb_info, api, 1);
4858 g_mutex_lock(&pc->cb_info->fd_lock);
4859 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
4860 g_mutex_unlock(&pc->cb_info->fd_lock);
4864 LOGE("message send failed");
4865 ret = CAMERA_ERROR_INVALID_OPERATION;
4867 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
4870 __camera_update_api_waiting(pc->cb_info, api, -1);
4872 muse_core_msg_free(msg);
4874 LOGD("ret : 0x%x", ret);
4880 int camera_attr_remove_geotag(camera_h camera)
4882 int ret = CAMERA_ERROR_NONE;
4883 camera_cli_s *pc = (camera_cli_s *)camera;
4884 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4886 if (!pc || !pc->cb_info) {
4887 LOGE("NULL handle");
4888 return CAMERA_ERROR_INVALID_PARAMETER;
4893 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4895 LOGD("ret : 0x%x", ret);
4901 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4903 int ret = CAMERA_ERROR_NONE;
4904 camera_cli_s *pc = (camera_cli_s *)camera;
4905 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
4906 camera_msg_param param;
4907 int set_mode = (int)mode;
4909 if (!pc || !pc->cb_info) {
4910 LOGE("NULL handle");
4911 return CAMERA_ERROR_INVALID_PARAMETER;
4916 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4918 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4920 LOGD("ret : 0x%x", ret);
4926 int camera_attr_get_zoom(camera_h camera, int *zoom)
4928 int ret = CAMERA_ERROR_NONE;
4929 camera_cli_s *pc = (camera_cli_s *)camera;
4930 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4932 if (!pc || !pc->cb_info || !zoom) {
4933 LOGE("NULL pointer %p %p", pc, zoom);
4934 return CAMERA_ERROR_INVALID_PARAMETER;
4939 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4941 if (ret == CAMERA_ERROR_NONE)
4942 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
4944 LOGD("ret : 0x%x", ret);
4950 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
4952 int ret = CAMERA_ERROR_NONE;
4953 camera_cli_s *pc = (camera_cli_s *)camera;
4954 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
4956 if (!pc || !pc->cb_info || !min || !max) {
4957 LOGE("NULL pointer %p %p %p", pc, min, max);
4958 return CAMERA_ERROR_INVALID_PARAMETER;
4963 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4965 if (ret == CAMERA_ERROR_NONE) {
4966 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
4967 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
4970 LOGD("ret : 0x%x", ret);
4976 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
4978 int ret = CAMERA_ERROR_NONE;
4979 camera_cli_s *pc = (camera_cli_s *)camera;
4980 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
4982 if (!pc || !pc->cb_info || !mode) {
4983 LOGE("NULL pointer %p %p", pc, mode);
4984 return CAMERA_ERROR_INVALID_PARAMETER;
4989 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4991 if (ret == CAMERA_ERROR_NONE)
4992 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
4994 LOGD("ret : 0x%x", ret);
5000 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5002 int ret = CAMERA_ERROR_NONE;
5003 camera_cli_s *pc = (camera_cli_s *)camera;
5004 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5006 if (!pc || !pc->cb_info || !mode) {
5007 LOGE("NULL pointer %p %p", pc, mode);
5008 return CAMERA_ERROR_INVALID_PARAMETER;
5013 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5015 if (ret == CAMERA_ERROR_NONE)
5016 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5018 LOGD("ret : 0x%x", ret);
5024 int camera_attr_get_exposure(camera_h camera, int *value)
5026 int ret = CAMERA_ERROR_NONE;
5027 camera_cli_s *pc = (camera_cli_s *)camera;
5028 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5030 if (!pc || !pc->cb_info || !value) {
5031 LOGE("NULL pointer %p %p", pc, value);
5032 return CAMERA_ERROR_INVALID_PARAMETER;
5037 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5039 if (ret == CAMERA_ERROR_NONE)
5040 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5042 LOGD("ret : 0x%x", ret);
5048 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5050 int ret = CAMERA_ERROR_NONE;
5051 camera_cli_s *pc = (camera_cli_s *)camera;
5052 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5054 if (!pc || !pc->cb_info || !min || !max) {
5055 LOGE("NULL pointer %p %p %p", pc, min, max);
5056 return CAMERA_ERROR_INVALID_PARAMETER;
5061 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5063 if (ret == CAMERA_ERROR_NONE) {
5064 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5065 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5068 LOGD("ret : 0x%x", ret);
5074 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5076 int ret = CAMERA_ERROR_NONE;
5077 camera_cli_s *pc = (camera_cli_s *)camera;
5078 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5080 if (!pc || !pc->cb_info || !iso) {
5081 LOGE("NULL pointer %p %p", pc, iso);
5082 return CAMERA_ERROR_INVALID_PARAMETER;
5087 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5089 if (ret == CAMERA_ERROR_NONE)
5090 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5092 LOGD("ret : 0x%x", ret);
5098 int camera_attr_get_brightness(camera_h camera, int *level)
5100 int ret = CAMERA_ERROR_NONE;
5101 camera_cli_s *pc = (camera_cli_s *)camera;
5102 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5104 if (!pc || !pc->cb_info || !level) {
5105 LOGE("NULL pointer %p %p", pc, level);
5106 return CAMERA_ERROR_INVALID_PARAMETER;
5111 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5113 if (ret == CAMERA_ERROR_NONE)
5114 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5116 LOGD("ret : 0x%x", ret);
5122 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5124 int ret = CAMERA_ERROR_NONE;
5125 camera_cli_s *pc = (camera_cli_s *)camera;
5126 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5128 if (!pc || !pc->cb_info || !min || !max) {
5129 LOGE("NULL pointer %p %p %p", pc, min, max);
5130 return CAMERA_ERROR_INVALID_PARAMETER;
5135 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5137 if (ret == CAMERA_ERROR_NONE) {
5138 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5139 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5142 LOGD("ret : 0x%x", ret);
5148 int camera_attr_get_contrast(camera_h camera, int *level)
5150 int ret = CAMERA_ERROR_NONE;
5151 camera_cli_s *pc = (camera_cli_s *)camera;
5152 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5154 if (!pc || !pc->cb_info || !level) {
5155 LOGE("NULL pointer %p %p", pc, level);
5156 return CAMERA_ERROR_INVALID_PARAMETER;
5161 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5163 if (ret == CAMERA_ERROR_NONE)
5164 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5166 LOGD("ret : 0x%x", ret);
5172 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5174 int ret = CAMERA_ERROR_NONE;
5175 camera_cli_s *pc = (camera_cli_s *)camera;
5176 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5178 if (!pc || !pc->cb_info || !min || !max) {
5179 LOGE("NULL pointer %p %p %p", pc, min, max);
5180 return CAMERA_ERROR_INVALID_PARAMETER;
5185 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5187 if (ret == CAMERA_ERROR_NONE) {
5188 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5189 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5190 LOGD("min %d, max %d", *min, *max);
5193 LOGD("ret : 0x%x", ret);
5199 int camera_attr_get_hue(camera_h camera, int *level)
5201 int ret = CAMERA_ERROR_NONE;
5202 camera_cli_s *pc = (camera_cli_s *)camera;
5203 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE;
5205 if (!pc || !pc->cb_info || !level) {
5206 LOGE("NULL pointer %p %p", pc, level);
5207 return CAMERA_ERROR_INVALID_PARAMETER;
5212 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5214 if (ret == CAMERA_ERROR_NONE)
5215 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HUE];
5217 LOGD("ret : 0x%x", ret);
5223 int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
5225 int ret = CAMERA_ERROR_NONE;
5226 camera_cli_s *pc = (camera_cli_s *)camera;
5227 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE_RANGE;
5229 if (!pc || !pc->cb_info || !min || !max) {
5230 LOGE("NULL pointer %p %p %p", pc, min, max);
5231 return CAMERA_ERROR_INVALID_PARAMETER;
5236 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5238 if (ret == CAMERA_ERROR_NONE) {
5239 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][0];
5240 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][1];
5241 LOGD("min %d, max %d", *min, *max);
5244 LOGD("ret : 0x%x", ret);
5250 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5252 int ret = CAMERA_ERROR_NONE;
5253 camera_cli_s *pc = (camera_cli_s *)camera;
5254 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5256 if (!pc || !pc->cb_info || !wb) {
5257 LOGE("NULL pointer %p %p", pc, wb);
5258 return CAMERA_ERROR_INVALID_PARAMETER;
5263 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5265 if (ret == CAMERA_ERROR_NONE)
5266 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5268 LOGD("ret : 0x%x", ret);
5274 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5276 int ret = CAMERA_ERROR_NONE;
5277 camera_cli_s *pc = (camera_cli_s *)camera;
5278 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5280 if (!pc || !pc->cb_info || !effect) {
5281 LOGE("NULL pointer %p %p", pc, effect);
5282 return CAMERA_ERROR_INVALID_PARAMETER;
5287 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5289 if (ret == CAMERA_ERROR_NONE)
5290 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5292 LOGD("ret : 0x%x", ret);
5298 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5300 int ret = CAMERA_ERROR_NONE;
5301 camera_cli_s *pc = (camera_cli_s *)camera;
5302 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5304 if (!pc || !pc->cb_info || !mode) {
5305 LOGE("NULL pointer %p %p", pc, mode);
5306 return CAMERA_ERROR_INVALID_PARAMETER;
5311 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5313 if (ret == CAMERA_ERROR_NONE)
5314 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5316 LOGD("ret : 0x%x", ret);
5322 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5324 int ret = CAMERA_ERROR_NONE;
5325 camera_cli_s *pc = (camera_cli_s *)camera;
5326 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5328 if (!pc || !pc->cb_info || !enable) {
5329 LOGE("NULL pointer %p %p", pc, enable);
5330 return CAMERA_ERROR_INVALID_PARAMETER;
5335 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5337 if (ret == CAMERA_ERROR_NONE)
5338 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5340 LOGD("ret : 0x%x", ret);
5346 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5348 int ret = CAMERA_ERROR_NONE;
5349 camera_cli_s *pc = (camera_cli_s *)camera;
5350 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5352 if (!pc || !pc->cb_info || !description) {
5353 LOGE("NULL pointer %p %p", pc, description);
5354 return CAMERA_ERROR_INVALID_PARAMETER;
5359 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5361 if (ret == CAMERA_ERROR_NONE)
5362 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5364 LOGD("ret : 0x%x", ret);
5370 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5372 int ret = CAMERA_ERROR_NONE;
5373 camera_cli_s *pc = (camera_cli_s *)camera;
5374 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5376 if (!pc || !pc->cb_info || !orientation) {
5377 LOGE("NULL pointer %p %p", pc, orientation);
5378 return CAMERA_ERROR_INVALID_PARAMETER;
5383 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5385 if (ret == CAMERA_ERROR_NONE)
5386 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5388 LOGD("ret : 0x%x", ret);
5394 int camera_attr_get_tag_software(camera_h camera, char **software)
5396 int ret = CAMERA_ERROR_NONE;
5397 camera_cli_s *pc = (camera_cli_s *)camera;
5398 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5400 if (!pc || !pc->cb_info || !software) {
5401 LOGE("NULL pointer %p %p", pc, software);
5402 return CAMERA_ERROR_INVALID_PARAMETER;
5407 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5409 if (ret == CAMERA_ERROR_NONE)
5410 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5412 LOGD("ret : 0x%x", ret);
5418 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5420 int ret = CAMERA_ERROR_NONE;
5421 camera_cli_s *pc = (camera_cli_s *)camera;
5422 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5424 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5425 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5426 return CAMERA_ERROR_INVALID_PARAMETER;
5431 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5433 if (ret == CAMERA_ERROR_NONE) {
5434 *latitude = pc->cb_info->get_geotag[0];
5435 *longitude = pc->cb_info->get_geotag[1];
5436 *altitude = pc->cb_info->get_geotag[2];
5439 LOGD("ret : 0x%x", ret);
5445 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5447 int ret = CAMERA_ERROR_NONE;
5448 camera_cli_s *pc = (camera_cli_s *)camera;
5449 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5451 if (!pc || !pc->cb_info || !mode) {
5452 LOGE("NULL pointer %p %p", pc, mode);
5453 return CAMERA_ERROR_INVALID_PARAMETER;
5458 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5460 if (ret == CAMERA_ERROR_NONE)
5461 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5463 LOGD("ret : 0x%x", ret);
5469 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5471 int ret = CAMERA_ERROR_NONE;
5472 int get_flash_state = 0;
5475 LOGE("NULL pointer");
5476 return CAMERA_ERROR_INVALID_PARAMETER;
5479 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5480 (int)device, "get_flash_state", &get_flash_state);
5482 if (ret == CAMERA_ERROR_NONE) {
5483 *state = (camera_flash_state_e)get_flash_state;
5484 LOGD("flash state %d", *state);
5486 LOGE("failed 0x%x", ret);
5493 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5495 int ret = CAMERA_ERROR_NONE;
5496 camera_cli_s *pc = (camera_cli_s *)camera;
5497 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5499 if (!pc || !pc->cb_info || !foreach_cb) {
5500 LOGE("NULL pointer %p %p", pc, foreach_cb);
5501 return CAMERA_ERROR_INVALID_PARAMETER;
5506 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5507 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5509 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5511 LOGD("ret : 0x%x", ret);
5517 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5519 int ret = CAMERA_ERROR_NONE;
5520 camera_cli_s *pc = (camera_cli_s *)camera;
5521 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5523 if (!pc || !pc->cb_info || !foreach_cb) {
5524 LOGE("NULL pointer %p %p", pc, foreach_cb);
5525 return CAMERA_ERROR_INVALID_PARAMETER;
5530 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5531 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5533 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5535 LOGD("ret : 0x%x", ret);
5541 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5543 int ret = CAMERA_ERROR_NONE;
5544 camera_cli_s *pc = (camera_cli_s *)camera;
5545 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5547 if (!pc || !pc->cb_info || !foreach_cb) {
5548 LOGE("NULL pointer %p %p", pc, foreach_cb);
5549 return CAMERA_ERROR_INVALID_PARAMETER;
5554 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5555 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5557 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5559 LOGD("ret : 0x%x", ret);
5565 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5567 int ret = CAMERA_ERROR_NONE;
5568 camera_cli_s *pc = (camera_cli_s *)camera;
5569 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5571 if (!pc || !pc->cb_info || !foreach_cb) {
5572 LOGE("NULL pointer %p %p", pc, foreach_cb);
5573 return CAMERA_ERROR_INVALID_PARAMETER;
5578 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5579 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5581 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5583 LOGD("ret : 0x%x", ret);
5589 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5591 int ret = CAMERA_ERROR_NONE;
5592 camera_cli_s *pc = (camera_cli_s *)camera;
5593 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5595 if (!pc || !pc->cb_info || !foreach_cb) {
5596 LOGE("NULL pointer %p %p", pc, foreach_cb);
5597 return CAMERA_ERROR_INVALID_PARAMETER;
5602 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5603 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5605 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5607 LOGD("ret : 0x%x", ret);
5613 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5615 int ret = CAMERA_ERROR_NONE;
5616 camera_cli_s *pc = (camera_cli_s *)camera;
5617 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5619 if (!pc || !pc->cb_info || !foreach_cb) {
5620 LOGE("NULL pointer %p %p", pc, foreach_cb);
5621 return CAMERA_ERROR_INVALID_PARAMETER;
5626 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5627 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5629 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5631 LOGD("ret : 0x%x", ret);
5637 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5639 int ret = CAMERA_ERROR_NONE;
5640 camera_cli_s *pc = (camera_cli_s *)camera;
5641 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5643 if (!pc || !pc->cb_info || !foreach_cb) {
5644 LOGE("NULL pointer %p %p", pc, foreach_cb);
5645 return CAMERA_ERROR_INVALID_PARAMETER;
5650 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5651 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5653 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5655 LOGD("ret : 0x%x", ret);
5661 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5663 int ret = CAMERA_ERROR_NONE;
5664 camera_cli_s *pc = (camera_cli_s *)camera;
5665 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5667 if (!pc || !pc->cb_info || !foreach_cb) {
5668 LOGE("NULL pointer %p %p", pc, foreach_cb);
5669 return CAMERA_ERROR_INVALID_PARAMETER;
5674 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5675 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5677 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5679 LOGD("Enter, handle :%td", pc->remote_handle);
5685 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)
5687 int ret = CAMERA_ERROR_NONE;
5688 camera_cli_s *pc = (camera_cli_s *)camera;
5689 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5690 camera_msg_param param;
5693 if (!pc || !pc->cb_info || !foreach_cb) {
5694 LOGE("NULL pointer %p %p", pc, foreach_cb);
5695 return CAMERA_ERROR_INVALID_PARAMETER;
5700 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5701 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5703 value = (width << 16) | height;
5704 CAMERA_MSG_PARAM_SET(param, INT, value);
5706 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5708 LOGD("ret : 0x%x", ret);
5714 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5716 int ret = CAMERA_ERROR_NONE;
5717 camera_cli_s *pc = (camera_cli_s *)camera;
5718 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5720 if (!pc || !pc->cb_info || !foreach_cb) {
5721 LOGE("NULL pointer %p %p", pc, foreach_cb);
5722 return CAMERA_ERROR_INVALID_PARAMETER;
5727 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5728 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5730 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5732 LOGD("ret : 0x%x", ret);
5738 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5740 int ret = CAMERA_ERROR_NONE;
5741 camera_cli_s *pc = (camera_cli_s *)camera;
5742 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5744 if (!pc || !pc->cb_info || !foreach_cb) {
5745 LOGE("NULL pointer %p %p", pc, foreach_cb);
5746 return CAMERA_ERROR_INVALID_PARAMETER;
5751 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5752 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5754 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5756 LOGD("ret : 0x%x", ret);
5762 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5764 int ret = CAMERA_ERROR_NONE;
5765 camera_cli_s *pc = (camera_cli_s *)camera;
5766 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5767 camera_msg_param param;
5768 int set_rotation = (int)rotation;
5770 if (!pc || !pc->cb_info) {
5771 LOGE("NULL handle");
5772 return CAMERA_ERROR_INVALID_PARAMETER;
5777 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5779 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5781 LOGD("ret : 0x%x", ret);
5787 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5789 int ret = CAMERA_ERROR_NONE;
5790 camera_cli_s *pc = (camera_cli_s *)camera;
5791 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5793 if (!pc || !pc->cb_info || !rotation) {
5794 LOGE("NULL pointer %p %p", pc, rotation);
5795 return CAMERA_ERROR_INVALID_PARAMETER;
5800 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5802 if (ret == CAMERA_ERROR_NONE)
5803 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5805 LOGD("ret : 0x%x", ret);
5811 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5813 int ret = CAMERA_ERROR_NONE;
5814 camera_cli_s *pc = (camera_cli_s *)camera;
5815 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5816 camera_msg_param param;
5817 int set_flip = (int)flip;
5819 if (!pc || !pc->cb_info) {
5820 LOGE("NULL handle");
5821 return CAMERA_ERROR_INVALID_PARAMETER;
5826 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5828 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5830 LOGD("ret : 0x%x", ret);
5836 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5838 int ret = CAMERA_ERROR_NONE;
5839 camera_cli_s *pc = (camera_cli_s *)camera;
5840 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5842 if (!pc || !pc->cb_info || !flip) {
5843 LOGE("NULL pointer %p %p", pc, flip);
5844 return CAMERA_ERROR_INVALID_PARAMETER;
5849 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5851 if (ret == CAMERA_ERROR_NONE)
5852 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5854 LOGD("ret : 0x%x", ret);
5859 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5861 int ret = CAMERA_ERROR_NONE;
5862 camera_cli_s *pc = (camera_cli_s *)camera;
5863 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5864 camera_msg_param param;
5865 int set_mode = (int)mode;
5867 if (!pc || !pc->cb_info) {
5868 LOGE("NULL handle");
5869 return CAMERA_ERROR_INVALID_PARAMETER;
5874 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5876 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5878 LOGD("ret : 0x%x", ret);
5884 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5886 int ret = CAMERA_ERROR_NONE;
5887 camera_cli_s *pc = (camera_cli_s *)camera;
5888 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5890 if (!pc || !pc->cb_info || !mode) {
5891 LOGE("NULL pointer %p %p", pc, mode);
5892 return CAMERA_ERROR_INVALID_PARAMETER;
5897 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5899 if (ret == CAMERA_ERROR_NONE)
5900 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
5902 LOGD("ret : 0x%x", ret);
5908 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5910 int ret = CAMERA_ERROR_NONE;
5911 camera_cli_s *pc = (camera_cli_s *)camera;
5912 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
5914 if (!pc || !pc->cb_info) {
5915 LOGE("NULL handle");
5916 return CAMERA_ERROR_INVALID_PARAMETER;
5921 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5924 LOGE("error is occurred 0x%x", ret);
5928 LOGD("ret : %d", ret);
5934 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5936 int ret = CAMERA_ERROR_NONE;
5937 camera_cli_s *pc = (camera_cli_s *)camera;
5938 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5940 if (!pc || !pc->cb_info) {
5941 LOGE("NULL handle");
5942 return CAMERA_ERROR_INVALID_PARAMETER;
5947 if (!camera_attr_is_supported_hdr_capture(camera)) {
5948 LOGE("HDR not supported");
5949 return CAMERA_ERROR_NOT_SUPPORTED;
5953 LOGE("NULL callback");
5954 return CAMERA_ERROR_INVALID_PARAMETER;
5957 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5959 if (ret == CAMERA_ERROR_NONE) {
5960 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5962 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5963 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5965 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5968 LOGD("ret : 0x%x", ret);
5974 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5976 int ret = CAMERA_ERROR_NONE;
5977 camera_cli_s *pc = (camera_cli_s *)camera;
5978 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5980 if (!pc || !pc->cb_info) {
5981 LOGE("NULL handle");
5982 return CAMERA_ERROR_INVALID_PARAMETER;
5987 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5989 if (ret == CAMERA_ERROR_NONE) {
5990 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5992 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5993 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5995 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5998 LOGD("ret : 0x%x", ret);
6004 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6006 int ret = CAMERA_ERROR_NONE;
6007 camera_cli_s *pc = (camera_cli_s *)camera;
6008 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
6009 camera_msg_param param;
6010 int set_enable = (int)enable;
6012 if (!pc || !pc->cb_info) {
6013 LOGE("NULL handle");
6014 return CAMERA_ERROR_INVALID_PARAMETER;
6019 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6021 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6023 LOGD("ret : 0x%x", ret);
6029 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6031 int ret = CAMERA_ERROR_NONE;
6032 camera_cli_s *pc = (camera_cli_s *)camera;
6033 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6035 if (!pc || !pc->cb_info || !enabled) {
6036 LOGE("NULL pointer %p %p", pc, enabled);
6037 return CAMERA_ERROR_INVALID_PARAMETER;
6042 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6044 if (ret == CAMERA_ERROR_NONE)
6045 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6047 LOGD("ret : 0x%x", ret);
6053 bool camera_attr_is_supported_anti_shake(camera_h camera)
6055 int ret = CAMERA_ERROR_NONE;
6056 camera_cli_s *pc = (camera_cli_s *)camera;
6057 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6059 if (!pc || !pc->cb_info) {
6060 LOGE("NULL handle");
6061 return CAMERA_ERROR_INVALID_PARAMETER;
6066 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6069 LOGE("error is occurred 0x%x", ret);
6073 LOGD("ret : %d", ret);
6079 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6081 int ret = CAMERA_ERROR_NONE;
6082 camera_cli_s *pc = (camera_cli_s *)camera;
6083 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6084 camera_msg_param param;
6085 int set_enable = (int)enable;
6087 if (!pc || !pc->cb_info) {
6088 LOGE("NULL handle");
6089 return CAMERA_ERROR_INVALID_PARAMETER;
6094 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6096 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6098 LOGD("ret : 0x%x", ret);
6104 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6106 int ret = CAMERA_ERROR_NONE;
6107 camera_cli_s *pc = (camera_cli_s *)camera;
6108 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6110 if (!pc || !pc->cb_info || !enabled) {
6111 LOGE("NULL pointer %p %p", pc, enabled);
6112 return CAMERA_ERROR_INVALID_PARAMETER;
6117 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6119 if (ret == CAMERA_ERROR_NONE)
6120 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6122 LOGD("ret : 0x%x", ret);
6128 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6130 int ret = CAMERA_ERROR_NONE;
6131 camera_cli_s *pc = (camera_cli_s *)camera;
6132 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6134 if (!pc || !pc->cb_info) {
6135 LOGE("NULL handle");
6136 return CAMERA_ERROR_INVALID_PARAMETER;
6141 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6144 LOGE("error is occurred 0x%x", ret);
6148 LOGD("ret : %d", ret);
6154 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6156 int ret = CAMERA_ERROR_NONE;
6157 camera_cli_s *pc = (camera_cli_s *)camera;
6158 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6159 camera_msg_param param;
6160 int set_enable = (int)enable;
6162 if (!pc || !pc->cb_info) {
6163 LOGE("NULL handle");
6164 return CAMERA_ERROR_INVALID_PARAMETER;
6169 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6171 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6173 LOGD("ret : 0x%x", ret);
6179 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6181 int ret = CAMERA_ERROR_NONE;
6182 camera_cli_s *pc = (camera_cli_s *)camera;
6183 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6185 if (!pc || !pc->cb_info || !enabled) {
6186 LOGE("NULL pointer %p %p", pc, enabled);
6187 return CAMERA_ERROR_INVALID_PARAMETER;
6192 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6194 if (ret == CAMERA_ERROR_NONE)
6195 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6197 LOGD("ret : 0x%x", ret);
6203 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6205 int ret = CAMERA_ERROR_NONE;
6206 camera_cli_s *pc = (camera_cli_s *)camera;
6207 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6209 if (!pc || !pc->cb_info) {
6210 LOGE("NULL handle");
6211 return CAMERA_ERROR_INVALID_PARAMETER;
6216 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6219 LOGE("error is occurred 0x%x", ret);
6223 LOGD("ret : %d", ret);
6229 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6231 int ret = CAMERA_ERROR_NONE;
6232 camera_cli_s *pc = (camera_cli_s *)camera;
6233 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6234 camera_msg_param param;
6235 int set_disable = (int)disable;
6237 if (!pc || !pc->cb_info) {
6238 LOGE("NULL handle");
6239 return CAMERA_ERROR_INVALID_PARAMETER;
6244 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6246 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6248 LOGD("ret : 0x%x", ret);
6254 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6256 int ret = CAMERA_ERROR_NONE;
6257 camera_cli_s *pc = (camera_cli_s *)camera;
6258 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6259 camera_msg_param param;
6260 int set_move_type = (int)move_type;
6263 if (!pc || !pc->cb_info) {
6264 LOGE("NULL handle");
6265 return CAMERA_ERROR_INVALID_PARAMETER;
6270 value = (set_move_type << 16) | pan_step;
6271 CAMERA_MSG_PARAM_SET(param, INT, value);
6273 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6275 LOGD("ret : 0x%x", ret);
6281 int camera_attr_get_pan(camera_h camera, int *pan_step)
6283 int ret = CAMERA_ERROR_NONE;
6284 camera_cli_s *pc = (camera_cli_s *)camera;
6285 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6287 if (!pc || !pc->cb_info || !pan_step) {
6288 LOGE("NULL pointer %p %p", pc, pan_step);
6289 return CAMERA_ERROR_INVALID_PARAMETER;
6294 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6296 if (ret == CAMERA_ERROR_NONE)
6297 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6299 LOGD("ret : 0x%x", ret);
6305 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6307 int ret = CAMERA_ERROR_NONE;
6308 camera_cli_s *pc = (camera_cli_s *)camera;
6309 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6311 if (!pc || !pc->cb_info || !min || !max) {
6312 LOGE("NULL pointer %p %p %p", pc, min, max);
6313 return CAMERA_ERROR_INVALID_PARAMETER;
6318 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6320 if (ret == CAMERA_ERROR_NONE) {
6321 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6322 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6325 LOGD("ret : 0x%x", ret);
6331 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6333 int ret = CAMERA_ERROR_NONE;
6334 camera_cli_s *pc = (camera_cli_s *)camera;
6335 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6336 camera_msg_param param;
6337 int set_move_type = (int)move_type;
6340 if (!pc || !pc->cb_info) {
6341 LOGE("NULL handle");
6342 return CAMERA_ERROR_INVALID_PARAMETER;
6347 value = (set_move_type << 16) | tilt_step;
6348 CAMERA_MSG_PARAM_SET(param, INT, value);
6350 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6352 LOGD("ret : 0x%x", ret);
6358 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6360 int ret = CAMERA_ERROR_NONE;
6361 camera_cli_s *pc = (camera_cli_s *)camera;
6362 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6364 if (!pc || !pc->cb_info || !tilt_step) {
6365 LOGE("NULL pointer %p %p", pc, tilt_step);
6366 return CAMERA_ERROR_INVALID_PARAMETER;
6371 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6373 if (ret == CAMERA_ERROR_NONE)
6374 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6376 LOGD("ret : 0x%x", ret);
6382 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6384 int ret = CAMERA_ERROR_NONE;
6385 camera_cli_s *pc = (camera_cli_s *)camera;
6386 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6388 if (!pc || !pc->cb_info || !min || !max) {
6389 LOGE("NULL pointer %p %p %p", pc, min, max);
6390 return CAMERA_ERROR_INVALID_PARAMETER;
6395 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6397 if (ret == CAMERA_ERROR_NONE) {
6398 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6399 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6402 LOGD("ret : 0x%x", ret);
6408 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6410 int ret = CAMERA_ERROR_NONE;
6411 camera_cli_s *pc = (camera_cli_s *)camera;
6412 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6413 camera_msg_param param;
6414 int set_ptz_type = (int)ptz_type;
6416 if (!pc || !pc->cb_info) {
6417 LOGE("NULL handle");
6418 return CAMERA_ERROR_INVALID_PARAMETER;
6423 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6425 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6427 LOGD("ret : 0x%x", ret);
6433 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6435 int ret = CAMERA_ERROR_NONE;
6436 camera_cli_s *pc = (camera_cli_s *)camera;
6437 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6439 if (!pc || !pc->cb_info || !foreach_cb) {
6440 LOGE("NULL pointer %p %p", pc, foreach_cb);
6441 return CAMERA_ERROR_INVALID_PARAMETER;
6446 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6447 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6449 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6451 LOGD("ret : 0x%x", ret);
6457 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6459 int ret = CAMERA_ERROR_NONE;
6460 camera_cli_s *pc = (camera_cli_s *)camera;
6461 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6462 int set_display_roi_area[4] = {x, y, width, height};
6467 if (!pc || !pc->cb_info) {
6468 LOGE("NULL handle");
6469 return CAMERA_ERROR_INVALID_PARAMETER;
6474 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6475 ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
6476 if (ret != MM_ERROR_NONE) {
6477 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6478 return CAMERA_ERROR_INVALID_OPERATION;
6482 length = sizeof(set_display_roi_area) / sizeof(int) + \
6483 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6485 msg = muse_core_msg_new(api,
6486 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6489 LOGE("msg creation failed: api %d", api);
6490 return CAMERA_ERROR_OUT_OF_MEMORY;
6493 if (pc->cb_info->is_server_connected) {
6494 __camera_update_api_waiting(pc->cb_info, api, 1);
6496 g_mutex_lock(&pc->cb_info->fd_lock);
6497 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
6498 g_mutex_unlock(&pc->cb_info->fd_lock);
6502 LOGE("message send failed");
6503 ret = CAMERA_ERROR_INVALID_OPERATION;
6505 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6508 __camera_update_api_waiting(pc->cb_info, api, -1);
6510 muse_core_msg_free(msg);
6512 LOGD("ret : 0x%x", ret);
6518 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6520 camera_cli_s *pc = (camera_cli_s *)camera;
6521 int ret = CAMERA_ERROR_NONE;
6522 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6524 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6525 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6526 return CAMERA_ERROR_INVALID_PARAMETER;
6531 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6533 if (ret == CAMERA_ERROR_NONE) {
6534 *x = pc->cb_info->get_display_roi_area[0];
6535 *y = pc->cb_info->get_display_roi_area[1];
6536 *width = pc->cb_info->get_display_roi_area[2];
6537 *height = pc->cb_info->get_display_roi_area[3];
6540 LOGD("ret : 0x%x", ret);
6546 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6548 int ret = CAMERA_ERROR_NONE;
6549 int get_device_state = 0;
6552 LOGE("NULL pointer");
6553 return CAMERA_ERROR_INVALID_PARAMETER;
6556 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6557 (int)device, "get_device_state", &get_device_state);
6559 if (ret == CAMERA_ERROR_NONE) {
6560 *state = (camera_device_state_e)get_device_state;
6561 LOGD("device state %d", *state);
6563 LOGE("failed 0x%x", ret);
6570 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6572 int ret = CAMERA_ERROR_NONE;
6573 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6574 camera_cb_info *info = NULL;
6576 if (!callback || !cb_id) {
6577 LOGE("invalid pointer %p %p", callback, cb_id);
6578 return CAMERA_ERROR_INVALID_PARAMETER;
6581 /* check camera support */
6582 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6583 if (ret != CAMERA_ERROR_NONE) {
6584 LOGE("get device state failed");
6588 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6590 info = g_new0(camera_cb_info, 1);
6592 LOGE("info failed");
6593 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6597 info->id = ++g_cam_dev_state_changed_cb_id;
6598 info->callback = (void *)callback;
6599 info->user_data = user_data;
6603 /* subscribe dbus signal for camera state change */
6604 if (!g_cam_dev_state_changed_cb_conn) {
6605 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6606 if (!g_cam_dev_state_changed_cb_conn) {
6607 LOGE("failed to get gdbus connection");
6608 ret = CAMERA_ERROR_INVALID_OPERATION;
6612 LOGD("subscribe signal %s - %s - %s",
6613 MM_CAMCORDER_DBUS_OBJECT,
6614 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6615 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6617 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6618 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6619 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6620 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6621 LOGE("failed to get gdbus connection");
6622 ret = CAMERA_ERROR_INVALID_OPERATION;
6626 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6629 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6631 LOGD("callback id %d", info->id);
6634 if (ret != CAMERA_ERROR_NONE) {
6640 if (g_cam_dev_state_changed_cb_conn) {
6641 g_object_unref(g_cam_dev_state_changed_cb_conn);
6642 g_cam_dev_state_changed_cb_conn = NULL;
6646 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6652 int camera_remove_device_state_changed_cb(int cb_id)
6654 int ret = CAMERA_ERROR_NONE;
6655 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6656 GList *tmp_list = NULL;
6657 camera_cb_info *info = NULL;
6659 /* check camera support */
6660 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6661 if (ret != CAMERA_ERROR_NONE) {
6662 LOGE("get device state failed");
6666 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6668 if (!g_cam_dev_state_changed_cb_list) {
6669 LOGE("there is no callback info");
6670 ret = CAMERA_ERROR_INVALID_OPERATION;
6674 tmp_list = g_cam_dev_state_changed_cb_list;
6677 info = tmp_list->data;
6678 tmp_list = tmp_list->next;
6685 if (info->id == cb_id) {
6686 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6691 if (!g_cam_dev_state_changed_cb_list) {
6692 /* no remained callback */
6693 if (g_cam_dev_state_changed_cb_conn) {
6694 /* unsubscribe signal */
6695 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6696 g_cam_dev_state_changed_cb_subscribe_id = 0;
6698 /* unref connection */
6699 g_object_unref(g_cam_dev_state_changed_cb_conn);
6700 g_cam_dev_state_changed_cb_conn = NULL;
6704 LOGD("id %d callback removed", cb_id);
6705 ret = CAMERA_ERROR_NONE;
6711 LOGE("id %d callback not found", cb_id);
6712 ret = CAMERA_ERROR_INVALID_PARAMETER;
6715 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);