2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
24 #include <muse_camera.h>
25 #include <muse_camera_msg.h>
26 #include <camera_private.h>
27 #include <muse_core.h>
28 #include <muse_client.h>
30 #include <tbm_surface_internal.h>
36 #define LOG_TAG "TIZEN_N_CAMERA"
38 /* for device changed callback */
39 static GMutex g_cam_dev_state_changed_cb_lock;
40 static GList *g_cam_dev_state_changed_cb_list;
41 static int g_cam_dev_state_changed_cb_id;
42 static GDBusConnection *g_cam_dev_state_changed_cb_conn;
43 static guint g_cam_dev_state_changed_cb_subscribe_id;
45 static void _camera_msg_send(int api, camera_cb_info_s *cb_info,
46 int *ret, int timeout);
47 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
48 int *ret, camera_msg_param *param, int timeout);
49 static int _camera_import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle);
50 static void _camera_release_imported_bo(tbm_bo *bo);
51 static void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_key,
52 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame);
53 static int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
54 camera_media_packet_data *mp_data, media_packet_h *packet);
55 static int _camera_media_packet_data_create(int tbm_key, int num_buffer_key, tbm_bo bo,
56 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data);
57 static void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info);
60 static void __camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value)
63 api < 0 || api >= MUSE_CAMERA_API_MAX) {
64 LOGE("invalid param %p %d", cb_info, api);
68 g_mutex_lock(&(cb_info->api_mutex[api]));
69 cb_info->api_waiting[api] += value;
70 g_mutex_unlock(&(cb_info->api_mutex[api]));
72 /*LOGD("api %d, value %d, waiting %d",
73 api, value, cb_info->api_waiting[api]);*/
79 static void __camera_device_state_changed_cb(GDBusConnection *connection,
80 const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
81 const gchar *signal_name, GVariant *param, gpointer user_data)
84 camera_device_e device = CAMERA_DEVICE_CAMERA0;
85 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
86 GList *tmp_list = NULL;
87 camera_cb_info *info = NULL;
89 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
91 if (!g_cam_dev_state_changed_cb_list || !param) {
92 LOGW("no callback or NULL param %p", param);
96 /* get device and state */
97 g_variant_get(param, "(i)", &value);
100 state = 0x0000ffff & value;
102 LOGD("device %d, state %d", device, state);
104 tmp_list = g_cam_dev_state_changed_cb_list;
107 info = (camera_cb_info *)tmp_list->data;
110 if (info->callback) {
111 LOGD("start id[%d] callback", info->id);
112 ((camera_device_state_changed_cb)info->callback)(device, state, info->user_data);
113 LOGD("returned id[%d] callback", info->id);
115 LOGW("NULL callback for id %d", info->id);
119 tmp_list = tmp_list->next;
123 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
129 static void __camera_event_handler_preview(camera_cb_info_s *cb_info, char *recv_msg)
133 int num_buffer_key = 0;
134 int buffer_key[BUFFER_MAX_PLANE_NUM] = {0, };
137 unsigned char *buf_pos = NULL;
138 camera_msg_param param;
141 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
142 tbm_bo_handle bo_handle = {.ptr = NULL};
143 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
144 tbm_bo data_bo = NULL;
145 tbm_bo_handle data_bo_handle = {.ptr = NULL};
147 camera_preview_data_s frame;
148 camera_stream_data_s *stream = NULL;
149 camera_media_packet_data *mp_data = NULL;
150 media_packet_h pkt = NULL;
151 media_packet_h pkt_evas = NULL;
153 if (!cb_info || !recv_msg) {
154 LOGE("invalid param %p %p", cb_info, recv_msg);
158 muse_camera_msg_get(tbm_key, recv_msg);
159 muse_camera_msg_get(num_buffer_key, recv_msg);
160 muse_camera_msg_get_array(buffer_key, recv_msg);
161 muse_camera_msg_get(data_key, recv_msg);
163 memset(&frame, 0x0, sizeof(camera_preview_data_s));
166 LOGE("invalid key %d", tbm_key);
170 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
172 if (num_buffer_key < 0 || num_buffer_key > BUFFER_MAX_PLANE_NUM) {
173 LOGE("invalid num buffer key %d", num_buffer_key);
174 goto _PREVIEW_CB_HANDLER_DONE;
178 /* import tbm data_bo and get virtual address */
179 if (!_camera_import_tbm_key(cb_info->bufmgr, data_key, &data_bo, &data_bo_handle)) {
180 LOGE("failed to import data key %d", data_key);
181 goto _PREVIEW_CB_HANDLER_DONE;
185 /* import tbm bo and get virtual address */
186 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
187 LOGE("failed to import key %d", tbm_key);
188 goto _PREVIEW_CB_HANDLER_DONE;
191 buf_pos = (unsigned char *)bo_handle.ptr;
193 /* get stream info */
194 stream = (camera_stream_data_s *)buf_pos;
196 for (i = 0 ; i < num_buffer_key ; i++) {
197 /* import buffer bo and get virtual address */
198 if (!_camera_import_tbm_key(cb_info->bufmgr, buffer_key[i], &buffer_bo[i], &buffer_bo_handle[i])) {
199 LOGE("failed to import buffer key %d", buffer_key[i]);
200 goto _PREVIEW_CB_HANDLER_DONE;
204 /* call preview callback */
205 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
206 _camera_preview_frame_create(stream, num_buffer_key, buffer_bo_handle, &data_bo_handle, &frame);
208 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
209 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
212 if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
213 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
215 if (ret == CAMERA_ERROR_NONE) {
216 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt_evas);
217 if (ret != CAMERA_ERROR_NONE) {
218 LOGE("create pkt for evas failed");
219 _camera_media_packet_data_release(mp_data, cb_info);
225 /* call media packet callback */
226 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
227 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
229 if (ret == CAMERA_ERROR_NONE) {
230 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt);
232 if (ret == CAMERA_ERROR_NONE) {
233 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
234 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
236 _camera_media_packet_data_release(mp_data, cb_info);
242 /* call evas renderer */
244 if (cb_info->run_evas_render) {
245 mm_display_interface_evas_render(cb_info->dp_interface, pkt_evas);
247 LOGW("evas renderer is stopped, skip this buffer...");
248 media_packet_destroy(pkt_evas);
253 /* send message for preview callback return */
254 if (!CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS))
255 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info, NULL, 0);
257 _PREVIEW_CB_HANDLER_DONE:
258 if (mp_data == NULL) {
259 /* release imported bo */
260 for (i = 0 ; i < num_buffer_key && i < BUFFER_MAX_PLANE_NUM ; i++)
261 _camera_release_imported_bo(&buffer_bo[i]);
263 /* unmap and unref tbm bo */
264 _camera_release_imported_bo(&data_bo);
265 _camera_release_imported_bo(&bo);
268 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
270 /*LOGD("return buffer Done");*/
277 static void __camera_event_handler_capture(camera_cb_info_s *cb_info, char *recv_msg)
280 int tbm_key_main = 0;
281 int tbm_key_post = 0;
282 int tbm_key_thumb = 0;
283 unsigned char *buf_pos = NULL;
285 camera_msg_param param;
286 camera_image_data_s *rImage = NULL;
287 camera_image_data_s *rPostview = NULL;
288 camera_image_data_s *rThumbnail = NULL;
290 tbm_bo bo_main = NULL;
291 tbm_bo bo_post = NULL;
292 tbm_bo bo_thumb = NULL;
293 tbm_bo_handle bo_main_handle = {.ptr = NULL};
294 tbm_bo_handle bo_post_handle = {.ptr = NULL};
295 tbm_bo_handle bo_thumb_handle = {.ptr = NULL};
297 if (!cb_info || !recv_msg) {
298 LOGE("invalid param %p %p", cb_info, recv_msg);
302 muse_camera_msg_get(tbm_key_main, recv_msg);
303 muse_camera_msg_get(tbm_key_post, recv_msg);
304 muse_camera_msg_get(tbm_key_thumb, recv_msg);
307 LOGD("camera capture callback came in. tbm_key_main %d, tbm_key_post %d, tbm_key_thumb %d",
308 tbm_key_main, tbm_key_post, tbm_key_thumb);
311 if (tbm_key_main <= 0) {
312 LOGE("invalid key %d", tbm_key_main);
313 goto _CAPTURE_CB_HANDLER_DONE;
316 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] == NULL) {
317 LOGW("NULL callback");
318 goto _CAPTURE_CB_HANDLER_DONE;
321 /* import tbm bo and get virtual address */
322 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_main, &bo_main, &bo_main_handle)) {
323 LOGE("failed to import key [%d] for main", tbm_key_main);
324 goto _CAPTURE_CB_HANDLER_DONE;
327 buf_pos = (unsigned char *)bo_main_handle.ptr;
328 rImage = (camera_image_data_s *)buf_pos;
329 rImage->data = buf_pos + sizeof(camera_image_data_s);
330 if (rImage->exif && rImage->exif_size > 0) {
331 rImage->exif = rImage->data + rImage->size;
334 rImage->exif_size = 0;
337 LOGD("image info %dx%d, size %d, EXIF info %p, size %d",
338 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
340 if (tbm_key_post > 0) {
341 /* import tbm bo and get virtual address */
342 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key_post, &bo_post, &bo_post_handle)) {
343 buf_pos = (unsigned char *)bo_post_handle.ptr;
344 rPostview = (camera_image_data_s *)buf_pos;
345 LOGD("rPostview->size : %d", rPostview->size);
346 rPostview->data = buf_pos + sizeof(camera_image_data_s);
348 LOGE("failed to import key [%d] for postview", tbm_key_post);
352 if (tbm_key_thumb > 0) {
353 /* import tbm bo and get virtual address */
354 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key_thumb, &bo_thumb, &bo_thumb_handle)) {
355 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
356 rThumbnail = (camera_image_data_s *)buf_pos;
357 LOGD("rThumbnail->size : %d", rThumbnail->size);
358 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
360 LOGE("failed to import key [%d] for thumbnail", tbm_key_thumb);
364 ((camera_capturing_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE])(rImage,
365 rPostview, rThumbnail, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE]);
367 _CAPTURE_CB_HANDLER_DONE:
369 if (tbm_key_main > 0) {
370 _camera_release_imported_bo(&bo_main);
372 tbm_key = tbm_key_main;
373 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
375 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
378 if (tbm_key_post > 0) {
379 _camera_release_imported_bo(&bo_post);
381 tbm_key = tbm_key_post;
382 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
384 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
387 if (tbm_key_thumb > 0) {
388 _camera_release_imported_bo(&bo_thumb);
390 tbm_key = tbm_key_thumb;
391 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
393 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
396 LOGD("return buffer done");
402 static void __camera_event_handler_face_detection(camera_cb_info_s *cb_info, char *recv_msg)
406 camera_detected_face_s *faces = NULL;
407 camera_msg_param param;
410 tbm_bo_handle bo_handle = {.ptr = NULL};
412 if (!cb_info || !recv_msg) {
413 LOGE("invalid param %p %p", cb_info, recv_msg);
417 muse_camera_msg_get(count, recv_msg);
418 muse_camera_msg_get(tbm_key, recv_msg);
420 if (count >= 0 && cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]) {
421 LOGD("FACE_DETECTION - count %d, tbm_key %d", count, tbm_key);
425 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
427 faces = bo_handle.ptr;
431 ((camera_face_detected_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION])(faces,
432 count, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
435 _camera_release_imported_bo(&bo);
437 LOGW("skip face detection message [count %d, key %d, cb %p",
438 count, tbm_key, cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
443 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
444 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
445 /*LOGD("return buffer done");*/
452 static int _camera_import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle)
454 tbm_bo tmp_bo = NULL;
455 tbm_bo_handle tmp_bo_handle = {NULL, };
457 if (!bufmgr || !bo || !bo_handle || !tbm_key) {
458 LOGE("invalid parameter - %p %p %p, key %d",
459 bufmgr, bo, bo_handle, tbm_key);
463 tmp_bo = tbm_bo_import(bufmgr, tbm_key);
464 if (tmp_bo == NULL) {
465 LOGE("import failed - key %d", tbm_key);
469 tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
470 if (tmp_bo_handle.ptr == NULL) {
471 LOGE("map failed %p", tmp_bo);
472 tbm_bo_unref(tmp_bo);
477 tbm_bo_unmap(tmp_bo);
479 /* set bo and bo_handle */
481 *bo_handle = tmp_bo_handle;
486 static void _camera_release_imported_bo(tbm_bo *bo)
499 static int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
501 int ret = CAMERA_ERROR_NONE;
504 /*LOGD("Enter api : %d", api);*/
506 if (!cb_info->is_server_connected) {
507 LOGE("server is disconnected");
508 return CAMERA_ERROR_SERVICE_DISCONNECTED;
511 g_mutex_lock(&(cb_info->api_mutex[api]));
513 if (cb_info->api_activating[api] == 0) {
514 if (time_out == CAMERA_CB_NO_TIMEOUT) {
515 LOGW("wait for api %d", api);
516 g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
517 ret = cb_info->api_ret[api];
518 cb_info->api_activating[api] = 0;
519 LOGW("api %d returned 0x%x", api, ret);
521 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
522 if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
523 ret = cb_info->api_ret[api];
524 cb_info->api_activating[api] = 0;
525 /*LOGD("return value : 0x%x", ret);*/
527 ret = CAMERA_ERROR_INVALID_OPERATION;
528 LOGE("api %d was TIMED OUT!", api);
532 ret = cb_info->api_ret[api];
533 cb_info->api_activating[api] = 0;
535 /*LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);*/
538 g_mutex_unlock(&(cb_info->api_mutex[api]));
540 if (ret != CAMERA_ERROR_NONE) {
541 LOGE("api %d : error 0x%x", api, ret);
543 if (ret == CAMERA_ERROR_SOUND_POLICY)
544 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
545 else if (ret == CAMERA_ERROR_SOUND_POLICY_BY_CALL)
546 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
547 else if (ret == CAMERA_ERROR_SOUND_POLICY_BY_ALARM)
548 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
555 static void _camera_msg_send(int api, camera_cb_info_s *cb_info,
556 int *ret, int timeout)
562 LOGE("NULL info - api %d", api);
565 *ret = CAMERA_ERROR_INVALID_PARAMETER;
570 msg = muse_core_msg_new(api, NULL);
572 LOGE("msg failed: api %d", api);
575 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
580 /*LOGD("send msg %s", msg);*/
582 if (cb_info->is_server_connected) {
583 __camera_update_api_waiting(cb_info, api, 1);
585 g_mutex_lock(&cb_info->fd_lock);
586 send_ret = muse_core_msg_send(cb_info->fd, msg);
587 g_mutex_unlock(&cb_info->fd_lock);
591 LOGE("msg send failed");
593 *ret = CAMERA_ERROR_INVALID_OPERATION;
596 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
599 __camera_update_api_waiting(cb_info, api, -1);
601 muse_core_msg_free(msg);
607 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
608 int *ret, camera_msg_param *param, int timeout)
613 if (!cb_info || !param) {
614 LOGE("invalid pointer : api %d - %p %p", api, cb_info, param);
617 *ret = CAMERA_ERROR_INVALID_PARAMETER;
622 /*LOGD("type %d, name %s", param->type, param->name);*/
624 switch (param->type) {
626 msg = muse_core_msg_new(api,
627 param->type, param->name, param->value.value_INT,
630 case MUSE_TYPE_STRING:
631 msg = muse_core_msg_new(api,
632 param->type, param->name, param->value.value_STRING,
636 LOGE("unknown type %d", param->type);
641 LOGE("msg failed: api %d", api);
644 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
649 /*LOGD("send msg %s", msg);*/
651 if (cb_info->is_server_connected) {
652 __camera_update_api_waiting(cb_info, api, 1);
654 g_mutex_lock(&cb_info->fd_lock);
655 send_ret = muse_core_msg_send(cb_info->fd, msg);
656 g_mutex_unlock(&cb_info->fd_lock);
660 LOGE("msg send failed");
663 *ret = CAMERA_ERROR_INVALID_OPERATION;
666 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
669 __camera_update_api_waiting(cb_info, api, -1);
671 muse_core_msg_free(msg);
677 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
679 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
680 in_format >= MM_PIXEL_FORMAT_NUM ||
681 out_format == NULL) {
682 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
683 return CAMERA_ERROR_INVALID_PARAMETER;
687 case MM_PIXEL_FORMAT_NV12:
688 case MM_PIXEL_FORMAT_NV12T:
689 *out_format = TBM_FORMAT_NV12;
691 case MM_PIXEL_FORMAT_NV16:
692 *out_format = TBM_FORMAT_NV16;
694 case MM_PIXEL_FORMAT_NV21:
695 *out_format = TBM_FORMAT_NV21;
697 case MM_PIXEL_FORMAT_YUYV:
698 *out_format = TBM_FORMAT_YUYV;
700 case MM_PIXEL_FORMAT_UYVY:
701 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
702 *out_format = TBM_FORMAT_UYVY;
704 case MM_PIXEL_FORMAT_422P:
705 *out_format = TBM_FORMAT_YUV422;
707 case MM_PIXEL_FORMAT_I420:
708 *out_format = TBM_FORMAT_YUV420;
710 case MM_PIXEL_FORMAT_YV12:
711 *out_format = TBM_FORMAT_YVU420;
713 case MM_PIXEL_FORMAT_RGB565:
714 *out_format = TBM_FORMAT_RGB565;
716 case MM_PIXEL_FORMAT_RGB888:
717 *out_format = TBM_FORMAT_RGB888;
719 case MM_PIXEL_FORMAT_RGBA:
720 *out_format = TBM_FORMAT_RGBA8888;
722 case MM_PIXEL_FORMAT_ARGB:
723 *out_format = TBM_FORMAT_ARGB8888;
726 LOGE("invalid in_format %d", in_format);
727 return CAMERA_ERROR_INVALID_PARAMETER;
730 return CAMERA_ERROR_NONE;
734 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
736 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
737 in_format >= MM_PIXEL_FORMAT_NUM ||
739 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
740 return CAMERA_ERROR_INVALID_PARAMETER;
744 case MM_PIXEL_FORMAT_NV12:
745 case MM_PIXEL_FORMAT_NV12T:
746 *mimetype = MEDIA_FORMAT_NV12;
748 case MM_PIXEL_FORMAT_NV16:
749 *mimetype = MEDIA_FORMAT_NV16;
751 case MM_PIXEL_FORMAT_NV21:
752 *mimetype = MEDIA_FORMAT_NV21;
754 case MM_PIXEL_FORMAT_YUYV:
755 *mimetype = MEDIA_FORMAT_YUYV;
757 case MM_PIXEL_FORMAT_UYVY:
758 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
759 *mimetype = MEDIA_FORMAT_UYVY;
761 case MM_PIXEL_FORMAT_422P:
762 *mimetype = MEDIA_FORMAT_422P;
764 case MM_PIXEL_FORMAT_I420:
765 *mimetype = MEDIA_FORMAT_I420;
767 case MM_PIXEL_FORMAT_YV12:
768 *mimetype = MEDIA_FORMAT_YV12;
770 case MM_PIXEL_FORMAT_RGB565:
771 *mimetype = MEDIA_FORMAT_RGB565;
773 case MM_PIXEL_FORMAT_RGB888:
774 *mimetype = MEDIA_FORMAT_RGB888;
776 case MM_PIXEL_FORMAT_RGBA:
777 *mimetype = MEDIA_FORMAT_RGBA;
779 case MM_PIXEL_FORMAT_ARGB:
780 *mimetype = MEDIA_FORMAT_ARGB;
783 LOGE("invalid in_format %d", in_format);
784 return CAMERA_ERROR_INVALID_PARAMETER;
787 return CAMERA_ERROR_NONE;
790 static void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_key,
791 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame)
794 unsigned char *buf_pos = NULL;
796 if (stream == NULL || buffer_bo_handle == NULL || frame == NULL) {
797 LOGE("invalid parameter - stream:%p, buffer_bo_handle:%p", stream, buffer_bo_handle);
802 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
803 frame->format = MM_PIXEL_FORMAT_UYVY;
805 frame->format = stream->format;
807 frame->width = stream->width;
808 frame->height = stream->height;
809 frame->timestamp = stream->timestamp;
810 frame->num_of_planes = stream->num_planes;
812 if (num_buffer_key == 0) {
814 if (!data_bo_handle || !data_bo_handle->ptr) {
815 LOGE("NULL pointer");
819 buf_pos = data_bo_handle->ptr;
821 if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) {
822 frame->data.encoded_plane.data = buf_pos;
823 frame->data.encoded_plane.size = stream->data.encoded.length_data;
824 total_size = stream->data.encoded.length_data;
826 switch (stream->num_planes) {
828 frame->data.single_plane.yuv = buf_pos;
829 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
830 total_size = stream->data.yuv420.length_yuv;
833 frame->data.double_plane.y = buf_pos;
834 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
835 buf_pos += stream->data.yuv420sp.length_y;
836 frame->data.double_plane.uv = buf_pos;
837 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
838 total_size = stream->data.yuv420sp.length_y + \
839 stream->data.yuv420sp.length_uv;
842 frame->data.triple_plane.y = buf_pos;
843 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
844 buf_pos += stream->data.yuv420p.length_y;
845 frame->data.triple_plane.u = buf_pos;
846 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
847 buf_pos += stream->data.yuv420p.length_u;
848 frame->data.triple_plane.v = buf_pos;
849 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
850 total_size = stream->data.yuv420p.length_y + \
851 stream->data.yuv420p.length_u + \
852 stream->data.yuv420p.length_v;
860 switch (stream->num_planes) {
862 frame->data.single_plane.yuv = buffer_bo_handle[0].ptr;
863 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
864 total_size = stream->data.yuv420.length_yuv;
867 frame->data.double_plane.y = buffer_bo_handle[0].ptr;
868 if (stream->num_planes == (unsigned int)num_buffer_key)
869 frame->data.double_plane.uv = buffer_bo_handle[1].ptr;
871 frame->data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
872 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
873 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
874 total_size = stream->data.yuv420sp.length_y + \
875 stream->data.yuv420sp.length_uv;
878 frame->data.triple_plane.y = buffer_bo_handle[0].ptr;
879 if (stream->num_planes == (unsigned int)num_buffer_key) {
880 frame->data.triple_plane.u = buffer_bo_handle[1].ptr;
881 frame->data.triple_plane.v = buffer_bo_handle[2].ptr;
883 frame->data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y;
884 frame->data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u;
886 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
887 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
888 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
889 total_size = stream->data.yuv420p.length_y + \
890 stream->data.yuv420p.length_u + \
891 stream->data.yuv420p.length_v;
899 LOGD("format %d, %dx%d, size %d plane num %d",
900 frame.format, frame.width, frame.height, total_size, frame.num_of_planes);
906 static int _camera_media_packet_data_create(int tbm_key, int num_buffer_key, tbm_bo bo,
907 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
910 int ret = CAMERA_ERROR_NONE;
911 camera_media_packet_data *tmp_mp_data = NULL;
913 if (*mp_data == NULL) {
914 tmp_mp_data = g_new0(camera_media_packet_data, 1);
916 tmp_mp_data->tbm_key = tbm_key;
917 tmp_mp_data->num_buffer_key = num_buffer_key;
918 tmp_mp_data->bo = bo;
919 tmp_mp_data->data_bo = data_bo;
920 tmp_mp_data->ref_cnt++;
922 for (i = 0 ; i < num_buffer_key ; i++)
923 tmp_mp_data->buffer_bo[i] = buffer_bo[i];
925 *mp_data = tmp_mp_data;
926 /*LOGD("mp_data %p", tmp_mp_data);*/
928 ret = CAMERA_ERROR_OUT_OF_MEMORY;
929 LOGE("failed to alloc media packet data");
932 ((camera_media_packet_data *)*mp_data)->ref_cnt++;
938 static void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
942 camera_msg_param param;
944 if (!mp_data || !cb_info) {
945 LOGE("NULL pointer %p %p", mp_data, cb_info);
949 if (mp_data->ref_cnt > 1) {
951 LOGD("ref count %d", mp_data->ref_cnt);
953 /* release imported bo */
954 for (i = 0 ; i < mp_data->num_buffer_key ; i++) {
955 tbm_bo_unref(mp_data->buffer_bo[i]);
956 mp_data->buffer_bo[i] = NULL;
960 _camera_release_imported_bo(&mp_data->bo);
961 _camera_release_imported_bo(&mp_data->data_bo);
964 tbm_key = mp_data->tbm_key;
966 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
968 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
977 static int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
978 camera_media_packet_data *mp_data, media_packet_h *packet)
980 media_packet_h pkt = NULL;
981 bool make_pkt_fmt = false;
982 tbm_surface_h tsurf = NULL;
983 tbm_surface_info_s tsurf_info;
984 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
985 uint32_t bo_format = 0;
988 int num_buffer_key = 0;
989 tbm_bo *buffer_bo = NULL;
991 if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) {
992 LOGE("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p",
993 cb_info, stream, mp_data, packet);
994 return CAMERA_ERROR_INVALID_PARAMETER;
997 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
998 buffer_bo = mp_data->buffer_bo;
999 num_buffer_key = mp_data->num_buffer_key;
1001 /* create tbm surface */
1002 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
1003 tsurf_info.planes[i].stride = stream->stride[i];
1005 /* get tbm surface format */
1006 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
1007 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
1009 if (ret == CAMERA_ERROR_NONE) {
1010 tsurf_info.width = stream->width;
1011 tsurf_info.height = stream->height;
1012 tsurf_info.format = bo_format;
1013 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
1014 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
1016 if (num_buffer_key > 0) {
1017 switch (bo_format) {
1018 case TBM_FORMAT_NV12:
1019 case TBM_FORMAT_NV21:
1020 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1021 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1022 tsurf_info.planes[0].offset = 0;
1023 if (num_buffer_key == 1)
1024 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1025 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1027 case TBM_FORMAT_YUV420:
1028 case TBM_FORMAT_YVU420:
1029 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1030 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1031 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
1032 tsurf_info.planes[0].offset = 0;
1033 if (num_buffer_key == 1) {
1034 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1035 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1037 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1039 case TBM_FORMAT_UYVY:
1040 case TBM_FORMAT_YUYV:
1041 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
1042 tsurf_info.planes[0].offset = 0;
1043 tsurf_info.size = tsurf_info.planes[0].size;
1049 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_key);
1050 } else if (mp_data->data_bo) {
1051 switch (bo_format) {
1052 case TBM_FORMAT_NV12:
1053 case TBM_FORMAT_NV21:
1054 tsurf_info.planes[0].size = stream->width * stream->height;
1055 tsurf_info.planes[1].size = (tsurf_info.planes[0].size) >> 1;
1056 tsurf_info.planes[0].offset = 0;
1057 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1058 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1060 case TBM_FORMAT_YUV420:
1061 case TBM_FORMAT_YVU420:
1062 tsurf_info.planes[0].size = stream->width * stream->height;
1063 tsurf_info.planes[1].size = (stream->width >> 1) * (stream->height >> 1);
1064 tsurf_info.planes[2].size = tsurf_info.planes[1].size;
1065 tsurf_info.planes[0].offset = 0;
1066 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1067 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1068 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1070 case TBM_FORMAT_UYVY:
1071 case TBM_FORMAT_YUYV:
1072 tsurf_info.planes[0].size = (stream->width * stream->height) << 1;
1073 tsurf_info.planes[0].offset = 0;
1074 tsurf_info.size = tsurf_info.planes[0].size;
1080 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1);
1082 /*LOGD("tbm surface %p", tsurf);*/
1086 /* check media packet format */
1087 if (cb_info->pkt_fmt) {
1088 int pkt_fmt_width = 0;
1089 int pkt_fmt_height = 0;
1090 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
1092 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
1093 if (pkt_fmt_mimetype != mimetype ||
1094 pkt_fmt_width != stream->width ||
1095 pkt_fmt_height != stream->height) {
1096 LOGW("change fmt: current 0x%x, %dx%d",
1097 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
1098 media_format_unref(cb_info->pkt_fmt);
1099 cb_info->pkt_fmt = NULL;
1100 make_pkt_fmt = true;
1103 make_pkt_fmt = true;
1106 /* create packet format */
1108 LOGW("make new pkt_fmt - 0x%x, %dx%d", mimetype, stream->width, stream->height);
1109 ret = media_format_create(&cb_info->pkt_fmt);
1110 if (ret == MEDIA_FORMAT_ERROR_NONE) {
1111 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
1112 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
1113 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
1114 LOGW("media_format_set : 0x%x", ret);
1116 LOGW("media_format_create failed 0x%x", ret);
1120 /* create media packet */
1121 ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt,
1122 tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
1123 (void *)cb_info, &pkt);
1124 if (ret != MEDIA_PACKET_ERROR_NONE) {
1125 LOGE("media_packet_create failed 0x%x", ret);
1126 tbm_surface_destroy(tsurf);
1130 LOGE("tbm surface failed. %dx%d, format %d, num_buffer_key %d, data_bo %p",
1131 stream->width, stream->height, stream->format, num_buffer_key, mp_data->data_bo);
1135 /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
1136 /* set media packet data */
1137 ret = media_packet_set_extra(pkt, (void *)mp_data);
1138 if (ret != MEDIA_PACKET_ERROR_NONE) {
1139 LOGE("media_packet_set_extra failed");
1141 _camera_media_packet_data_release(mp_data, cb_info);
1144 media_packet_destroy(pkt);
1147 /* set timestamp : msec -> nsec */
1148 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
1149 LOGW("media_packet_set_pts failed");
1158 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
1161 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1162 camera_media_packet_data *mp_data = NULL;
1163 tbm_surface_h tsurf = NULL;
1165 if (!pkt || !cb_info) {
1166 LOGE("NULL pointer %p %p", pkt, cb_info);
1167 return MEDIA_PACKET_FINALIZE;
1170 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1171 if (ret != MEDIA_PACKET_ERROR_NONE) {
1172 LOGE("media_packet_get_extra failed 0x%x", ret);
1173 return MEDIA_PACKET_FINALIZE;
1176 /*LOGD("mp_data %p", mp_data);*/
1178 g_mutex_lock(&cb_info->mp_data_mutex);
1180 _camera_media_packet_data_release(mp_data, cb_info);
1183 g_mutex_unlock(&cb_info->mp_data_mutex);
1185 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1186 if (ret != MEDIA_PACKET_ERROR_NONE)
1187 LOGE("get tbm_surface failed 0x%x", ret);
1190 tbm_surface_destroy(tsurf);
1194 return MEDIA_PACKET_FINALIZE;
1197 static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event)
1202 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1203 LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event);
1207 /*LOGD("get camera msg %s, event %d", recv_msg, event);*/
1209 g_mutex_lock(&cb_info->user_cb_mutex[event]);
1211 if (cb_info->user_cb[event] == NULL) {
1212 if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
1213 event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
1214 event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
1215 event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1216 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1217 LOGW("NULL callback for event %d, return here", event);
1221 /* return buffer message should be sent for some events.
1222 - MUSE_CAMERA_EVENT_TYPE_PREVIEW
1223 - MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW
1224 - MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION
1225 - MUSE_CAMERA_EVENT_TYPE_CAPTURE
1230 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1236 muse_camera_msg_get(previous, recv_msg);
1237 muse_camera_msg_get(current, recv_msg);
1238 muse_camera_msg_get(by_policy, recv_msg);
1240 LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
1241 previous, current, by_policy);
1243 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1244 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1247 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1251 muse_camera_msg_get(state, recv_msg);
1253 LOGD("FOCUS state - %d", state);
1255 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1258 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1259 LOGD("CAPTURE_COMPLETED");
1260 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1262 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1263 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1264 __camera_event_handler_preview(cb_info, recv_msg);
1266 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1270 muse_camera_msg_get(percent, recv_msg);
1272 LOGD("HDR progress - %d %%", percent);
1274 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1277 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1283 muse_camera_msg_get(policy, recv_msg);
1284 muse_camera_msg_get(previous, recv_msg);
1285 muse_camera_msg_get(current, recv_msg);
1287 LOGW("INTERRUPTED - policy %d, state previous %d, current %d",
1288 policy, previous, current);
1290 if (policy == CAMERA_POLICY_SOUND)
1291 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND is deprecated and will be removed from next release.");
1292 else if (policy == CAMERA_POLICY_SOUND_BY_CALL)
1293 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_CALL is deprecated and will be removed from next release.");
1294 else if (policy == CAMERA_POLICY_SOUND_BY_ALARM)
1295 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_ALARM is deprecated and will be removed from next release.");
1297 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1298 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1301 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1306 muse_camera_msg_get(policy, recv_msg);
1307 muse_camera_msg_get(state, recv_msg);
1309 LOGW("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1311 if (policy == CAMERA_POLICY_SOUND)
1312 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND is deprecated and will be removed from next release.");
1313 else if (policy == CAMERA_POLICY_SOUND_BY_CALL)
1314 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_CALL is deprecated and will be removed from next release.");
1315 else if (policy == CAMERA_POLICY_SOUND_BY_ALARM)
1316 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_ALARM is deprecated and will be removed from next release.");
1318 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1319 (camera_state_e)state, cb_info->user_data[event]);
1322 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1323 __camera_event_handler_face_detection(cb_info, recv_msg);
1325 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1328 int current_state = 0;
1330 muse_camera_msg_get(error, recv_msg);
1331 muse_camera_msg_get(current_state, recv_msg);
1333 LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
1335 if (error == CAMERA_ERROR_SOUND_POLICY)
1336 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
1337 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_CALL)
1338 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
1339 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_ALARM)
1340 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
1342 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1343 (camera_state_e)current_state, cb_info->user_data[event]);
1346 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1348 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1349 muse_camera_msg_get(param1, recv_msg);
1350 muse_camera_msg_get(param2, recv_msg);
1352 /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/
1354 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1355 cb_info->user_cb[event] = NULL;
1356 cb_info->user_data[event] = NULL;
1357 LOGW("stop foreach callback for event %d", event);
1360 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1362 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1364 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1366 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1368 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1370 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1372 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1374 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1376 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1378 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1380 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1382 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1384 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1386 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1388 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1389 muse_camera_msg_get(param1, recv_msg);
1391 /*LOGD("event %d SUPPORTED %d ", event, param1);*/
1393 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1394 cb_info->user_cb[event] = NULL;
1395 cb_info->user_data[event] = NULL;
1396 LOGW("stop foreach callback for event %d", event);
1399 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1400 __camera_event_handler_capture(cb_info, recv_msg);
1403 LOGW("unhandled event %d", event);
1407 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1412 static bool _camera_idle_event_callback(void *data)
1414 camera_cb_info_s *cb_info = NULL;
1415 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1417 if (cam_idle_event == NULL) {
1418 LOGE("cam_idle_event is NULL");
1423 g_mutex_lock(&cam_idle_event->event_mutex);
1425 cb_info = cam_idle_event->cb_info;
1426 if (cb_info == NULL) {
1427 LOGW("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1428 goto IDLE_EVENT_CALLBACK_DONE;
1431 /* remove event from list */
1432 g_mutex_lock(&cb_info->idle_event_mutex);
1434 if (cb_info->idle_event_list)
1435 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1437 /*LOGD("remove camera idle event %p, %p", cam_idle_event, cb_info->idle_event_list);*/
1438 g_mutex_unlock(&cb_info->idle_event_mutex);
1441 _camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
1443 /* send signal for waiting thread */
1444 g_cond_signal(&cb_info->idle_event_cond);
1446 IDLE_EVENT_CALLBACK_DONE:
1447 /* unlock and release event */
1448 g_mutex_unlock(&cam_idle_event->event_mutex);
1449 g_mutex_clear(&cam_idle_event->event_mutex);
1451 g_free(cam_idle_event);
1452 cam_idle_event = NULL;
1457 static void *_camera_msg_handler_func(gpointer data)
1461 camera_message_s *cam_msg = NULL;
1462 camera_idle_event_s *cam_idle_event = NULL;
1463 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1464 camera_cb_info_s *cb_info = NULL;
1466 if (!handler_info || !handler_info->cb_info) {
1467 LOGE("NULL handler %p", handler_info);
1471 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1472 type = handler_info->type;
1474 LOGD("t:%d start", type);
1476 g_mutex_lock(&handler_info->mutex);
1478 while (g_atomic_int_get(&handler_info->running)) {
1479 if (g_queue_is_empty(handler_info->queue)) {
1480 /*LOGD("t:%d signal wait...", type);*/
1481 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1482 /*LOGD("t:%d signal received", type);*/
1484 if (g_atomic_int_get(&handler_info->running) == 0) {
1485 LOGD("t:%d stop event thread", type);
1490 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1492 g_mutex_unlock(&handler_info->mutex);
1494 if (cam_msg == NULL) {
1495 LOGE("t:%d NULL message", type);
1496 g_mutex_lock(&handler_info->mutex);
1502 if (api < MUSE_CAMERA_API_MAX) {
1505 g_mutex_lock(&cb_info->api_mutex[api]);
1507 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1508 if (cb_info->api_waiting[api] > 0) {
1509 cb_info->api_ret[api] = ret;
1510 cb_info->api_activating[api] = 1;
1512 /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
1514 g_cond_signal(&cb_info->api_cond[api]);
1516 LOGW("no waiting for this api [%d]", api);
1519 LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1522 g_mutex_unlock(&cb_info->api_mutex[api]);
1523 } else if (api == MUSE_CAMERA_CB_EVENT) {
1524 switch (cam_msg->event_class) {
1525 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1526 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event);
1528 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1529 cam_idle_event = g_new0(camera_idle_event_s, 1);
1530 if (cam_idle_event == NULL) {
1531 LOGE("t:%d cam_idle_event alloc failed", type);
1535 cam_idle_event->event = cam_msg->event;
1536 cam_idle_event->cb_info = cb_info;
1537 g_mutex_init(&cam_idle_event->event_mutex);
1538 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg) - 1);
1540 /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, cam_msg->event, cam_idle_event);*/
1542 g_mutex_lock(&cb_info->idle_event_mutex);
1543 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1544 g_mutex_unlock(&cb_info->idle_event_mutex);
1546 g_idle_add_full(G_PRIORITY_DEFAULT,
1547 (GSourceFunc)_camera_idle_event_callback,
1548 (gpointer)cam_idle_event,
1552 LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
1556 LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1562 g_mutex_lock(&handler_info->mutex);
1565 /* remove remained event */
1566 while (!g_queue_is_empty(handler_info->queue)) {
1567 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1569 LOGD("t:%d remove camera message %p", type, cam_msg);
1573 LOGW("t:%d NULL camera message", type);
1577 g_mutex_unlock(&handler_info->mutex);
1579 LOGD("t:%d return", type);
1585 static void _camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1587 camera_idle_event_s *cam_idle_event = NULL;
1589 gint64 end_time = 0;
1591 if (cb_info == NULL) {
1592 LOGE("cb_info is NULL");
1596 g_mutex_lock(&cb_info->idle_event_mutex);
1598 if (cb_info->idle_event_list == NULL) {
1599 LOGD("No remained idle event");
1600 g_mutex_unlock(&cb_info->idle_event_mutex);
1604 list = cb_info->idle_event_list;
1607 cam_idle_event = list->data;
1608 list = g_list_next(list);
1610 if (!cam_idle_event) {
1611 LOGW("Fail to remove idle event. The event is NULL");
1615 if (g_idle_remove_by_data(cam_idle_event)) {
1616 LOGW("remove idle event %p done", cam_idle_event);
1618 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1620 g_mutex_clear(&cam_idle_event->event_mutex);
1621 g_free(cam_idle_event);
1622 cam_idle_event = NULL;
1627 LOGW("remove idle event %p failed", cam_idle_event);
1629 if (!g_mutex_trylock(&cam_idle_event->event_mutex)) {
1630 LOGW("lock failed, %p event is calling now", cam_idle_event);
1632 end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
1634 if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
1635 LOGW("signal received");
1642 LOGW("set NULL cb_info for event %p %d, it will be freed on idle callback",
1643 cam_idle_event, cam_idle_event->event);
1645 cam_idle_event->cb_info = NULL;
1647 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1649 g_mutex_unlock(&cam_idle_event->event_mutex);
1652 g_list_free(cb_info->idle_event_list);
1653 cb_info->idle_event_list = NULL;
1655 g_mutex_unlock(&cb_info->idle_event_mutex);
1661 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg)
1663 camera_message_s *cam_msg = NULL;
1665 if (!cb_info || !msg) {
1666 LOGE("NULL pointer %p %p", cb_info, msg);
1670 cam_msg = g_new0(camera_message_s, 1);
1672 LOGE("failed to alloc cam_msg for [%s]", msg);
1677 cam_msg->event = event;
1678 cam_msg->event_class = event_class;
1680 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1682 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1684 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1685 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1686 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1687 g_cond_signal(&cb_info->preview_cb_info.cond);
1688 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1689 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1690 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1691 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1692 g_cond_signal(&cb_info->capture_cb_info.cond);
1693 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1695 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1696 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1697 g_cond_signal(&cb_info->msg_handler_info.cond);
1698 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1707 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg)
1709 int ret = CAMERA_ERROR_NONE;
1713 int event_class = -1;
1717 if (!cb_info || !msg) {
1718 LOGE("invalid ptr %p %p", cb_info, msg);
1722 /*LOGD("msg [%s]", msg);*/
1724 if (!muse_camera_msg_get(api, msg)) {
1725 LOGE("failed to get camera api");
1729 if (api == MUSE_CAMERA_CB_EVENT) {
1730 if (!muse_camera_msg_get(event, msg) ||
1731 !muse_camera_msg_get(event_class, msg)) {
1732 LOGE("failed to get camera event or event_class [%s]", msg);
1736 if (!muse_camera_msg_get(api_class, msg)) {
1737 LOGE("failed to get camera api_class [%s]", msg);
1742 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1743 if (api >= MUSE_CAMERA_API_MAX) {
1744 LOGE("invalid api %d", api);
1748 if (!muse_camera_msg_get(ret, msg)) {
1749 LOGE("failed to get camera ret");
1753 g_mutex_lock(&cb_info->api_mutex[api]);
1756 case MUSE_CAMERA_API_CREATE:
1757 if (ret != CAMERA_ERROR_NONE) {
1758 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1759 LOGE("camera create error 0x%x. close client cb handler", ret);
1762 case MUSE_CAMERA_API_DESTROY:
1763 if (ret == CAMERA_ERROR_NONE) {
1764 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1765 LOGD("camera destroy done. close client cb handler");
1769 muse_camera_msg_get(get_type, msg);
1770 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1771 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1772 muse_camera_msg_get(get_index, msg);
1775 case MUSE_CAMERA_GET_TYPE_INT:
1776 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
1778 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1779 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
1780 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
1782 case MUSE_CAMERA_GET_TYPE_ARRAY:
1783 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
1784 muse_core_msg_deserialize("get_value",
1785 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
1786 LOGD("get display roi %d,%d,%dx%d",
1787 cb_info->get_display_roi_area[0],
1788 cb_info->get_display_roi_area[1],
1789 cb_info->get_display_roi_area[2],
1790 cb_info->get_display_roi_area[3]);
1792 muse_core_msg_deserialize("get_value",
1793 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
1794 LOGD("get geotag %lf, %lf, %lf",
1795 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
1798 case MUSE_CAMERA_GET_TYPE_STRING:
1799 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
1802 LOGW("unknown type %d", get_type);
1809 if (cb_info->api_waiting[api] > 0) {
1810 cb_info->api_ret[api] = ret;
1811 cb_info->api_activating[api] = 1;
1813 g_cond_signal(&cb_info->api_cond[api]);
1815 LOGW("no waiting for this api [%d]", api);
1818 g_mutex_unlock(&cb_info->api_mutex[api]);
1819 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
1820 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg);
1822 LOGW("unknown camera api %d, class %d", api, api_class);
1829 static void *_camera_msg_recv_func(gpointer data)
1831 int recv_length = 0;
1832 int single_length = 0;
1833 int remained_length = 0;
1834 char *recv_msg = NULL;
1835 char *single_msg = NULL;
1836 char *remained_msg = NULL;
1840 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
1843 LOGE("cb_info NULL");
1847 LOGD("start - fd : %d", cb_info->fd);
1849 single_msg = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
1851 LOGE("single_msg malloc failed");
1855 recv_msg = cb_info->recv_msg;
1857 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
1858 recv_length = muse_core_msg_recv(cb_info->fd, recv_msg);
1859 if (recv_length <= 0) {
1860 cb_info->is_server_connected = FALSE;
1861 LOGE("receive msg failed - server disconnected");
1869 /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
1871 /* Need to split the combined entering msgs */
1872 for (cur_pos = 0 ; cur_pos < recv_length ; cur_pos++) {
1873 if (recv_msg[cur_pos] == '}') {
1874 single_length = cur_pos - prev_pos + 1;
1876 if (single_length < MUSE_CAMERA_MSG_MAX_LENGTH) {
1877 /* check remained msg */
1878 if (remained_length > 0) {
1880 strncpy(single_msg, remained_msg, remained_length);
1881 strncpy(single_msg + remained_length, recv_msg + prev_pos, single_length);
1882 single_msg[remained_length + single_length] = '\0';
1885 remained_msg = NULL;
1887 strncpy(single_msg, recv_msg + prev_pos, single_length);
1888 single_msg[single_length] = '\0';
1889 LOGE("lost msg [%s], skip...", single_msg);
1892 remained_length = 0;
1894 strncpy(single_msg, recv_msg + prev_pos, single_length);
1895 single_msg[single_length] = '\0';
1898 if (single_msg[0] == '{') {
1900 /*LOGD("splitted msg : [%s], Index : %d", single_msg, num_msg);*/
1901 /* process each message */
1902 __camera_process_msg(cb_info, single_msg);
1904 LOGE("invalid msg [%s]", single_msg);
1907 LOGE("too long message [len %d] skip...", single_length);
1910 prev_pos = cur_pos + 1;
1914 /* check incompleted message */
1915 if (recv_msg[recv_length - 1] != '}') {
1916 remained_length = recv_length - prev_pos;
1918 LOGW("incompleted message [len %d]", remained_length);
1922 remained_msg = NULL;
1925 remained_msg = (char *)malloc(remained_length + 1);
1927 strncpy(remained_msg, recv_msg + prev_pos, remained_length);
1928 remained_msg[remained_length] = '\0';
1930 LOGE("failed to alloc for remained msg");
1933 remained_length = 0;
1937 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
1939 if (!cb_info->is_server_connected) {
1940 char *error_msg = NULL;
1942 if (cb_info->fd < 0) {
1943 LOGE("fd is closed in client side");
1944 goto CB_HANDLER_EXIT;
1947 /* send error msg for server disconnection */
1948 error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
1949 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
1950 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
1954 LOGE("error_msg failed");
1955 goto CB_HANDLER_EXIT;
1958 __camera_add_msg_to_queue(cb_info,
1959 MUSE_CAMERA_CB_EVENT,
1960 MUSE_CAMERA_EVENT_TYPE_ERROR,
1961 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
1964 muse_core_msg_free(error_msg);
1967 LOGE("add error msg for service disconnection done");
1978 remained_msg = NULL;
1985 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
1986 int type, const char *thread_name, camera_cb_info_s *cb_info)
1988 if (!handler_info || !thread_name || !cb_info) {
1989 LOGE("t:%d NULL %p %p %p",
1990 type, handler_info, thread_name, cb_info);
1996 handler_info->type = type;
1997 handler_info->queue = g_queue_new();
1998 if (handler_info->queue == NULL) {
1999 LOGE("t:%d queue failed", type);
2003 g_mutex_init(&handler_info->mutex);
2004 g_cond_init(&handler_info->cond);
2006 handler_info->cb_info = (void *)cb_info;
2007 g_atomic_int_set(&handler_info->running, 1);
2009 handler_info->thread = g_thread_try_new(thread_name,
2010 _camera_msg_handler_func, (gpointer)handler_info, NULL);
2011 if (handler_info->thread == NULL) {
2012 LOGE("t:%d thread failed", type);
2014 g_mutex_clear(&handler_info->mutex);
2015 g_cond_clear(&handler_info->cond);
2016 g_queue_free(handler_info->queue);
2017 handler_info->queue = NULL;
2022 LOGD("t:%d done", type);
2028 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2032 if (!handler_info) {
2033 LOGE("NULL handler");
2037 if (!handler_info->thread) {
2038 LOGW("thread is not created");
2042 type = handler_info->type;
2044 LOGD("t:%d thread %p", type, handler_info->thread);
2046 g_mutex_lock(&handler_info->mutex);
2047 g_atomic_int_set(&handler_info->running, 0);
2048 g_cond_signal(&handler_info->cond);
2049 g_mutex_unlock(&handler_info->mutex);
2051 g_thread_join(handler_info->thread);
2052 handler_info->thread = NULL;
2054 g_mutex_clear(&handler_info->mutex);
2055 g_cond_clear(&handler_info->cond);
2056 g_queue_free(handler_info->queue);
2057 handler_info->queue = NULL;
2059 LOGD("t:%d done", type);
2065 static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
2067 camera_cb_info_s *cb_info = NULL;
2070 g_return_val_if_fail(sockfd > 0, NULL);
2072 cb_info = g_new0(camera_cb_info_s, 1);
2073 if (cb_info == NULL) {
2074 LOGE("cb_info failed");
2078 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2080 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2081 g_mutex_init(&cb_info->api_mutex[i]);
2082 g_cond_init(&cb_info->api_cond[i]);
2085 g_mutex_init(&cb_info->fd_lock);
2086 g_mutex_init(&cb_info->idle_event_mutex);
2087 g_cond_init(&cb_info->idle_event_cond);
2088 g_mutex_init(&cb_info->mp_data_mutex);
2090 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2091 g_mutex_init(&cb_info->user_cb_mutex[i]);
2093 /* message handler thread */
2094 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2095 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2096 LOGE("msg_handler_info failed");
2100 /* message handler thread for preview callback */
2101 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2102 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2103 LOGE("preview_cb_info failed");
2107 /* message handler thread for capture callback */
2108 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2109 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2110 LOGE("capture_cb_info failed");
2114 cb_info->fd = sockfd;
2115 cb_info->preview_cb_flag = 0;
2117 /* message receive thread */
2118 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2119 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2120 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2121 if (cb_info->msg_recv_thread == NULL) {
2122 LOGE("message receive thread creation failed");
2126 cb_info->is_server_connected = TRUE;
2132 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2133 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2134 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2136 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2137 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2139 g_mutex_clear(&cb_info->fd_lock);
2140 g_mutex_clear(&cb_info->idle_event_mutex);
2141 g_cond_clear(&cb_info->idle_event_cond);
2142 g_mutex_clear(&cb_info->mp_data_mutex);
2144 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2145 g_mutex_clear(&cb_info->api_mutex[i]);
2146 g_cond_clear(&cb_info->api_cond[i]);
2156 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2160 g_return_if_fail(cb_info != NULL);
2162 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2164 g_thread_join(cb_info->msg_recv_thread);
2165 cb_info->msg_recv_thread = NULL;
2167 LOGD("msg_recv thread removed");
2169 /* destroy msg handler threads */
2170 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2171 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2172 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2174 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2175 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2177 g_mutex_clear(&cb_info->fd_lock);
2178 g_mutex_clear(&cb_info->idle_event_mutex);
2179 g_cond_clear(&cb_info->idle_event_cond);
2180 g_mutex_clear(&cb_info->mp_data_mutex);
2182 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2183 g_mutex_clear(&cb_info->api_mutex[i]);
2184 g_cond_clear(&cb_info->api_cond[i]);
2187 if (cb_info->fd > -1) {
2188 muse_client_close(cb_info->fd);
2192 if (cb_info->bufmgr) {
2193 tbm_bufmgr_deinit(cb_info->bufmgr);
2194 cb_info->bufmgr = NULL;
2196 if (cb_info->pkt_fmt) {
2197 media_format_unref(cb_info->pkt_fmt);
2198 cb_info->pkt_fmt = NULL;
2201 if (cb_info->dp_interface) {
2202 mm_display_interface_deinit(cb_info->dp_interface);
2203 cb_info->dp_interface = NULL;
2206 cb_info->preview_cb_flag = 0;
2215 int _camera_start_evas_rendering(camera_h camera)
2217 camera_cli_s *pc = (camera_cli_s *)camera;
2219 if (!pc || !pc->cb_info) {
2220 LOGE("NULL handle");
2221 return CAMERA_ERROR_INVALID_PARAMETER;
2226 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2227 LOGE("EVAS surface is not set");
2228 return CAMERA_ERROR_NONE;
2231 /* set evas render flag as RUN */
2232 pc->cb_info->run_evas_render = true;
2234 return CAMERA_ERROR_NONE;
2238 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2240 int ret = CAMERA_ERROR_NONE;
2241 camera_cli_s *pc = (camera_cli_s *)camera;
2243 if (!pc || !pc->cb_info) {
2244 LOGE("NULL handle");
2245 return CAMERA_ERROR_INVALID_PARAMETER;
2248 LOGD("stop - keep screen %d", keep_screen);
2250 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2251 LOGE("EVAS surface is not set");
2252 return CAMERA_ERROR_NONE;
2255 /* set evas render flag as STOP and release buffers */
2256 pc->cb_info->run_evas_render = false;
2258 ret = mm_display_interface_evas_flush(pc->cb_info->dp_interface, keep_screen);
2259 if (ret == MM_ERROR_NONE) {
2260 ret = CAMERA_ERROR_NONE;
2262 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2263 ret = CAMERA_ERROR_INVALID_OPERATION;
2270 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2272 int ret = CAMERA_ERROR_NONE;
2275 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2277 /* create muse connection */
2278 if (!key || !value) {
2279 LOGE("NULL pointer");
2280 return CAMERA_ERROR_INVALID_PARAMETER;
2283 sock_fd = muse_client_new();
2285 LOGE("muse_client_new failed");
2286 return CAMERA_ERROR_INVALID_OPERATION;
2289 msg = muse_core_msg_new(api,
2290 MUSE_TYPE_INT, "module", MUSE_CAMERA,
2291 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2295 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2299 ret = muse_core_msg_send(sock_fd, msg);
2301 muse_core_msg_free(msg);
2305 LOGE("send msg failed");
2306 ret = CAMERA_ERROR_INVALID_OPERATION;
2310 ret = muse_core_msg_recv(sock_fd, recv_msg);
2312 LOGE("recv msg failed %d", errno);
2313 ret = CAMERA_ERROR_INVALID_OPERATION;
2317 if (!muse_camera_msg_get(ret, recv_msg)) {
2318 LOGE("failed to get return value from msg [%s]", recv_msg);
2319 ret = CAMERA_ERROR_INVALID_OPERATION;
2323 if (ret == CAMERA_ERROR_NONE)
2324 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2326 LOGD("api %d - value %d", api, *value);
2330 muse_client_close(sock_fd);
2338 int camera_create(camera_device_e device, camera_h *camera)
2341 char *send_msg = NULL;
2343 int ret = CAMERA_ERROR_NONE;
2345 camera_cli_s *pc = NULL;
2346 tbm_bufmgr bufmgr = NULL;
2348 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2349 muse_core_api_module_e muse_module = MUSE_CAMERA;
2350 int device_type = (int)device;
2353 LOGE("NULL pointer");
2354 return CAMERA_ERROR_INVALID_PARAMETER;
2357 sock_fd = muse_client_new();
2359 LOGE("muse_client_new failed - returned fd %d", sock_fd);
2360 ret = CAMERA_ERROR_INVALID_OPERATION;
2366 send_msg = muse_core_msg_new(api,
2367 MUSE_TYPE_INT, "module", muse_module,
2368 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2369 MUSE_TYPE_INT, "pid", pid,
2374 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2378 send_ret = muse_core_msg_send(sock_fd, send_msg);
2380 muse_core_msg_free(send_msg);
2384 LOGE("send msg failed %d", errno);
2385 ret = CAMERA_ERROR_INVALID_OPERATION;
2389 pc = g_new0(camera_cli_s, 1);
2391 LOGE("camera_cli_s alloc failed");
2392 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2396 bufmgr = tbm_bufmgr_init(-1);
2397 if (bufmgr == NULL) {
2398 LOGE("get tbm bufmgr failed");
2399 ret = CAMERA_ERROR_INVALID_OPERATION;
2403 pc->cb_info = _camera_client_callback_new(sock_fd);
2404 if (pc->cb_info == NULL) {
2405 LOGE("cb_info alloc failed");
2406 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2412 LOGD("cb info : %d", pc->cb_info->fd);
2414 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2416 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2418 if (ret == CAMERA_ERROR_NONE) {
2419 intptr_t handle = 0;
2420 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2422 LOGE("Receiving Handle Failed!!");
2423 ret = CAMERA_ERROR_INVALID_OPERATION;
2427 pc->remote_handle = handle;
2428 pc->cb_info->bufmgr = bufmgr;
2430 ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL);
2431 if (ret != CAMERA_ERROR_NONE) {
2432 LOGE("init display failed 0x%x", ret);
2436 LOGD("camera create 0x%x", pc->remote_handle);
2437 *camera = (camera_h)pc;
2446 tbm_bufmgr_deinit(bufmgr);
2451 muse_client_close(sock_fd);
2457 int temp_fd = pc->cb_info->fd;
2459 /* pc->cb_info->fd should be closed,
2460 because g_thread_join for msg_recv_thread is not returned
2461 in _camera_client_callback_destroy. */
2463 pc->cb_info->fd = -1;
2464 muse_client_close(temp_fd);
2467 _camera_client_callback_destroy(pc->cb_info);
2474 LOGE("camera create error : 0x%x", ret);
2480 int camera_change_device(camera_h camera, camera_device_e device)
2483 int ret = CAMERA_ERROR_NONE;
2484 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2485 camera_cli_s *pc = (camera_cli_s *)camera;
2486 camera_msg_param param;
2488 if (!pc || !pc->cb_info) {
2489 LOGE("NULL handle");
2490 return CAMERA_ERROR_INVALID_PARAMETER;
2493 CAMERA_MSG_PARAM_SET(param, INT, device);
2495 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2497 if (ret == CAMERA_ERROR_NONE) {
2498 /* reset callback and user data */
2499 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2500 pc->cb_info->user_cb[i] = NULL;
2501 pc->cb_info->user_data[i] = NULL;
2503 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
2510 int camera_destroy(camera_h camera)
2512 int ret = CAMERA_ERROR_NONE;
2513 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2514 camera_cli_s *pc = (camera_cli_s *)camera;
2516 if (!pc || !pc->cb_info) {
2517 LOGE("NULL handle");
2518 return CAMERA_ERROR_INVALID_PARAMETER;
2523 if (pc->cb_info->is_server_connected)
2524 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2526 LOGW("server disconnected. release resource without send message.");
2528 if (ret == CAMERA_ERROR_NONE) {
2529 _camera_deactivate_idle_event_all(pc->cb_info);
2530 _camera_client_callback_destroy(pc->cb_info);
2537 LOGD("ret : 0x%x", ret);
2542 int camera_start_preview(camera_h camera)
2544 int ret = CAMERA_ERROR_NONE;
2545 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2546 camera_cli_s *pc = (camera_cli_s *)camera;
2548 if (!pc || !pc->cb_info) {
2549 LOGE("NULL handle");
2550 return CAMERA_ERROR_INVALID_PARAMETER;
2555 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2556 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2557 ret = _camera_start_evas_rendering(camera);
2558 if (ret != CAMERA_ERROR_NONE) {
2559 LOGE("stop preview because of error");
2560 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, pc->cb_info, NULL, 0);
2564 LOGD("ret : 0x%x", ret);
2570 int camera_stop_preview(camera_h camera)
2572 int ret = CAMERA_ERROR_NONE;
2573 camera_cli_s *pc = (camera_cli_s *)camera;
2574 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2575 camera_state_e current_state = CAMERA_STATE_NONE;
2577 if (!pc || !pc->cb_info) {
2578 LOGE("NULL handle");
2579 return CAMERA_ERROR_INVALID_PARAMETER;
2584 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2585 ret = camera_get_state(camera, ¤t_state);
2586 if (ret != CAMERA_ERROR_NONE) {
2587 LOGE("failed to get current state 0x%x", ret);
2591 if (current_state == CAMERA_STATE_PREVIEW) {
2592 ret = _camera_stop_evas_rendering(camera, false);
2593 if (ret != CAMERA_ERROR_NONE)
2598 /* send stop preview message */
2599 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2601 if (ret != CAMERA_ERROR_NONE &&
2602 current_state == CAMERA_STATE_PREVIEW) {
2603 LOGW("restart evas rendering");
2604 _camera_start_evas_rendering(camera);
2607 LOGD("ret : 0x%x", ret);
2613 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2615 int ret = CAMERA_ERROR_NONE;
2616 camera_cli_s *pc = (camera_cli_s *)camera;
2617 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2619 if (!pc || !pc->cb_info) {
2620 LOGE("NULL handle");
2621 return CAMERA_ERROR_INVALID_PARAMETER;
2626 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2627 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2629 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2630 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2632 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2634 LOGD("ret : 0x%x", ret);
2640 bool camera_is_supported_continuous_capture(camera_h camera)
2642 int ret = CAMERA_ERROR_NONE;
2643 camera_cli_s *pc = (camera_cli_s *)camera;
2644 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2646 if (!pc || !pc->cb_info) {
2647 LOGE("NULL handle");
2648 return CAMERA_ERROR_INVALID_PARAMETER;
2653 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2656 LOGE("error is occurred 0x%x", ret);
2660 LOGD("ret : %d", ret);
2666 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)
2668 int ret = CAMERA_ERROR_NONE;
2669 camera_cli_s *pc = (camera_cli_s *)camera;
2670 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2671 camera_msg_param param;
2674 if (!pc || !pc->cb_info) {
2675 LOGE("NULL handle");
2676 return CAMERA_ERROR_INVALID_PARAMETER;
2681 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2682 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2684 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2685 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2687 value = (count << 16) | interval;
2688 CAMERA_MSG_PARAM_SET(param, INT, value);
2690 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2692 LOGD("ret : 0x%x", ret);
2698 int camera_stop_continuous_capture(camera_h camera)
2700 int ret = CAMERA_ERROR_NONE;
2701 camera_cli_s *pc = (camera_cli_s *)camera;
2702 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2704 if (!pc || !pc->cb_info) {
2705 LOGE("NULL handle");
2706 return CAMERA_ERROR_INVALID_PARAMETER;
2711 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2713 LOGD("ret : 0x%x", ret);
2719 bool camera_is_supported_face_detection(camera_h camera)
2721 int ret = CAMERA_ERROR_NONE;
2722 camera_cli_s *pc = (camera_cli_s *)camera;
2723 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2725 if (!pc || !pc->cb_info) {
2726 LOGE("NULL handle");
2727 return CAMERA_ERROR_INVALID_PARAMETER;
2732 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2735 LOGE("error is occurred 0x%x", ret);
2739 LOGD("ret : %d", ret);
2745 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2747 int ret = CAMERA_ERROR_NONE;
2748 camera_cli_s *pc = (camera_cli_s *)camera;
2749 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2751 if (!pc || !pc->cb_info) {
2752 LOGE("NULL handle");
2753 return CAMERA_ERROR_INVALID_PARAMETER;
2758 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2761 LOGE("error is occurred 0x%x", ret);
2765 LOGD("ret : %d", ret);
2771 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2773 int ret = CAMERA_ERROR_NONE;
2774 camera_cli_s *pc = (camera_cli_s *)camera;
2775 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2777 if (!pc || !pc->cb_info) {
2778 LOGE("NULL handle");
2779 return CAMERA_ERROR_INVALID_PARAMETER;
2784 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2787 LOGE("error is occurred 0x%x", ret);
2791 LOGD("ret : %d", ret);
2796 int camera_get_device_count(camera_h camera, int *device_count)
2798 int ret = CAMERA_ERROR_NONE;
2799 camera_cli_s *pc = (camera_cli_s *)camera;
2800 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2802 if (!pc || !pc->cb_info) {
2803 LOGE("NULL handle");
2804 return CAMERA_ERROR_INVALID_PARAMETER;
2809 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2811 if (ret == CAMERA_ERROR_NONE)
2812 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2814 LOGD("ret : 0x%x", ret);
2819 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2821 int ret = CAMERA_ERROR_NONE;
2822 camera_cli_s *pc = (camera_cli_s *)camera;
2823 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2825 if (!pc || !pc->cb_info) {
2826 LOGE("NULL handle");
2827 return CAMERA_ERROR_INVALID_PARAMETER;
2832 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2834 if (ret == CAMERA_ERROR_NONE) {
2835 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2837 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2838 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2840 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2843 LOGD("ret : 0x%x", ret);
2848 int camera_stop_face_detection(camera_h camera)
2850 int ret = CAMERA_ERROR_NONE;
2851 camera_cli_s *pc = (camera_cli_s *)camera;
2852 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
2854 if (!pc || !pc->cb_info) {
2855 LOGE("NULL handle");
2856 return CAMERA_ERROR_INVALID_PARAMETER;
2861 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2863 if (ret == CAMERA_ERROR_NONE) {
2864 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2866 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
2867 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
2869 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2872 LOGD("ret : 0x%x", ret);
2877 int camera_get_state(camera_h camera, camera_state_e *state)
2879 int ret = CAMERA_ERROR_NONE;
2880 camera_cli_s *pc = (camera_cli_s *)camera;
2881 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
2883 if (!pc || !pc->cb_info || !state) {
2884 LOGE("NULL pointer %p %p", pc, state);
2885 return CAMERA_ERROR_INVALID_PARAMETER;
2890 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2892 if (ret == CAMERA_ERROR_NONE)
2893 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
2895 LOGD("ret : 0x%x", ret);
2900 int camera_start_focusing(camera_h camera, bool continuous)
2902 int ret = CAMERA_ERROR_NONE;
2903 camera_cli_s *pc = (camera_cli_s *)camera;
2904 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
2905 camera_msg_param param;
2906 int is_continuous = (int)continuous;
2908 if (!pc || !pc->cb_info) {
2909 LOGE("NULL handle");
2910 return CAMERA_ERROR_INVALID_PARAMETER;
2915 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
2917 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2919 LOGD("ret : 0x%x", ret);
2924 int camera_cancel_focusing(camera_h camera)
2926 int ret = CAMERA_ERROR_NONE;
2927 camera_cli_s *pc = (camera_cli_s *)camera;
2928 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
2930 if (!pc || !pc->cb_info) {
2931 LOGE("NULL handle");
2932 return CAMERA_ERROR_INVALID_PARAMETER;
2935 LOGD("Enter, remote_handle : %x", pc->remote_handle);
2937 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2939 LOGD("ret : 0x%x", ret);
2944 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
2946 int ret = CAMERA_ERROR_NONE;
2947 camera_cli_s *pc = (camera_cli_s *)camera;
2948 camera_cb_info_s *cb_info = NULL;
2949 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
2950 camera_state_e current_state = CAMERA_STATE_NONE;
2951 camera_msg_param param;
2955 if (!pc || !pc->cb_info) {
2956 LOGE("NULL handle");
2957 return CAMERA_ERROR_INVALID_PARAMETER;
2960 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
2961 LOGE("invalid type %d", type);
2962 return CAMERA_ERROR_INVALID_PARAMETER;
2965 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
2966 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
2967 return CAMERA_ERROR_INVALID_PARAMETER;
2970 cb_info = (camera_cb_info_s *)pc->cb_info;
2972 ret = camera_get_state(camera, ¤t_state);
2973 if (ret != CAMERA_ERROR_NONE) {
2974 LOGE("failed to get current state 0x%x", ret);
2978 if (current_state != CAMERA_STATE_CREATED) {
2979 LOGE("INVALID_STATE : current %d", current_state);
2980 return CAMERA_ERROR_INVALID_STATE;
2983 LOGD("Enter - display : %p", display);
2985 if (type == CAMERA_DISPLAY_TYPE_NONE) {
2986 LOGD("display type NONE");
2988 /* display interface handle */
2989 if (!cb_info->dp_interface) {
2990 if (mm_display_interface_init(&cb_info->dp_interface) != MM_ERROR_NONE) {
2991 LOGE("display interface init failed");
2992 return CAMERA_ERROR_NOT_SUPPORTED;
2996 ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &cb_info->parent_id);
2997 if (ret == MM_ERROR_NONE && type == CAMERA_DISPLAY_TYPE_EVAS) {
2998 camera_flip_e flip = CAMERA_FLIP_NONE;
2999 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3000 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3007 camera_get_display_flip(camera, &flip);
3008 camera_get_display_mode(camera, &mode);
3009 camera_get_display_rotation(camera, &rotation);
3010 camera_is_display_visible(camera, &visible);
3011 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3013 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
3014 flip, mode, rotation, visible, x, y, width, height);
3016 ret = mm_display_interface_evas_set_flip(cb_info->dp_interface, flip);
3017 ret |= mm_display_interface_evas_set_mode(cb_info->dp_interface, mode);
3018 ret |= mm_display_interface_evas_set_rotation(cb_info->dp_interface, rotation);
3019 ret |= mm_display_interface_evas_set_visible(cb_info->dp_interface, visible);
3021 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
3022 ret |= mm_display_interface_evas_set_roi_area(cb_info->dp_interface, x, y, width, height);
3026 if (type == CAMERA_DISPLAY_TYPE_OVERLAY) {
3029 length = sizeof(camera_wl_info_s) / sizeof(int) + \
3030 (sizeof(camera_wl_info_s) % sizeof(int) ? 1 : 0);
3032 msg = muse_core_msg_new(api,
3033 MUSE_TYPE_INT, "type", type,
3034 MUSE_TYPE_INT, "parent_id", cb_info->parent_id,
3037 LOGE("msg creation failed: api %d", api);
3038 return CAMERA_ERROR_OUT_OF_MEMORY;
3041 if (pc->cb_info->is_server_connected) {
3042 __camera_update_api_waiting(pc->cb_info, api, 1);
3044 g_mutex_lock(&pc->cb_info->fd_lock);
3045 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
3046 g_mutex_unlock(&pc->cb_info->fd_lock);
3050 LOGE("message send failed");
3051 ret = CAMERA_ERROR_INVALID_OPERATION;
3053 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
3056 __camera_update_api_waiting(pc->cb_info, api, -1);
3058 muse_core_msg_free(msg);
3060 CAMERA_MSG_PARAM_SET(param, INT, type);
3062 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3065 if (ret != CAMERA_ERROR_NONE)
3066 LOGE("set display error 0x%x", ret);
3067 else if (type == CAMERA_DISPLAY_TYPE_EVAS)
3068 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3074 int camera_set_preview_resolution(camera_h camera, int width, int height)
3076 int ret = CAMERA_ERROR_NONE;
3077 camera_state_e current_state = CAMERA_STATE_NONE;
3078 camera_cli_s *pc = (camera_cli_s *)camera;
3079 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3080 camera_msg_param param;
3083 if (!pc || !pc->cb_info) {
3084 LOGE("NULL handle");
3085 return CAMERA_ERROR_INVALID_PARAMETER;
3088 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3089 ret = camera_get_state(camera, ¤t_state);
3090 if (ret != CAMERA_ERROR_NONE) {
3091 LOGE("failed to get current state 0x%x", ret);
3095 if (current_state == CAMERA_STATE_PREVIEW) {
3096 ret = _camera_stop_evas_rendering(camera, true);
3097 if (ret != CAMERA_ERROR_NONE)
3102 value = (width << 16) | height;
3103 CAMERA_MSG_PARAM_SET(param, INT, value);
3105 LOGD("%dx%d -> 0x%x", width, height, value);
3107 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3109 LOGD("ret : 0x%x", ret);
3111 if (current_state == CAMERA_STATE_PREVIEW) {
3112 LOGW("restart evas rendering");
3113 _camera_start_evas_rendering(camera);
3120 int camera_set_capture_resolution(camera_h camera, int width, int height)
3122 int ret = CAMERA_ERROR_NONE;
3123 camera_cli_s *pc = (camera_cli_s *)camera;
3124 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3125 camera_msg_param param;
3128 if (!pc || !pc->cb_info) {
3129 LOGE("NULL handle");
3130 return CAMERA_ERROR_INVALID_PARAMETER;
3135 value = (width << 16) | height;
3136 CAMERA_MSG_PARAM_SET(param, INT, value);
3138 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3140 LOGD("ret : 0x%x", ret);
3146 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3148 int ret = CAMERA_ERROR_NONE;
3149 int set_format = (int)format;
3150 camera_cli_s *pc = (camera_cli_s *)camera;
3151 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3152 camera_msg_param param;
3154 if (!pc || !pc->cb_info) {
3155 LOGE("NULL handle");
3156 return CAMERA_ERROR_INVALID_PARAMETER;
3159 LOGD("Enter - format %d", set_format);
3161 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3163 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3165 LOGD("ret : 0x%x", ret);
3171 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3173 int ret = CAMERA_ERROR_NONE;
3174 int set_format = (int)format;
3175 camera_msg_param param;
3176 camera_cli_s *pc = (camera_cli_s *)camera;
3177 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3179 if (!pc || !pc->cb_info) {
3180 LOGE("NULL handle");
3181 return CAMERA_ERROR_INVALID_PARAMETER;
3184 LOGD("Enter - capture_format %d", set_format);
3186 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3188 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3190 LOGD("ret : 0x%x", ret);
3196 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3198 int ret = CAMERA_ERROR_NONE;
3199 camera_cli_s *pc = (camera_cli_s *)camera;
3200 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3202 if (!pc || !pc->cb_info || !width || !height) {
3203 LOGE("NULL pointer %p %p %p", pc, width, height);
3204 return CAMERA_ERROR_INVALID_PARAMETER;
3209 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3211 if (ret == CAMERA_ERROR_NONE) {
3212 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3213 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3216 LOGD("ret : 0x%x", ret);
3222 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3224 int ret = CAMERA_ERROR_NONE;
3225 int set_rotation = (int)rotation;
3226 camera_cli_s *pc = (camera_cli_s *)camera;
3227 camera_msg_param param;
3229 if (!pc || !pc->cb_info) {
3230 LOGE("NULL handle");
3231 return CAMERA_ERROR_INVALID_PARAMETER;
3234 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3235 ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
3236 if (ret != MM_ERROR_NONE) {
3237 LOGE("failed to set rotation for evas surface 0x%x", ret);
3238 return CAMERA_ERROR_INVALID_OPERATION;
3242 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3244 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3250 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3252 int ret = CAMERA_ERROR_NONE;
3253 camera_cli_s *pc = (camera_cli_s *)camera;
3255 if (!pc || !pc->cb_info || !rotation) {
3256 LOGE("NULL pointer %p %p", pc, rotation);
3257 return CAMERA_ERROR_INVALID_PARAMETER;
3260 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3262 if (ret == CAMERA_ERROR_NONE)
3263 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3269 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3271 int ret = CAMERA_ERROR_NONE;
3272 int set_flip = (int)flip;
3273 camera_cli_s *pc = (camera_cli_s *)camera;
3274 camera_msg_param param;
3276 if (!pc || !pc->cb_info) {
3277 LOGE("NULL handle");
3278 return CAMERA_ERROR_INVALID_PARAMETER;
3281 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3282 ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
3283 if (ret != MM_ERROR_NONE) {
3284 LOGE("failed to set flip for evas surface 0x%x", ret);
3285 return CAMERA_ERROR_INVALID_OPERATION;
3289 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3291 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3297 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3299 int ret = CAMERA_ERROR_NONE;
3300 camera_cli_s *pc = (camera_cli_s *)camera;
3302 if (!pc || !pc->cb_info || !flip) {
3303 LOGE("NULL pointer %p %p", pc, flip);
3304 return CAMERA_ERROR_INVALID_PARAMETER;
3307 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3309 if (ret == CAMERA_ERROR_NONE)
3310 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3316 int camera_set_display_visible(camera_h camera, bool visible)
3318 int ret = CAMERA_ERROR_NONE;
3319 int set_visible = (int)visible;
3320 camera_cli_s *pc = (camera_cli_s *)camera;
3321 camera_msg_param param;
3323 if (!pc || !pc->cb_info) {
3324 LOGE("NULL handle");
3325 return CAMERA_ERROR_INVALID_PARAMETER;
3328 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3329 ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
3330 if (ret != MM_ERROR_NONE) {
3331 LOGE("failed to set visible for evas surface 0x%x", ret);
3332 return CAMERA_ERROR_INVALID_OPERATION;
3336 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3338 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3344 int camera_is_display_visible(camera_h camera, bool *visible)
3346 int ret = CAMERA_ERROR_NONE;
3347 camera_cli_s *pc = (camera_cli_s *)camera;
3349 if (!pc || !pc->cb_info || !visible) {
3350 LOGE("NULL pointer %p %p", pc, visible);
3351 return CAMERA_ERROR_INVALID_PARAMETER;
3354 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3356 if (ret == CAMERA_ERROR_NONE)
3357 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3363 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3365 int ret = CAMERA_ERROR_NONE;
3366 int set_mode = (int)mode;
3367 camera_cli_s *pc = (camera_cli_s *)camera;
3368 camera_msg_param param;
3370 if (!pc || !pc->cb_info) {
3371 LOGE("NULL handle");
3372 return CAMERA_ERROR_INVALID_PARAMETER;
3375 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3376 ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
3377 if (ret != MM_ERROR_NONE) {
3378 LOGE("failed to set geometry for evas surface 0x%x", ret);
3379 return CAMERA_ERROR_INVALID_OPERATION;
3383 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3385 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3391 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3393 int ret = CAMERA_ERROR_NONE;
3394 camera_cli_s *pc = (camera_cli_s *)camera;
3396 if (!pc || !pc->cb_info || !mode) {
3397 LOGE("NULL pointer %p %p", pc, mode);
3398 return CAMERA_ERROR_INVALID_PARAMETER;
3401 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3403 if (ret == CAMERA_ERROR_NONE)
3404 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3410 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3412 int ret = CAMERA_ERROR_NONE;
3413 int set_hint = (int)hint;
3414 camera_cli_s *pc = (camera_cli_s *)camera;
3415 camera_msg_param param;
3417 if (!pc || !pc->cb_info) {
3418 LOGE("NULL handle");
3419 return CAMERA_ERROR_INVALID_PARAMETER;
3422 LOGD("Enter - hint %d", set_hint);
3424 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3426 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3432 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3434 int ret = CAMERA_ERROR_NONE;
3435 camera_cli_s *pc = (camera_cli_s *)camera;
3436 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3438 if (!pc || !pc->cb_info || !hint) {
3439 LOGE("NULL pointer %p %p", pc, hint);
3440 return CAMERA_ERROR_INVALID_PARAMETER;
3443 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3445 if (ret == CAMERA_ERROR_NONE) {
3446 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3447 LOGD("display reuse hint %d", *hint);
3454 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3456 int ret = CAMERA_ERROR_NONE;
3457 camera_cli_s *pc = (camera_cli_s *)camera;
3458 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3460 if (!pc || !pc->cb_info || !width || !height) {
3461 LOGE("NULL pointer %p %p %p", pc, width, height);
3462 return CAMERA_ERROR_INVALID_PARAMETER;
3467 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3469 if (ret == CAMERA_ERROR_NONE) {
3470 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3471 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3474 LOGD("ret : 0x%x", ret);
3480 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3482 int ret = CAMERA_ERROR_NONE;
3483 camera_cli_s *pc = (camera_cli_s *)camera;
3484 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3486 if (!pc || !pc->cb_info || !format) {
3487 LOGE("NULL pointer %p %p", pc, format);
3488 return CAMERA_ERROR_INVALID_PARAMETER;
3493 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3495 if (ret == CAMERA_ERROR_NONE)
3496 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3498 LOGD("ret : 0x%x", ret);
3504 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3506 int ret = CAMERA_ERROR_NONE;
3507 camera_cli_s *pc = (camera_cli_s *)camera;
3508 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3510 if (!pc || !pc->cb_info || !format) {
3511 LOGE("NULL pointer %p %p", pc, format);
3512 return CAMERA_ERROR_INVALID_PARAMETER;
3517 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3519 if (ret == CAMERA_ERROR_NONE)
3520 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3522 LOGD("ret : 0x%x", ret);
3528 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3530 int ret = CAMERA_ERROR_NONE;
3531 camera_cli_s *pc = (camera_cli_s *)camera;
3532 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3534 if (!pc || !pc->cb_info || !facing_direction) {
3535 LOGE("NULL pointer %p %p", pc, facing_direction);
3536 return CAMERA_ERROR_INVALID_PARAMETER;
3541 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3543 if (ret == CAMERA_ERROR_NONE)
3544 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3546 LOGD("ret : 0x%x", ret);
3552 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3554 int ret = CAMERA_ERROR_NONE;
3555 camera_cli_s *pc = (camera_cli_s *)camera;
3556 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3558 if (!pc || !pc->cb_info || !callback) {
3559 LOGE("NULL pointer %p %p", pc, callback);
3560 return CAMERA_ERROR_INVALID_PARAMETER;
3565 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3567 if (ret == CAMERA_ERROR_NONE) {
3568 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3570 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3571 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3573 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3575 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3578 LOGD("ret : 0x%x", ret);
3584 int camera_unset_preview_cb(camera_h camera)
3586 int ret = CAMERA_ERROR_NONE;
3587 camera_cli_s *pc = (camera_cli_s *)camera;
3588 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3590 if (!pc || !pc->cb_info) {
3591 LOGE("NULL handle");
3592 return CAMERA_ERROR_INVALID_PARAMETER;
3597 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3599 if (ret == CAMERA_ERROR_NONE) {
3600 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3602 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3603 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3605 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3607 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3610 LOGD("ret : 0x%x", ret);
3616 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3618 int ret = CAMERA_ERROR_NONE;
3619 camera_cli_s *pc = (camera_cli_s *)camera;
3620 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3622 if (!pc || !pc->cb_info) {
3623 LOGE("NULL handle");
3624 return CAMERA_ERROR_INVALID_PARAMETER;
3627 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3628 LOGE("NOT SUPPORTED");
3629 return CAMERA_ERROR_NOT_SUPPORTED;
3632 if (callback == NULL) {
3633 LOGE("NULL callback");
3634 return CAMERA_ERROR_INVALID_PARAMETER;
3639 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3641 if (ret == CAMERA_ERROR_NONE) {
3642 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3644 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3645 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3647 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3650 LOGD("ret : 0x%x", ret);
3656 int camera_unset_media_packet_preview_cb(camera_h camera)
3658 int ret = CAMERA_ERROR_NONE;
3659 camera_cli_s *pc = (camera_cli_s *)camera;
3660 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3662 if (!pc || !pc->cb_info) {
3663 LOGE("NULL handle");
3664 return CAMERA_ERROR_INVALID_PARAMETER;
3669 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3671 if (ret == CAMERA_ERROR_NONE) {
3672 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3674 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3675 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3677 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3680 LOGD("ret : 0x%x", ret);
3686 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3688 int ret = CAMERA_ERROR_NONE;
3689 camera_cli_s *pc = (camera_cli_s *)camera;
3690 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3692 if (!pc || !pc->cb_info || !callback) {
3693 LOGE("NULL pointer %p %p", pc, callback);
3694 return CAMERA_ERROR_INVALID_PARAMETER;
3699 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3701 if (ret == CAMERA_ERROR_NONE) {
3702 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3704 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3705 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3707 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3710 LOGD("ret : 0x%x", ret);
3716 int camera_unset_state_changed_cb(camera_h camera)
3718 int ret = CAMERA_ERROR_NONE;
3719 camera_cli_s *pc = (camera_cli_s *)camera;
3720 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3722 if (!pc || !pc->cb_info) {
3723 LOGE("NULL handle");
3724 return CAMERA_ERROR_INVALID_PARAMETER;
3729 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3731 if (ret == CAMERA_ERROR_NONE) {
3732 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3734 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3735 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3737 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3740 LOGD("ret : 0x%x", ret);
3746 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3748 int ret = CAMERA_ERROR_NONE;
3749 camera_cli_s *pc = (camera_cli_s *)camera;
3750 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3752 if (!pc || !pc->cb_info || !callback) {
3753 LOGE("NULL pointer %p %p", pc, callback);
3754 return CAMERA_ERROR_INVALID_PARAMETER;
3759 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3761 if (ret == CAMERA_ERROR_NONE) {
3762 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3764 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3765 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3767 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3770 LOGD("ret : 0x%x", ret);
3776 int camera_unset_interrupted_cb(camera_h camera)
3778 int ret = CAMERA_ERROR_NONE;
3779 camera_cli_s *pc = (camera_cli_s *)camera;
3780 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3782 if (!pc || !pc->cb_info) {
3783 LOGE("NULL handle");
3784 return CAMERA_ERROR_INVALID_PARAMETER;
3789 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3791 if (ret == CAMERA_ERROR_NONE) {
3792 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3794 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3795 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3797 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3800 LOGD("ret : 0x%x", ret);
3806 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
3808 int ret = CAMERA_ERROR_NONE;
3809 camera_cli_s *pc = (camera_cli_s *)camera;
3810 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
3812 if (!pc || !pc->cb_info || !callback) {
3813 LOGE("NULL pointer %p %p", pc, callback);
3814 return CAMERA_ERROR_INVALID_PARAMETER;
3819 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3821 if (ret == CAMERA_ERROR_NONE) {
3822 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3824 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
3825 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
3827 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3830 LOGD("ret : 0x%x", ret);
3836 int camera_unset_interrupt_started_cb(camera_h camera)
3838 int ret = CAMERA_ERROR_NONE;
3839 camera_cli_s *pc = (camera_cli_s *)camera;
3840 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
3842 if (!pc || !pc->cb_info) {
3843 LOGE("NULL handle");
3844 return CAMERA_ERROR_INVALID_PARAMETER;
3849 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3851 if (ret == CAMERA_ERROR_NONE) {
3852 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3854 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3855 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3857 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3860 LOGD("ret : 0x%x", ret);
3866 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
3868 int ret = CAMERA_ERROR_NONE;
3869 camera_cli_s *pc = (camera_cli_s *)camera;
3870 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3872 if (!pc || !pc->cb_info || !callback) {
3873 LOGE("NULL pointer %p %p", pc, callback);
3874 return CAMERA_ERROR_INVALID_PARAMETER;
3879 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3881 if (ret == CAMERA_ERROR_NONE) {
3882 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3884 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3885 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3887 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3890 LOGD("ret : 0x%x", ret);
3896 int camera_unset_focus_changed_cb(camera_h camera)
3898 int ret = CAMERA_ERROR_NONE;
3899 camera_cli_s *pc = (camera_cli_s *)camera;
3900 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
3902 if (!pc || !pc->cb_info) {
3903 LOGE("NULL handle");
3904 return CAMERA_ERROR_INVALID_PARAMETER;
3909 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3911 if (ret == CAMERA_ERROR_NONE) {
3912 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3914 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3915 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3917 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3920 LOGD("ret : 0x%x", ret);
3926 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
3928 int ret = CAMERA_ERROR_NONE;
3929 camera_cli_s *pc = (camera_cli_s *)camera;
3930 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
3932 if (!pc || !pc->cb_info || !callback) {
3933 LOGE("NULL pointer %p %p", pc, callback);
3934 return CAMERA_ERROR_INVALID_PARAMETER;
3939 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3941 if (ret == CAMERA_ERROR_NONE) {
3942 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3944 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
3945 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
3947 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3950 LOGD("ret : 0x%x", ret);
3956 int camera_unset_error_cb(camera_h camera)
3958 int ret = CAMERA_ERROR_NONE;
3959 camera_cli_s *pc = (camera_cli_s *)camera;
3960 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
3962 if (!pc || !pc->cb_info) {
3963 LOGE("NULL handle");
3964 return CAMERA_ERROR_INVALID_PARAMETER;
3969 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3971 if (ret == CAMERA_ERROR_NONE) {
3972 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3974 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
3975 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
3977 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3980 LOGD("ret : 0x%x", ret);
3986 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
3988 int ret = CAMERA_ERROR_NONE;
3989 camera_cli_s *pc = (camera_cli_s *)camera;
3990 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
3992 if (!pc || !pc->cb_info || !foreach_cb) {
3993 LOGE("NULL pointer %p %p", pc, foreach_cb);
3994 return CAMERA_ERROR_INVALID_PARAMETER;
3999 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4000 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4002 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4004 LOGD("ret : 0x%x", ret);
4010 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4012 int ret = CAMERA_ERROR_NONE;
4013 camera_cli_s *pc = (camera_cli_s *)camera;
4014 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4016 if (!pc || !pc->cb_info || !foreach_cb) {
4017 LOGE("NULL pointer %p %p", pc, foreach_cb);
4018 return CAMERA_ERROR_INVALID_PARAMETER;
4023 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4024 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4026 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4028 LOGD("ret : 0x%x", ret);
4034 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4036 int ret = CAMERA_ERROR_NONE;
4037 camera_cli_s *pc = (camera_cli_s *)camera;
4038 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4040 if (!pc || !pc->cb_info || !foreach_cb) {
4041 LOGE("NULL pointer %p %p", pc, foreach_cb);
4042 return CAMERA_ERROR_INVALID_PARAMETER;
4047 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4048 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4050 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4052 LOGD("ret : 0x%x", ret);
4058 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4060 int ret = CAMERA_ERROR_NONE;
4061 camera_cli_s *pc = (camera_cli_s *)camera;
4062 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4064 if (!pc || !pc->cb_info || !foreach_cb) {
4065 LOGE("NULL pointer %p %p", pc, foreach_cb);
4066 return CAMERA_ERROR_INVALID_PARAMETER;
4071 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4072 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4074 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4076 LOGD("ret : 0x%x", ret);
4082 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4084 int ret = CAMERA_ERROR_NONE;
4085 camera_cli_s *pc = (camera_cli_s *)camera;
4086 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4088 if (!pc || !pc->cb_info || !width || !height) {
4089 LOGE("NULL pointer %p %p %p", pc, width, height);
4090 return CAMERA_ERROR_INVALID_PARAMETER;
4094 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4096 if (ret == CAMERA_ERROR_NONE) {
4097 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4098 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4101 LOGD("ret : 0x%x", ret);
4107 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4109 int ret = CAMERA_ERROR_NONE;
4110 camera_cli_s *pc = (camera_cli_s *)camera;
4111 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4113 if (!pc || !pc->cb_info || !angle) {
4114 LOGE("NULL pointer %p %p", pc, angle);
4115 return CAMERA_ERROR_INVALID_PARAMETER;
4120 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4122 if (ret == CAMERA_ERROR_NONE)
4123 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4125 LOGD("ret : 0x%x", ret);
4131 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4133 int ret = CAMERA_ERROR_NONE;
4134 camera_cli_s *pc = (camera_cli_s *)camera;
4135 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4136 camera_msg_param param;
4137 int set_mode = (int)mode;
4139 if (!pc || !pc->cb_info) {
4140 LOGE("NULL handle");
4141 return CAMERA_ERROR_INVALID_PARAMETER;
4146 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4148 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4150 LOGD("ret : 0x%x", ret);
4156 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4158 int ret = CAMERA_ERROR_NONE;
4159 camera_cli_s *pc = (camera_cli_s *)camera;
4160 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4162 if (!pc || !pc->cb_info || !mode) {
4163 LOGE("NULL pointer %p %p", pc, mode);
4164 return CAMERA_ERROR_INVALID_PARAMETER;
4169 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4171 if (ret == CAMERA_ERROR_NONE)
4172 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4174 LOGD("ret : 0x%x", ret);
4180 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4182 int ret = CAMERA_ERROR_NONE;
4183 camera_cli_s *pc = (camera_cli_s *)camera;
4184 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4186 if (!pc || !pc->cb_info || !foreach_cb) {
4187 LOGE("NULL pointer %p %p", pc, foreach_cb);
4188 return CAMERA_ERROR_INVALID_PARAMETER;
4193 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4194 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4196 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4198 LOGD("Finish, return :%x", ret);
4204 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4206 int ret = CAMERA_ERROR_NONE;
4207 camera_cli_s *pc = (camera_cli_s *)camera;
4208 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4209 camera_msg_param param;
4210 int set_fps = (int)fps;
4212 if (!pc || !pc->cb_info) {
4213 LOGE("NULL handle");
4214 return CAMERA_ERROR_INVALID_PARAMETER;
4219 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4221 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4223 LOGD("ret : 0x%x", ret);
4229 int camera_attr_set_image_quality(camera_h camera, int quality)
4231 int ret = CAMERA_ERROR_NONE;
4232 camera_cli_s *pc = (camera_cli_s *)camera;
4233 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4234 camera_msg_param param;
4236 if (!pc || !pc->cb_info) {
4237 LOGE("NULL handle");
4238 return CAMERA_ERROR_INVALID_PARAMETER;
4243 CAMERA_MSG_PARAM_SET(param, INT, quality);
4245 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4247 LOGD("ret : 0x%x", ret);
4253 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4255 int ret = CAMERA_ERROR_NONE;
4256 camera_cli_s *pc = (camera_cli_s *)camera;
4257 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4259 if (!pc || !pc->cb_info || !fps) {
4260 LOGE("NULL pointer %p %p", pc, fps);
4261 return CAMERA_ERROR_INVALID_PARAMETER;
4266 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4268 if (ret == CAMERA_ERROR_NONE)
4269 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4271 LOGD("ret : 0x%x", ret);
4277 int camera_attr_get_image_quality(camera_h camera, int *quality)
4279 int ret = CAMERA_ERROR_NONE;
4280 camera_cli_s *pc = (camera_cli_s *)camera;
4281 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4283 if (!pc || !pc->cb_info || !quality) {
4284 LOGE("NULL pointer %p %p", pc, quality);
4285 return CAMERA_ERROR_INVALID_PARAMETER;
4290 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4292 if (ret == CAMERA_ERROR_NONE)
4293 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4295 LOGD("ret : 0x%x", ret);
4301 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4303 int ret = CAMERA_ERROR_NONE;
4304 camera_cli_s *pc = (camera_cli_s *)camera;
4305 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4307 if (!pc || !pc->cb_info || !bitrate) {
4308 LOGE("NULL pointer %p %p", pc, bitrate);
4309 return CAMERA_ERROR_INVALID_PARAMETER;
4314 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4316 if (ret == CAMERA_ERROR_NONE)
4317 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4319 LOGD("ret : 0x%x", ret);
4325 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4327 int ret = CAMERA_ERROR_NONE;
4328 camera_cli_s *pc = (camera_cli_s *)camera;
4329 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4330 camera_msg_param param;
4331 int set_bitrate = bitrate;
4333 if (!pc || !pc->cb_info) {
4334 LOGE("NULL handle");
4335 return CAMERA_ERROR_INVALID_PARAMETER;
4340 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4342 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4344 LOGD("ret : 0x%x", ret);
4350 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4352 int ret = CAMERA_ERROR_NONE;
4353 camera_cli_s *pc = (camera_cli_s *)camera;
4354 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4356 if (!pc || !pc->cb_info || !interval) {
4357 LOGE("NULL pointer %p %p", pc, interval);
4358 return CAMERA_ERROR_INVALID_PARAMETER;
4363 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4365 if (ret == CAMERA_ERROR_NONE)
4366 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4368 LOGD("ret : 0x%x", ret);
4374 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4376 int ret = CAMERA_ERROR_NONE;
4377 camera_cli_s *pc = (camera_cli_s *)camera;
4378 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4379 camera_msg_param param;
4380 int set_gop_interval = interval;
4382 if (!pc || !pc->cb_info) {
4383 LOGE("NULL handle");
4384 return CAMERA_ERROR_INVALID_PARAMETER;
4389 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4391 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4393 LOGD("ret : 0x%x", ret);
4399 int camera_attr_set_zoom(camera_h camera, int zoom)
4401 int ret = CAMERA_ERROR_NONE;
4402 camera_cli_s *pc = (camera_cli_s *)camera;
4403 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4404 camera_msg_param param;
4406 if (!pc || !pc->cb_info) {
4407 LOGE("NULL handle");
4408 return CAMERA_ERROR_INVALID_PARAMETER;
4411 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4413 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4415 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4417 LOGD("ret : 0x%x", ret);
4423 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4425 int ret = CAMERA_ERROR_NONE;
4426 camera_cli_s *pc = (camera_cli_s *)camera;
4427 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4428 camera_msg_param param;
4429 int set_mode = (int)mode;
4431 if (!pc || !pc->cb_info) {
4432 LOGE("NULL handle");
4433 return CAMERA_ERROR_INVALID_PARAMETER;
4436 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4438 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4440 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4446 int camera_attr_set_af_area(camera_h camera, int x, int y)
4448 int ret = CAMERA_ERROR_NONE;
4449 camera_cli_s *pc = (camera_cli_s *)camera;
4450 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4451 camera_msg_param param;
4454 if (!pc || !pc->cb_info) {
4455 LOGE("NULL handle");
4456 return CAMERA_ERROR_INVALID_PARAMETER;
4459 LOGD("Enter - %d,%d", x, y);
4461 value = (x << 16) | y;
4462 CAMERA_MSG_PARAM_SET(param, INT, value);
4464 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4466 LOGD("ret : 0x%x", ret);
4472 int camera_attr_clear_af_area(camera_h camera)
4474 int ret = CAMERA_ERROR_NONE;
4475 camera_cli_s *pc = (camera_cli_s *)camera;
4476 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4478 if (!pc || !pc->cb_info) {
4479 LOGE("NULL handle");
4480 return CAMERA_ERROR_INVALID_PARAMETER;
4485 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4487 LOGD("ret : 0x%x", ret);
4493 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4495 int ret = CAMERA_ERROR_NONE;
4496 camera_cli_s *pc = (camera_cli_s *)camera;
4497 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4498 camera_msg_param param;
4499 int set_mode = (int)mode;
4501 if (!pc || !pc->cb_info) {
4502 LOGE("NULL handle");
4503 return CAMERA_ERROR_INVALID_PARAMETER;
4508 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4510 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4512 LOGD("ret : 0x%x", ret);
4518 int camera_attr_set_exposure(camera_h camera, int value)
4520 int ret = CAMERA_ERROR_NONE;
4521 camera_cli_s *pc = (camera_cli_s *)camera;
4522 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4523 camera_msg_param param;
4525 if (!pc || !pc->cb_info) {
4526 LOGE("NULL handle");
4527 return CAMERA_ERROR_INVALID_PARAMETER;
4532 CAMERA_MSG_PARAM_SET(param, INT, value);
4534 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4536 LOGD("ret : 0x%x", ret);
4542 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4544 int ret = CAMERA_ERROR_NONE;
4545 camera_cli_s *pc = (camera_cli_s *)camera;
4546 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4547 camera_msg_param param;
4548 int set_iso = (int)iso;
4550 if (!pc || !pc->cb_info) {
4551 LOGE("NULL handle");
4552 return CAMERA_ERROR_INVALID_PARAMETER;
4557 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4559 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4561 LOGD("ret : 0x%x", ret);
4567 int camera_attr_set_brightness(camera_h camera, int level)
4569 int ret = CAMERA_ERROR_NONE;
4570 camera_cli_s *pc = (camera_cli_s *)camera;
4571 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4572 camera_msg_param param;
4574 if (!pc || !pc->cb_info) {
4575 LOGE("NULL handle");
4576 return CAMERA_ERROR_INVALID_PARAMETER;
4581 CAMERA_MSG_PARAM_SET(param, INT, level);
4583 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4585 LOGD("ret : 0x%x", ret);
4591 int camera_attr_set_contrast(camera_h camera, int level)
4593 int ret = CAMERA_ERROR_NONE;
4594 camera_cli_s *pc = (camera_cli_s *)camera;
4595 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4596 camera_msg_param param;
4598 if (!pc || !pc->cb_info) {
4599 LOGE("NULL handle");
4600 return CAMERA_ERROR_INVALID_PARAMETER;
4605 CAMERA_MSG_PARAM_SET(param, INT, level);
4607 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4609 LOGD("ret : 0x%x", ret);
4615 int camera_attr_set_hue(camera_h camera, int level)
4617 int ret = CAMERA_ERROR_NONE;
4618 camera_cli_s *pc = (camera_cli_s *)camera;
4619 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HUE;
4620 camera_msg_param param;
4622 if (!pc || !pc->cb_info) {
4623 LOGE("NULL handle");
4624 return CAMERA_ERROR_INVALID_PARAMETER;
4629 CAMERA_MSG_PARAM_SET(param, INT, level);
4631 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4633 LOGD("ret : 0x%x", ret);
4639 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4641 int ret = CAMERA_ERROR_NONE;
4642 camera_cli_s *pc = (camera_cli_s *)camera;
4643 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4644 camera_msg_param param;
4645 int set_whitebalance = (int)wb;
4647 if (!pc || !pc->cb_info) {
4648 LOGE("NULL handle");
4649 return CAMERA_ERROR_INVALID_PARAMETER;
4654 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4656 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4658 LOGD("ret : 0x%x", ret);
4664 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4666 int ret = CAMERA_ERROR_NONE;
4667 camera_cli_s *pc = (camera_cli_s *)camera;
4668 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4669 camera_msg_param param;
4670 int set_effect = (int)effect;
4672 if (!pc || !pc->cb_info) {
4673 LOGE("NULL handle");
4674 return CAMERA_ERROR_INVALID_PARAMETER;
4679 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4681 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4683 LOGD("ret : 0x%x", ret);
4689 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4691 int ret = CAMERA_ERROR_NONE;
4692 camera_cli_s *pc = (camera_cli_s *)camera;
4693 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4694 camera_msg_param param;
4695 int set_mode = (int)mode;
4697 if (!pc || !pc->cb_info) {
4698 LOGE("NULL handle");
4699 return CAMERA_ERROR_INVALID_PARAMETER;
4704 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4706 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4708 LOGD("ret : 0x%x", ret);
4714 int camera_attr_enable_tag(camera_h camera, bool enable)
4716 int ret = CAMERA_ERROR_NONE;
4717 camera_cli_s *pc = (camera_cli_s *)camera;
4718 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4719 camera_msg_param param;
4720 int set_enable = (int)enable;
4722 if (!pc || !pc->cb_info) {
4723 LOGE("NULL handle");
4724 return CAMERA_ERROR_INVALID_PARAMETER;
4729 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4731 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4733 LOGD("ret : 0x%x", ret);
4739 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4741 int ret = CAMERA_ERROR_NONE;
4742 camera_cli_s *pc = (camera_cli_s *)camera;
4743 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4744 camera_msg_param param;
4746 if (!pc || !pc->cb_info || !description) {
4747 LOGE("NULL pointer %p %p", pc, description);
4748 return CAMERA_ERROR_INVALID_PARAMETER;
4753 CAMERA_MSG_PARAM_SET(param, STRING, description);
4755 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4757 LOGD("ret : 0x%x", ret);
4763 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4765 int ret = CAMERA_ERROR_NONE;
4766 camera_cli_s *pc = (camera_cli_s *)camera;
4767 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4768 camera_msg_param param;
4769 int set_orientation = (int)orientation;
4771 if (!pc || !pc->cb_info) {
4772 LOGE("NULL handle");
4773 return CAMERA_ERROR_INVALID_PARAMETER;
4778 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4780 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4782 LOGD("ret : 0x%x", ret);
4788 int camera_attr_set_tag_software(camera_h camera, const char *software)
4790 int ret = CAMERA_ERROR_NONE;
4791 camera_cli_s *pc = (camera_cli_s *)camera;
4792 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4793 camera_msg_param param;
4795 if (!pc || !pc->cb_info || !software) {
4796 LOGE("NULL pointer %p %p", pc, software);
4797 return CAMERA_ERROR_INVALID_PARAMETER;
4800 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4802 CAMERA_MSG_PARAM_SET(param, STRING, software);
4804 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4806 LOGD("ret : 0x%x", ret);
4812 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4814 int ret = CAMERA_ERROR_NONE;
4815 camera_cli_s *pc = (camera_cli_s *)camera;
4816 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4817 double set_geotag[3] = {latitude, longitude, altitude};
4822 if (!pc || !pc->cb_info) {
4823 LOGE("NULL handle");
4824 return CAMERA_ERROR_INVALID_PARAMETER;
4829 length = sizeof(set_geotag) / sizeof(int) + \
4830 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4832 msg = muse_core_msg_new(api,
4833 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4836 LOGE("msg creation failed: api %d", api);
4837 return CAMERA_ERROR_OUT_OF_MEMORY;
4840 if (pc->cb_info->is_server_connected) {
4841 __camera_update_api_waiting(pc->cb_info, api, 1);
4843 g_mutex_lock(&pc->cb_info->fd_lock);
4844 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
4845 g_mutex_unlock(&pc->cb_info->fd_lock);
4849 LOGE("message send failed");
4850 ret = CAMERA_ERROR_INVALID_OPERATION;
4852 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
4855 __camera_update_api_waiting(pc->cb_info, api, -1);
4857 muse_core_msg_free(msg);
4859 LOGD("ret : 0x%x", ret);
4865 int camera_attr_remove_geotag(camera_h camera)
4867 int ret = CAMERA_ERROR_NONE;
4868 camera_cli_s *pc = (camera_cli_s *)camera;
4869 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4871 if (!pc || !pc->cb_info) {
4872 LOGE("NULL handle");
4873 return CAMERA_ERROR_INVALID_PARAMETER;
4878 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4880 LOGD("ret : 0x%x", ret);
4886 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4888 int ret = CAMERA_ERROR_NONE;
4889 camera_cli_s *pc = (camera_cli_s *)camera;
4890 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
4891 camera_msg_param param;
4892 int set_mode = (int)mode;
4894 if (!pc || !pc->cb_info) {
4895 LOGE("NULL handle");
4896 return CAMERA_ERROR_INVALID_PARAMETER;
4901 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4903 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4905 LOGD("ret : 0x%x", ret);
4911 int camera_attr_get_zoom(camera_h camera, int *zoom)
4913 int ret = CAMERA_ERROR_NONE;
4914 camera_cli_s *pc = (camera_cli_s *)camera;
4915 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4917 if (!pc || !pc->cb_info || !zoom) {
4918 LOGE("NULL pointer %p %p", pc, zoom);
4919 return CAMERA_ERROR_INVALID_PARAMETER;
4924 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4926 if (ret == CAMERA_ERROR_NONE)
4927 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
4929 LOGD("ret : 0x%x", ret);
4935 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
4937 int ret = CAMERA_ERROR_NONE;
4938 camera_cli_s *pc = (camera_cli_s *)camera;
4939 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
4941 if (!pc || !pc->cb_info || !min || !max) {
4942 LOGE("NULL pointer %p %p %p", pc, min, max);
4943 return CAMERA_ERROR_INVALID_PARAMETER;
4948 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4950 if (ret == CAMERA_ERROR_NONE) {
4951 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
4952 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
4955 LOGD("ret : 0x%x", ret);
4961 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
4963 int ret = CAMERA_ERROR_NONE;
4964 camera_cli_s *pc = (camera_cli_s *)camera;
4965 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
4967 if (!pc || !pc->cb_info || !mode) {
4968 LOGE("NULL pointer %p %p", pc, mode);
4969 return CAMERA_ERROR_INVALID_PARAMETER;
4974 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4976 if (ret == CAMERA_ERROR_NONE)
4977 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
4979 LOGD("ret : 0x%x", ret);
4985 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
4987 int ret = CAMERA_ERROR_NONE;
4988 camera_cli_s *pc = (camera_cli_s *)camera;
4989 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
4991 if (!pc || !pc->cb_info || !mode) {
4992 LOGE("NULL pointer %p %p", pc, mode);
4993 return CAMERA_ERROR_INVALID_PARAMETER;
4998 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5000 if (ret == CAMERA_ERROR_NONE)
5001 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5003 LOGD("ret : 0x%x", ret);
5009 int camera_attr_get_exposure(camera_h camera, int *value)
5011 int ret = CAMERA_ERROR_NONE;
5012 camera_cli_s *pc = (camera_cli_s *)camera;
5013 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5015 if (!pc || !pc->cb_info || !value) {
5016 LOGE("NULL pointer %p %p", pc, value);
5017 return CAMERA_ERROR_INVALID_PARAMETER;
5022 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5024 if (ret == CAMERA_ERROR_NONE)
5025 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5027 LOGD("ret : 0x%x", ret);
5033 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5035 int ret = CAMERA_ERROR_NONE;
5036 camera_cli_s *pc = (camera_cli_s *)camera;
5037 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5039 if (!pc || !pc->cb_info || !min || !max) {
5040 LOGE("NULL pointer %p %p %p", pc, min, max);
5041 return CAMERA_ERROR_INVALID_PARAMETER;
5046 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5048 if (ret == CAMERA_ERROR_NONE) {
5049 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5050 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5053 LOGD("ret : 0x%x", ret);
5059 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5061 int ret = CAMERA_ERROR_NONE;
5062 camera_cli_s *pc = (camera_cli_s *)camera;
5063 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5065 if (!pc || !pc->cb_info || !iso) {
5066 LOGE("NULL pointer %p %p", pc, iso);
5067 return CAMERA_ERROR_INVALID_PARAMETER;
5072 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5074 if (ret == CAMERA_ERROR_NONE)
5075 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5077 LOGD("ret : 0x%x", ret);
5083 int camera_attr_get_brightness(camera_h camera, int *level)
5085 int ret = CAMERA_ERROR_NONE;
5086 camera_cli_s *pc = (camera_cli_s *)camera;
5087 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5089 if (!pc || !pc->cb_info || !level) {
5090 LOGE("NULL pointer %p %p", pc, level);
5091 return CAMERA_ERROR_INVALID_PARAMETER;
5096 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5098 if (ret == CAMERA_ERROR_NONE)
5099 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5101 LOGD("ret : 0x%x", ret);
5107 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5109 int ret = CAMERA_ERROR_NONE;
5110 camera_cli_s *pc = (camera_cli_s *)camera;
5111 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5113 if (!pc || !pc->cb_info || !min || !max) {
5114 LOGE("NULL pointer %p %p %p", pc, min, max);
5115 return CAMERA_ERROR_INVALID_PARAMETER;
5120 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5122 if (ret == CAMERA_ERROR_NONE) {
5123 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5124 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5127 LOGD("ret : 0x%x", ret);
5133 int camera_attr_get_contrast(camera_h camera, int *level)
5135 int ret = CAMERA_ERROR_NONE;
5136 camera_cli_s *pc = (camera_cli_s *)camera;
5137 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5139 if (!pc || !pc->cb_info || !level) {
5140 LOGE("NULL pointer %p %p", pc, level);
5141 return CAMERA_ERROR_INVALID_PARAMETER;
5146 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5148 if (ret == CAMERA_ERROR_NONE)
5149 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5151 LOGD("ret : 0x%x", ret);
5157 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5159 int ret = CAMERA_ERROR_NONE;
5160 camera_cli_s *pc = (camera_cli_s *)camera;
5161 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5163 if (!pc || !pc->cb_info || !min || !max) {
5164 LOGE("NULL pointer %p %p %p", pc, min, max);
5165 return CAMERA_ERROR_INVALID_PARAMETER;
5170 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5172 if (ret == CAMERA_ERROR_NONE) {
5173 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5174 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5175 LOGD("min %d, max %d", *min, *max);
5178 LOGD("ret : 0x%x", ret);
5184 int camera_attr_get_hue(camera_h camera, int *level)
5186 int ret = CAMERA_ERROR_NONE;
5187 camera_cli_s *pc = (camera_cli_s *)camera;
5188 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE;
5190 if (!pc || !pc->cb_info || !level) {
5191 LOGE("NULL pointer %p %p", pc, level);
5192 return CAMERA_ERROR_INVALID_PARAMETER;
5197 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5199 if (ret == CAMERA_ERROR_NONE)
5200 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HUE];
5202 LOGD("ret : 0x%x", ret);
5208 int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
5210 int ret = CAMERA_ERROR_NONE;
5211 camera_cli_s *pc = (camera_cli_s *)camera;
5212 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE_RANGE;
5214 if (!pc || !pc->cb_info || !min || !max) {
5215 LOGE("NULL pointer %p %p %p", pc, min, max);
5216 return CAMERA_ERROR_INVALID_PARAMETER;
5221 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5223 if (ret == CAMERA_ERROR_NONE) {
5224 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][0];
5225 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][1];
5226 LOGD("min %d, max %d", *min, *max);
5229 LOGD("ret : 0x%x", ret);
5235 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5237 int ret = CAMERA_ERROR_NONE;
5238 camera_cli_s *pc = (camera_cli_s *)camera;
5239 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5241 if (!pc || !pc->cb_info || !wb) {
5242 LOGE("NULL pointer %p %p", pc, wb);
5243 return CAMERA_ERROR_INVALID_PARAMETER;
5248 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5250 if (ret == CAMERA_ERROR_NONE)
5251 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5253 LOGD("ret : 0x%x", ret);
5259 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5261 int ret = CAMERA_ERROR_NONE;
5262 camera_cli_s *pc = (camera_cli_s *)camera;
5263 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5265 if (!pc || !pc->cb_info || !effect) {
5266 LOGE("NULL pointer %p %p", pc, effect);
5267 return CAMERA_ERROR_INVALID_PARAMETER;
5272 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5274 if (ret == CAMERA_ERROR_NONE)
5275 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5277 LOGD("ret : 0x%x", ret);
5283 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5285 int ret = CAMERA_ERROR_NONE;
5286 camera_cli_s *pc = (camera_cli_s *)camera;
5287 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5289 if (!pc || !pc->cb_info || !mode) {
5290 LOGE("NULL pointer %p %p", pc, mode);
5291 return CAMERA_ERROR_INVALID_PARAMETER;
5296 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5298 if (ret == CAMERA_ERROR_NONE)
5299 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5301 LOGD("ret : 0x%x", ret);
5307 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5309 int ret = CAMERA_ERROR_NONE;
5310 camera_cli_s *pc = (camera_cli_s *)camera;
5311 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5313 if (!pc || !pc->cb_info || !enable) {
5314 LOGE("NULL pointer %p %p", pc, enable);
5315 return CAMERA_ERROR_INVALID_PARAMETER;
5320 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5322 if (ret == CAMERA_ERROR_NONE)
5323 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5325 LOGD("ret : 0x%x", ret);
5331 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5333 int ret = CAMERA_ERROR_NONE;
5334 camera_cli_s *pc = (camera_cli_s *)camera;
5335 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5337 if (!pc || !pc->cb_info || !description) {
5338 LOGE("NULL pointer %p %p", pc, description);
5339 return CAMERA_ERROR_INVALID_PARAMETER;
5344 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5346 if (ret == CAMERA_ERROR_NONE)
5347 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5349 LOGD("ret : 0x%x", ret);
5355 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5357 int ret = CAMERA_ERROR_NONE;
5358 camera_cli_s *pc = (camera_cli_s *)camera;
5359 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5361 if (!pc || !pc->cb_info || !orientation) {
5362 LOGE("NULL pointer %p %p", pc, orientation);
5363 return CAMERA_ERROR_INVALID_PARAMETER;
5368 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5370 if (ret == CAMERA_ERROR_NONE)
5371 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5373 LOGD("ret : 0x%x", ret);
5379 int camera_attr_get_tag_software(camera_h camera, char **software)
5381 int ret = CAMERA_ERROR_NONE;
5382 camera_cli_s *pc = (camera_cli_s *)camera;
5383 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5385 if (!pc || !pc->cb_info || !software) {
5386 LOGE("NULL pointer %p %p", pc, software);
5387 return CAMERA_ERROR_INVALID_PARAMETER;
5392 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5394 if (ret == CAMERA_ERROR_NONE)
5395 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5397 LOGD("ret : 0x%x", ret);
5403 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5405 int ret = CAMERA_ERROR_NONE;
5406 camera_cli_s *pc = (camera_cli_s *)camera;
5407 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5409 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5410 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5411 return CAMERA_ERROR_INVALID_PARAMETER;
5416 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5418 if (ret == CAMERA_ERROR_NONE) {
5419 *latitude = pc->cb_info->get_geotag[0];
5420 *longitude = pc->cb_info->get_geotag[1];
5421 *altitude = pc->cb_info->get_geotag[2];
5424 LOGD("ret : 0x%x", ret);
5430 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5432 int ret = CAMERA_ERROR_NONE;
5433 camera_cli_s *pc = (camera_cli_s *)camera;
5434 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5436 if (!pc || !pc->cb_info || !mode) {
5437 LOGE("NULL pointer %p %p", pc, mode);
5438 return CAMERA_ERROR_INVALID_PARAMETER;
5443 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5445 if (ret == CAMERA_ERROR_NONE)
5446 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5448 LOGD("ret : 0x%x", ret);
5454 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5456 int ret = CAMERA_ERROR_NONE;
5457 int get_flash_state = 0;
5460 LOGE("NULL pointer");
5461 return CAMERA_ERROR_INVALID_PARAMETER;
5464 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5465 (int)device, "get_flash_state", &get_flash_state);
5467 if (ret == CAMERA_ERROR_NONE) {
5468 *state = (camera_flash_state_e)get_flash_state;
5469 LOGD("flash state %d", *state);
5471 LOGE("failed 0x%x", ret);
5478 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5480 int ret = CAMERA_ERROR_NONE;
5481 camera_cli_s *pc = (camera_cli_s *)camera;
5482 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5484 if (!pc || !pc->cb_info || !foreach_cb) {
5485 LOGE("NULL pointer %p %p", pc, foreach_cb);
5486 return CAMERA_ERROR_INVALID_PARAMETER;
5491 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5492 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5494 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5496 LOGD("ret : 0x%x", ret);
5502 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5504 int ret = CAMERA_ERROR_NONE;
5505 camera_cli_s *pc = (camera_cli_s *)camera;
5506 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5508 if (!pc || !pc->cb_info || !foreach_cb) {
5509 LOGE("NULL pointer %p %p", pc, foreach_cb);
5510 return CAMERA_ERROR_INVALID_PARAMETER;
5515 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5516 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5518 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5520 LOGD("ret : 0x%x", ret);
5526 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5528 int ret = CAMERA_ERROR_NONE;
5529 camera_cli_s *pc = (camera_cli_s *)camera;
5530 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5532 if (!pc || !pc->cb_info || !foreach_cb) {
5533 LOGE("NULL pointer %p %p", pc, foreach_cb);
5534 return CAMERA_ERROR_INVALID_PARAMETER;
5539 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5540 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5542 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5544 LOGD("ret : 0x%x", ret);
5550 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5552 int ret = CAMERA_ERROR_NONE;
5553 camera_cli_s *pc = (camera_cli_s *)camera;
5554 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5556 if (!pc || !pc->cb_info || !foreach_cb) {
5557 LOGE("NULL pointer %p %p", pc, foreach_cb);
5558 return CAMERA_ERROR_INVALID_PARAMETER;
5563 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5564 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5566 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5568 LOGD("ret : 0x%x", ret);
5574 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5576 int ret = CAMERA_ERROR_NONE;
5577 camera_cli_s *pc = (camera_cli_s *)camera;
5578 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5580 if (!pc || !pc->cb_info || !foreach_cb) {
5581 LOGE("NULL pointer %p %p", pc, foreach_cb);
5582 return CAMERA_ERROR_INVALID_PARAMETER;
5587 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5588 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5590 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5592 LOGD("ret : 0x%x", ret);
5598 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5600 int ret = CAMERA_ERROR_NONE;
5601 camera_cli_s *pc = (camera_cli_s *)camera;
5602 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5604 if (!pc || !pc->cb_info || !foreach_cb) {
5605 LOGE("NULL pointer %p %p", pc, foreach_cb);
5606 return CAMERA_ERROR_INVALID_PARAMETER;
5611 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5612 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5614 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5616 LOGD("ret : 0x%x", ret);
5622 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5624 int ret = CAMERA_ERROR_NONE;
5625 camera_cli_s *pc = (camera_cli_s *)camera;
5626 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5628 if (!pc || !pc->cb_info || !foreach_cb) {
5629 LOGE("NULL pointer %p %p", pc, foreach_cb);
5630 return CAMERA_ERROR_INVALID_PARAMETER;
5635 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5636 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5638 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5640 LOGD("ret : 0x%x", ret);
5646 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5648 int ret = CAMERA_ERROR_NONE;
5649 camera_cli_s *pc = (camera_cli_s *)camera;
5650 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5652 if (!pc || !pc->cb_info || !foreach_cb) {
5653 LOGE("NULL pointer %p %p", pc, foreach_cb);
5654 return CAMERA_ERROR_INVALID_PARAMETER;
5659 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5660 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5662 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5664 LOGD("Enter, handle :%x", pc->remote_handle);
5670 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)
5672 int ret = CAMERA_ERROR_NONE;
5673 camera_cli_s *pc = (camera_cli_s *)camera;
5674 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5675 camera_msg_param param;
5678 if (!pc || !pc->cb_info || !foreach_cb) {
5679 LOGE("NULL pointer %p %p", pc, foreach_cb);
5680 return CAMERA_ERROR_INVALID_PARAMETER;
5685 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5686 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5688 value = (width << 16) | height;
5689 CAMERA_MSG_PARAM_SET(param, INT, value);
5691 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5693 LOGD("ret : 0x%x", ret);
5699 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5701 int ret = CAMERA_ERROR_NONE;
5702 camera_cli_s *pc = (camera_cli_s *)camera;
5703 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5705 if (!pc || !pc->cb_info || !foreach_cb) {
5706 LOGE("NULL pointer %p %p", pc, foreach_cb);
5707 return CAMERA_ERROR_INVALID_PARAMETER;
5712 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5713 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5715 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5717 LOGD("ret : 0x%x", ret);
5723 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5725 int ret = CAMERA_ERROR_NONE;
5726 camera_cli_s *pc = (camera_cli_s *)camera;
5727 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5729 if (!pc || !pc->cb_info || !foreach_cb) {
5730 LOGE("NULL pointer %p %p", pc, foreach_cb);
5731 return CAMERA_ERROR_INVALID_PARAMETER;
5736 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5737 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5739 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5741 LOGD("ret : 0x%x", ret);
5747 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5749 int ret = CAMERA_ERROR_NONE;
5750 camera_cli_s *pc = (camera_cli_s *)camera;
5751 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5752 camera_msg_param param;
5753 int set_rotation = (int)rotation;
5755 if (!pc || !pc->cb_info) {
5756 LOGE("NULL handle");
5757 return CAMERA_ERROR_INVALID_PARAMETER;
5762 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5764 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5766 LOGD("ret : 0x%x", ret);
5772 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5774 int ret = CAMERA_ERROR_NONE;
5775 camera_cli_s *pc = (camera_cli_s *)camera;
5776 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5778 if (!pc || !pc->cb_info || !rotation) {
5779 LOGE("NULL pointer %p %p", pc, rotation);
5780 return CAMERA_ERROR_INVALID_PARAMETER;
5785 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5787 if (ret == CAMERA_ERROR_NONE)
5788 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5790 LOGD("ret : 0x%x", ret);
5796 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5798 int ret = CAMERA_ERROR_NONE;
5799 camera_cli_s *pc = (camera_cli_s *)camera;
5800 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5801 camera_msg_param param;
5802 int set_flip = (int)flip;
5804 if (!pc || !pc->cb_info) {
5805 LOGE("NULL handle");
5806 return CAMERA_ERROR_INVALID_PARAMETER;
5811 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5813 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5815 LOGD("ret : 0x%x", ret);
5821 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5823 int ret = CAMERA_ERROR_NONE;
5824 camera_cli_s *pc = (camera_cli_s *)camera;
5825 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5827 if (!pc || !pc->cb_info || !flip) {
5828 LOGE("NULL pointer %p %p", pc, flip);
5829 return CAMERA_ERROR_INVALID_PARAMETER;
5834 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5836 if (ret == CAMERA_ERROR_NONE)
5837 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5839 LOGD("ret : 0x%x", ret);
5844 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5846 int ret = CAMERA_ERROR_NONE;
5847 camera_cli_s *pc = (camera_cli_s *)camera;
5848 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5849 camera_msg_param param;
5850 int set_mode = (int)mode;
5852 if (!pc || !pc->cb_info) {
5853 LOGE("NULL handle");
5854 return CAMERA_ERROR_INVALID_PARAMETER;
5859 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5861 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5863 LOGD("ret : 0x%x", ret);
5869 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5871 int ret = CAMERA_ERROR_NONE;
5872 camera_cli_s *pc = (camera_cli_s *)camera;
5873 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5875 if (!pc || !pc->cb_info || !mode) {
5876 LOGE("NULL pointer %p %p", pc, mode);
5877 return CAMERA_ERROR_INVALID_PARAMETER;
5882 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5884 if (ret == CAMERA_ERROR_NONE)
5885 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
5887 LOGD("ret : 0x%x", ret);
5893 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5895 int ret = CAMERA_ERROR_NONE;
5896 camera_cli_s *pc = (camera_cli_s *)camera;
5897 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
5899 if (!pc || !pc->cb_info) {
5900 LOGE("NULL handle");
5901 return CAMERA_ERROR_INVALID_PARAMETER;
5906 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5909 LOGE("error is occurred 0x%x", ret);
5913 LOGD("ret : %d", ret);
5919 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5921 int ret = CAMERA_ERROR_NONE;
5922 camera_cli_s *pc = (camera_cli_s *)camera;
5923 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5925 if (!pc || !pc->cb_info) {
5926 LOGE("NULL handle");
5927 return CAMERA_ERROR_INVALID_PARAMETER;
5932 if (!camera_attr_is_supported_hdr_capture(camera)) {
5933 LOGE("HDR not supported");
5934 return CAMERA_ERROR_NOT_SUPPORTED;
5938 LOGE("NULL callback");
5939 return CAMERA_ERROR_INVALID_PARAMETER;
5942 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5944 if (ret == CAMERA_ERROR_NONE) {
5945 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5947 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5948 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5950 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5953 LOGD("ret : 0x%x", ret);
5959 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5961 int ret = CAMERA_ERROR_NONE;
5962 camera_cli_s *pc = (camera_cli_s *)camera;
5963 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5965 if (!pc || !pc->cb_info) {
5966 LOGE("NULL handle");
5967 return CAMERA_ERROR_INVALID_PARAMETER;
5972 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5974 if (ret == CAMERA_ERROR_NONE) {
5975 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5977 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5978 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5980 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5983 LOGD("ret : 0x%x", ret);
5989 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
5991 int ret = CAMERA_ERROR_NONE;
5992 camera_cli_s *pc = (camera_cli_s *)camera;
5993 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
5994 camera_msg_param param;
5995 int set_enable = (int)enable;
5997 if (!pc || !pc->cb_info) {
5998 LOGE("NULL handle");
5999 return CAMERA_ERROR_INVALID_PARAMETER;
6004 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6006 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6008 LOGD("ret : 0x%x", ret);
6014 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6016 int ret = CAMERA_ERROR_NONE;
6017 camera_cli_s *pc = (camera_cli_s *)camera;
6018 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6020 if (!pc || !pc->cb_info || !enabled) {
6021 LOGE("NULL pointer %p %p", pc, enabled);
6022 return CAMERA_ERROR_INVALID_PARAMETER;
6027 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6029 if (ret == CAMERA_ERROR_NONE)
6030 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6032 LOGD("ret : 0x%x", ret);
6038 bool camera_attr_is_supported_anti_shake(camera_h camera)
6040 int ret = CAMERA_ERROR_NONE;
6041 camera_cli_s *pc = (camera_cli_s *)camera;
6042 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6044 if (!pc || !pc->cb_info) {
6045 LOGE("NULL handle");
6046 return CAMERA_ERROR_INVALID_PARAMETER;
6051 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6054 LOGE("error is occurred 0x%x", ret);
6058 LOGD("ret : %d", ret);
6064 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6066 int ret = CAMERA_ERROR_NONE;
6067 camera_cli_s *pc = (camera_cli_s *)camera;
6068 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6069 camera_msg_param param;
6070 int set_enable = (int)enable;
6072 if (!pc || !pc->cb_info) {
6073 LOGE("NULL handle");
6074 return CAMERA_ERROR_INVALID_PARAMETER;
6079 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6081 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6083 LOGD("ret : 0x%x", ret);
6089 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6091 int ret = CAMERA_ERROR_NONE;
6092 camera_cli_s *pc = (camera_cli_s *)camera;
6093 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6095 if (!pc || !pc->cb_info || !enabled) {
6096 LOGE("NULL pointer %p %p", pc, enabled);
6097 return CAMERA_ERROR_INVALID_PARAMETER;
6102 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6104 if (ret == CAMERA_ERROR_NONE)
6105 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6107 LOGD("ret : 0x%x", ret);
6113 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6115 int ret = CAMERA_ERROR_NONE;
6116 camera_cli_s *pc = (camera_cli_s *)camera;
6117 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6119 if (!pc || !pc->cb_info) {
6120 LOGE("NULL handle");
6121 return CAMERA_ERROR_INVALID_PARAMETER;
6126 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6129 LOGE("error is occurred 0x%x", ret);
6133 LOGD("ret : %d", ret);
6139 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6141 int ret = CAMERA_ERROR_NONE;
6142 camera_cli_s *pc = (camera_cli_s *)camera;
6143 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6144 camera_msg_param param;
6145 int set_enable = (int)enable;
6147 if (!pc || !pc->cb_info) {
6148 LOGE("NULL handle");
6149 return CAMERA_ERROR_INVALID_PARAMETER;
6154 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6156 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6158 LOGD("ret : 0x%x", ret);
6164 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6166 int ret = CAMERA_ERROR_NONE;
6167 camera_cli_s *pc = (camera_cli_s *)camera;
6168 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6170 if (!pc || !pc->cb_info || !enabled) {
6171 LOGE("NULL pointer %p %p", pc, enabled);
6172 return CAMERA_ERROR_INVALID_PARAMETER;
6177 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6179 if (ret == CAMERA_ERROR_NONE)
6180 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6182 LOGD("ret : 0x%x", ret);
6188 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6190 int ret = CAMERA_ERROR_NONE;
6191 camera_cli_s *pc = (camera_cli_s *)camera;
6192 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6194 if (!pc || !pc->cb_info) {
6195 LOGE("NULL handle");
6196 return CAMERA_ERROR_INVALID_PARAMETER;
6201 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6204 LOGE("error is occurred 0x%x", ret);
6208 LOGD("ret : %d", ret);
6214 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6216 int ret = CAMERA_ERROR_NONE;
6217 camera_cli_s *pc = (camera_cli_s *)camera;
6218 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6219 camera_msg_param param;
6220 int set_disable = (int)disable;
6222 if (!pc || !pc->cb_info) {
6223 LOGE("NULL handle");
6224 return CAMERA_ERROR_INVALID_PARAMETER;
6229 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6231 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6233 LOGD("ret : 0x%x", ret);
6239 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6241 int ret = CAMERA_ERROR_NONE;
6242 camera_cli_s *pc = (camera_cli_s *)camera;
6243 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6244 camera_msg_param param;
6245 int set_move_type = (int)move_type;
6248 if (!pc || !pc->cb_info) {
6249 LOGE("NULL handle");
6250 return CAMERA_ERROR_INVALID_PARAMETER;
6255 value = (set_move_type << 16) | pan_step;
6256 CAMERA_MSG_PARAM_SET(param, INT, value);
6258 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6260 LOGD("ret : 0x%x", ret);
6266 int camera_attr_get_pan(camera_h camera, int *pan_step)
6268 int ret = CAMERA_ERROR_NONE;
6269 camera_cli_s *pc = (camera_cli_s *)camera;
6270 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6272 if (!pc || !pc->cb_info || !pan_step) {
6273 LOGE("NULL pointer %p %p", pc, pan_step);
6274 return CAMERA_ERROR_INVALID_PARAMETER;
6279 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6281 if (ret == CAMERA_ERROR_NONE)
6282 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6284 LOGD("ret : 0x%x", ret);
6290 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6292 int ret = CAMERA_ERROR_NONE;
6293 camera_cli_s *pc = (camera_cli_s *)camera;
6294 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6296 if (!pc || !pc->cb_info || !min || !max) {
6297 LOGE("NULL pointer %p %p %p", pc, min, max);
6298 return CAMERA_ERROR_INVALID_PARAMETER;
6303 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6305 if (ret == CAMERA_ERROR_NONE) {
6306 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6307 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6310 LOGD("ret : 0x%x", ret);
6316 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6318 int ret = CAMERA_ERROR_NONE;
6319 camera_cli_s *pc = (camera_cli_s *)camera;
6320 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6321 camera_msg_param param;
6322 int set_move_type = (int)move_type;
6325 if (!pc || !pc->cb_info) {
6326 LOGE("NULL handle");
6327 return CAMERA_ERROR_INVALID_PARAMETER;
6332 value = (set_move_type << 16) | tilt_step;
6333 CAMERA_MSG_PARAM_SET(param, INT, value);
6335 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6337 LOGD("ret : 0x%x", ret);
6343 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6345 int ret = CAMERA_ERROR_NONE;
6346 camera_cli_s *pc = (camera_cli_s *)camera;
6347 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6349 if (!pc || !pc->cb_info || !tilt_step) {
6350 LOGE("NULL pointer %p %p", pc, tilt_step);
6351 return CAMERA_ERROR_INVALID_PARAMETER;
6356 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6358 if (ret == CAMERA_ERROR_NONE)
6359 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6361 LOGD("ret : 0x%x", ret);
6367 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6369 int ret = CAMERA_ERROR_NONE;
6370 camera_cli_s *pc = (camera_cli_s *)camera;
6371 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6373 if (!pc || !pc->cb_info || !min || !max) {
6374 LOGE("NULL pointer %p %p %p", pc, min, max);
6375 return CAMERA_ERROR_INVALID_PARAMETER;
6380 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6382 if (ret == CAMERA_ERROR_NONE) {
6383 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6384 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6387 LOGD("ret : 0x%x", ret);
6393 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6395 int ret = CAMERA_ERROR_NONE;
6396 camera_cli_s *pc = (camera_cli_s *)camera;
6397 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6398 camera_msg_param param;
6399 int set_ptz_type = (int)ptz_type;
6401 if (!pc || !pc->cb_info) {
6402 LOGE("NULL handle");
6403 return CAMERA_ERROR_INVALID_PARAMETER;
6408 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6410 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6412 LOGD("ret : 0x%x", ret);
6418 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6420 int ret = CAMERA_ERROR_NONE;
6421 camera_cli_s *pc = (camera_cli_s *)camera;
6422 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6424 if (!pc || !pc->cb_info || !foreach_cb) {
6425 LOGE("NULL pointer %p %p", pc, foreach_cb);
6426 return CAMERA_ERROR_INVALID_PARAMETER;
6431 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6432 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6434 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6436 LOGD("ret : 0x%x", ret);
6442 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6444 int ret = CAMERA_ERROR_NONE;
6445 camera_cli_s *pc = (camera_cli_s *)camera;
6446 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6447 int set_display_roi_area[4] = {x, y, width, height};
6452 if (!pc || !pc->cb_info) {
6453 LOGE("NULL handle");
6454 return CAMERA_ERROR_INVALID_PARAMETER;
6459 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6460 ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
6461 if (ret != MM_ERROR_NONE) {
6462 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6463 return CAMERA_ERROR_INVALID_OPERATION;
6467 length = sizeof(set_display_roi_area) / sizeof(int) + \
6468 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6470 msg = muse_core_msg_new(api,
6471 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6474 LOGE("msg creation failed: api %d", api);
6475 return CAMERA_ERROR_OUT_OF_MEMORY;
6478 if (pc->cb_info->is_server_connected) {
6479 __camera_update_api_waiting(pc->cb_info, api, 1);
6481 g_mutex_lock(&pc->cb_info->fd_lock);
6482 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
6483 g_mutex_unlock(&pc->cb_info->fd_lock);
6487 LOGE("message send failed");
6488 ret = CAMERA_ERROR_INVALID_OPERATION;
6490 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6493 __camera_update_api_waiting(pc->cb_info, api, -1);
6495 muse_core_msg_free(msg);
6497 LOGD("ret : 0x%x", ret);
6503 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6505 camera_cli_s *pc = (camera_cli_s *)camera;
6506 int ret = CAMERA_ERROR_NONE;
6507 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6509 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6510 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6511 return CAMERA_ERROR_INVALID_PARAMETER;
6516 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6518 if (ret == CAMERA_ERROR_NONE) {
6519 *x = pc->cb_info->get_display_roi_area[0];
6520 *y = pc->cb_info->get_display_roi_area[1];
6521 *width = pc->cb_info->get_display_roi_area[2];
6522 *height = pc->cb_info->get_display_roi_area[3];
6525 LOGD("ret : 0x%x", ret);
6531 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6533 int ret = CAMERA_ERROR_NONE;
6534 int get_device_state = 0;
6537 LOGE("NULL pointer");
6538 return CAMERA_ERROR_INVALID_PARAMETER;
6541 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6542 (int)device, "get_device_state", &get_device_state);
6544 if (ret == CAMERA_ERROR_NONE) {
6545 *state = (camera_device_state_e)get_device_state;
6546 LOGD("device state %d", *state);
6548 LOGE("failed 0x%x", ret);
6555 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6557 int ret = CAMERA_ERROR_NONE;
6558 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6559 camera_cb_info *info = NULL;
6561 if (!callback || !cb_id) {
6562 LOGE("invalid pointer %p %p", callback, cb_id);
6563 return CAMERA_ERROR_INVALID_PARAMETER;
6566 /* check camera support */
6567 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6568 if (ret != CAMERA_ERROR_NONE) {
6569 LOGE("get device state failed");
6573 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6575 info = g_new0(camera_cb_info, 1);
6577 LOGE("info failed");
6578 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6582 info->id = ++g_cam_dev_state_changed_cb_id;
6583 info->callback = (void *)callback;
6584 info->user_data = user_data;
6588 /* subscribe dbus signal for camera state change */
6589 if (!g_cam_dev_state_changed_cb_conn) {
6590 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6591 if (!g_cam_dev_state_changed_cb_conn) {
6592 LOGE("failed to get gdbus connection");
6593 ret = CAMERA_ERROR_INVALID_OPERATION;
6597 LOGD("subscribe signal %s - %s - %s",
6598 MM_CAMCORDER_DBUS_OBJECT,
6599 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6600 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6602 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6603 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6604 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6605 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6606 LOGE("failed to get gdbus connection");
6607 ret = CAMERA_ERROR_INVALID_OPERATION;
6611 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6614 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6616 LOGD("callback id %d", info->id);
6619 if (ret != CAMERA_ERROR_NONE) {
6625 if (g_cam_dev_state_changed_cb_conn) {
6626 g_object_unref(g_cam_dev_state_changed_cb_conn);
6627 g_cam_dev_state_changed_cb_conn = NULL;
6631 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6637 int camera_remove_device_state_changed_cb(int cb_id)
6639 int ret = CAMERA_ERROR_NONE;
6640 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6641 GList *tmp_list = NULL;
6642 camera_cb_info *info = NULL;
6644 /* check camera support */
6645 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6646 if (ret != CAMERA_ERROR_NONE) {
6647 LOGE("get device state failed");
6651 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6653 if (!g_cam_dev_state_changed_cb_list) {
6654 LOGE("there is no callback info");
6655 ret = CAMERA_ERROR_INVALID_OPERATION;
6659 tmp_list = g_cam_dev_state_changed_cb_list;
6662 info = tmp_list->data;
6663 tmp_list = tmp_list->next;
6670 if (info->id == cb_id) {
6671 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6676 if (!g_cam_dev_state_changed_cb_list) {
6677 /* no remained callback */
6678 if (g_cam_dev_state_changed_cb_conn) {
6679 /* unsubscribe signal */
6680 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6681 g_cam_dev_state_changed_cb_subscribe_id = 0;
6683 /* unref connection */
6684 g_object_unref(g_cam_dev_state_changed_cb_conn);
6685 g_cam_dev_state_changed_cb_conn = NULL;
6689 LOGD("id %d callback removed", cb_id);
6690 ret = CAMERA_ERROR_NONE;
6696 LOGE("id %d callback not found", cb_id);
6697 ret = CAMERA_ERROR_INVALID_PARAMETER;
6700 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);