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;
692 case MM_PIXEL_FORMAT_NV16:
693 *out_format = TBM_FORMAT_NV16;
695 case MM_PIXEL_FORMAT_NV21:
696 *out_format = TBM_FORMAT_NV21;
698 case MM_PIXEL_FORMAT_YUYV:
699 *out_format = TBM_FORMAT_YUYV;
701 case MM_PIXEL_FORMAT_UYVY:
702 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
703 *out_format = TBM_FORMAT_UYVY;
705 case MM_PIXEL_FORMAT_422P:
706 *out_format = TBM_FORMAT_YUV422;
708 case MM_PIXEL_FORMAT_I420:
709 *out_format = TBM_FORMAT_YUV420;
711 case MM_PIXEL_FORMAT_YV12:
712 *out_format = TBM_FORMAT_YVU420;
714 case MM_PIXEL_FORMAT_RGB565:
715 *out_format = TBM_FORMAT_RGB565;
717 case MM_PIXEL_FORMAT_RGB888:
718 *out_format = TBM_FORMAT_RGB888;
720 case MM_PIXEL_FORMAT_RGBA:
721 *out_format = TBM_FORMAT_RGBA8888;
723 case MM_PIXEL_FORMAT_ARGB:
724 *out_format = TBM_FORMAT_ARGB8888;
727 LOGE("invalid in_format %d", in_format);
728 return CAMERA_ERROR_INVALID_PARAMETER;
732 return CAMERA_ERROR_NONE;
736 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
738 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
739 in_format >= MM_PIXEL_FORMAT_NUM ||
741 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
742 return CAMERA_ERROR_INVALID_PARAMETER;
746 case MM_PIXEL_FORMAT_NV12:
747 case MM_PIXEL_FORMAT_NV12T:
748 *mimetype = MEDIA_FORMAT_NV12;
751 case MM_PIXEL_FORMAT_NV16:
752 *mimetype = MEDIA_FORMAT_NV16;
754 case MM_PIXEL_FORMAT_NV21:
755 *mimetype = MEDIA_FORMAT_NV21;
757 case MM_PIXEL_FORMAT_YUYV:
758 *mimetype = MEDIA_FORMAT_YUYV;
760 case MM_PIXEL_FORMAT_UYVY:
761 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
762 *mimetype = MEDIA_FORMAT_UYVY;
764 case MM_PIXEL_FORMAT_422P:
765 *mimetype = MEDIA_FORMAT_422P;
767 case MM_PIXEL_FORMAT_I420:
768 *mimetype = MEDIA_FORMAT_I420;
770 case MM_PIXEL_FORMAT_YV12:
771 *mimetype = MEDIA_FORMAT_YV12;
773 case MM_PIXEL_FORMAT_RGB565:
774 *mimetype = MEDIA_FORMAT_RGB565;
776 case MM_PIXEL_FORMAT_RGB888:
777 *mimetype = MEDIA_FORMAT_RGB888;
779 case MM_PIXEL_FORMAT_RGBA:
780 *mimetype = MEDIA_FORMAT_RGBA;
782 case MM_PIXEL_FORMAT_ARGB:
783 *mimetype = MEDIA_FORMAT_ARGB;
786 LOGE("invalid in_format %d", in_format);
787 return CAMERA_ERROR_INVALID_PARAMETER;
791 return CAMERA_ERROR_NONE;
794 static void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_key,
795 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame)
798 unsigned char *buf_pos = NULL;
800 if (stream == NULL || buffer_bo_handle == NULL || frame == NULL) {
801 LOGE("invalid parameter - stream:%p, buffer_bo_handle:%p", stream, buffer_bo_handle);
806 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
807 frame->format = MM_PIXEL_FORMAT_UYVY;
809 frame->format = stream->format;
811 frame->width = stream->width;
812 frame->height = stream->height;
813 frame->timestamp = stream->timestamp;
814 frame->num_of_planes = stream->num_planes;
816 if (num_buffer_key == 0) {
819 if (!data_bo_handle || !data_bo_handle->ptr) {
820 LOGE("NULL pointer");
824 buf_pos = data_bo_handle->ptr;
826 if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) {
827 frame->data.encoded_plane.data = buf_pos;
828 frame->data.encoded_plane.size = stream->data.encoded.length_data;
829 total_size = stream->data.encoded.length_data;
831 switch (stream->num_planes) {
833 frame->data.single_plane.yuv = buf_pos;
834 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
835 total_size = stream->data.yuv420.length_yuv;
838 frame->data.double_plane.y = buf_pos;
839 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
840 buf_pos += stream->data.yuv420sp.length_y;
841 frame->data.double_plane.uv = buf_pos;
842 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
843 total_size = stream->data.yuv420sp.length_y + \
844 stream->data.yuv420sp.length_uv;
847 frame->data.triple_plane.y = buf_pos;
848 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
849 buf_pos += stream->data.yuv420p.length_y;
850 frame->data.triple_plane.u = buf_pos;
851 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
852 buf_pos += stream->data.yuv420p.length_u;
853 frame->data.triple_plane.v = buf_pos;
854 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
855 total_size = stream->data.yuv420p.length_y + \
856 stream->data.yuv420p.length_u + \
857 stream->data.yuv420p.length_v;
866 switch (stream->num_planes) {
869 frame->data.single_plane.yuv = buffer_bo_handle[0].ptr;
870 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
871 total_size = stream->data.yuv420.length_yuv;
875 frame->data.double_plane.y = buffer_bo_handle[0].ptr;
876 if (stream->num_planes == (unsigned int)num_buffer_key)
877 frame->data.double_plane.uv = buffer_bo_handle[1].ptr;
879 frame->data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
880 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
881 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
882 total_size = stream->data.yuv420sp.length_y + \
883 stream->data.yuv420sp.length_uv;
887 frame->data.triple_plane.y = buffer_bo_handle[0].ptr;
888 if (stream->num_planes == (unsigned int)num_buffer_key) {
889 frame->data.triple_plane.u = buffer_bo_handle[1].ptr;
890 frame->data.triple_plane.v = buffer_bo_handle[2].ptr;
892 frame->data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y;
893 frame->data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u;
895 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
896 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
897 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
898 total_size = stream->data.yuv420p.length_y + \
899 stream->data.yuv420p.length_u + \
900 stream->data.yuv420p.length_v;
909 LOGD("format %d, %dx%d, size %d plane num %d",
910 frame.format, frame.width, frame.height, total_size, frame.num_of_planes);
916 static int _camera_media_packet_data_create(int tbm_key, int num_buffer_key, tbm_bo bo,
917 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
920 int ret = CAMERA_ERROR_NONE;
921 camera_media_packet_data *tmp_mp_data = NULL;
923 if (*mp_data == NULL) {
924 tmp_mp_data = g_new0(camera_media_packet_data, 1);
926 tmp_mp_data->tbm_key = tbm_key;
927 tmp_mp_data->num_buffer_key = num_buffer_key;
928 tmp_mp_data->bo = bo;
929 tmp_mp_data->data_bo = data_bo;
930 tmp_mp_data->ref_cnt++;
932 for (i = 0 ; i < num_buffer_key ; i++)
933 tmp_mp_data->buffer_bo[i] = buffer_bo[i];
935 *mp_data = tmp_mp_data;
936 /*LOGD("mp_data %p", tmp_mp_data);*/
938 ret = CAMERA_ERROR_OUT_OF_MEMORY;
939 LOGE("failed to alloc media packet data");
942 ((camera_media_packet_data *)*mp_data)->ref_cnt++;
948 static void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
952 camera_msg_param param;
954 if (!mp_data || !cb_info) {
955 LOGE("NULL pointer %p %p", mp_data, cb_info);
959 if (mp_data->ref_cnt > 1) {
961 LOGD("ref count %d", mp_data->ref_cnt);
963 /* release imported bo */
964 for (i = 0 ; i < mp_data->num_buffer_key ; i++) {
965 tbm_bo_unref(mp_data->buffer_bo[i]);
966 mp_data->buffer_bo[i] = NULL;
970 _camera_release_imported_bo(&mp_data->bo);
971 _camera_release_imported_bo(&mp_data->data_bo);
974 tbm_key = mp_data->tbm_key;
976 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
978 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
987 static int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
988 camera_media_packet_data *mp_data, media_packet_h *packet)
990 media_packet_h pkt = NULL;
991 bool make_pkt_fmt = false;
992 tbm_surface_h tsurf = NULL;
993 tbm_surface_info_s tsurf_info;
994 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
995 uint32_t bo_format = 0;
998 int num_buffer_key = 0;
999 tbm_bo *buffer_bo = NULL;
1001 if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) {
1002 LOGE("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p",
1003 cb_info, stream, mp_data, packet);
1004 return CAMERA_ERROR_INVALID_PARAMETER;
1007 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
1008 buffer_bo = mp_data->buffer_bo;
1009 num_buffer_key = mp_data->num_buffer_key;
1011 /* create tbm surface */
1012 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
1013 tsurf_info.planes[i].stride = stream->stride[i];
1015 /* get tbm surface format */
1016 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
1017 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
1019 if (ret == CAMERA_ERROR_NONE) {
1020 tsurf_info.width = stream->width;
1021 tsurf_info.height = stream->height;
1022 tsurf_info.format = bo_format;
1023 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
1024 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
1026 if (num_buffer_key > 0) {
1027 switch (bo_format) {
1028 case TBM_FORMAT_NV12:
1029 case TBM_FORMAT_NV21:
1030 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1031 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
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.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1038 case TBM_FORMAT_YUV420:
1039 case TBM_FORMAT_YVU420:
1040 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1041 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1042 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
1043 tsurf_info.planes[0].offset = 0;
1044 if (num_buffer_key == 1) {
1045 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1046 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1048 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1050 case TBM_FORMAT_UYVY:
1051 case TBM_FORMAT_YUYV:
1052 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
1053 tsurf_info.planes[0].offset = 0;
1054 tsurf_info.size = tsurf_info.planes[0].size;
1061 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_key);
1062 } else if (mp_data->data_bo) {
1064 switch (bo_format) {
1065 case TBM_FORMAT_NV12:
1066 case TBM_FORMAT_NV21:
1067 tsurf_info.planes[0].size = stream->width * stream->height;
1068 tsurf_info.planes[1].size = (tsurf_info.planes[0].size) >> 1;
1069 tsurf_info.planes[0].offset = 0;
1070 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1071 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1073 case TBM_FORMAT_YUV420:
1074 case TBM_FORMAT_YVU420:
1075 tsurf_info.planes[0].size = stream->width * stream->height;
1076 tsurf_info.planes[1].size = (stream->width >> 1) * (stream->height >> 1);
1077 tsurf_info.planes[2].size = tsurf_info.planes[1].size;
1078 tsurf_info.planes[0].offset = 0;
1079 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1080 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1081 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1083 case TBM_FORMAT_UYVY:
1084 case TBM_FORMAT_YUYV:
1085 tsurf_info.planes[0].size = (stream->width * stream->height) << 1;
1086 tsurf_info.planes[0].offset = 0;
1087 tsurf_info.size = tsurf_info.planes[0].size;
1093 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1);
1096 /*LOGD("tbm surface %p", tsurf);*/
1100 /* check media packet format */
1101 if (cb_info->pkt_fmt) {
1102 int pkt_fmt_width = 0;
1103 int pkt_fmt_height = 0;
1104 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
1106 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
1107 if (pkt_fmt_mimetype != mimetype ||
1108 pkt_fmt_width != stream->width ||
1109 pkt_fmt_height != stream->height) {
1110 LOGW("change fmt: current 0x%x, %dx%d",
1111 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
1112 media_format_unref(cb_info->pkt_fmt);
1113 cb_info->pkt_fmt = NULL;
1114 make_pkt_fmt = true;
1117 make_pkt_fmt = true;
1120 /* create packet format */
1122 LOGW("make new pkt_fmt - 0x%x, %dx%d", mimetype, stream->width, stream->height);
1123 ret = media_format_create(&cb_info->pkt_fmt);
1124 if (ret == MEDIA_FORMAT_ERROR_NONE) {
1125 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
1126 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
1127 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
1128 LOGW("media_format_set : 0x%x", ret);
1130 LOGW("media_format_create failed 0x%x", ret);
1134 /* create media packet */
1135 ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt,
1136 tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
1137 (void *)cb_info, &pkt);
1138 if (ret != MEDIA_PACKET_ERROR_NONE) {
1139 LOGE("media_packet_create failed 0x%x", ret);
1140 tbm_surface_destroy(tsurf);
1144 LOGE("tbm surface failed. %dx%d, format %d, num_buffer_key %d, data_bo %p",
1145 stream->width, stream->height, stream->format, num_buffer_key, mp_data->data_bo);
1149 /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
1150 /* set media packet data */
1151 ret = media_packet_set_extra(pkt, (void *)mp_data);
1152 if (ret != MEDIA_PACKET_ERROR_NONE) {
1153 LOGE("media_packet_set_extra failed");
1155 _camera_media_packet_data_release(mp_data, cb_info);
1158 media_packet_destroy(pkt);
1161 /* set timestamp : msec -> nsec */
1162 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
1163 LOGW("media_packet_set_pts failed");
1172 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
1175 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1176 camera_media_packet_data *mp_data = NULL;
1177 tbm_surface_h tsurf = NULL;
1179 if (!pkt || !cb_info) {
1180 LOGE("NULL pointer %p %p", pkt, cb_info);
1181 return MEDIA_PACKET_FINALIZE;
1184 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1185 if (ret != MEDIA_PACKET_ERROR_NONE) {
1186 LOGE("media_packet_get_extra failed 0x%x", ret);
1187 return MEDIA_PACKET_FINALIZE;
1190 /*LOGD("mp_data %p", mp_data);*/
1192 g_mutex_lock(&cb_info->mp_data_mutex);
1194 _camera_media_packet_data_release(mp_data, cb_info);
1197 g_mutex_unlock(&cb_info->mp_data_mutex);
1199 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1200 if (ret != MEDIA_PACKET_ERROR_NONE)
1201 LOGE("get tbm_surface failed 0x%x", ret);
1204 tbm_surface_destroy(tsurf);
1208 return MEDIA_PACKET_FINALIZE;
1211 static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event)
1216 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1217 LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event);
1221 /*LOGD("get camera msg %s, event %d", recv_msg, event);*/
1223 g_mutex_lock(&cb_info->user_cb_mutex[event]);
1225 if (cb_info->user_cb[event] == NULL) {
1226 if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
1227 event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
1228 event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
1229 event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1230 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1231 LOGW("NULL callback for event %d, return here", event);
1235 /* return buffer message should be sent for some events.
1236 - MUSE_CAMERA_EVENT_TYPE_PREVIEW
1237 - MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW
1238 - MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION
1239 - MUSE_CAMERA_EVENT_TYPE_CAPTURE
1244 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1250 muse_camera_msg_get(previous, recv_msg);
1251 muse_camera_msg_get(current, recv_msg);
1252 muse_camera_msg_get(by_policy, recv_msg);
1254 LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
1255 previous, current, by_policy);
1257 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1258 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1261 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1265 muse_camera_msg_get(state, recv_msg);
1267 LOGD("FOCUS state - %d", state);
1269 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1272 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1273 LOGD("CAPTURE_COMPLETED");
1274 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1276 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1277 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1278 __camera_event_handler_preview(cb_info, recv_msg);
1281 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1285 muse_camera_msg_get(percent, recv_msg);
1287 LOGD("HDR progress - %d %%", percent);
1289 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1292 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1298 muse_camera_msg_get(policy, recv_msg);
1299 muse_camera_msg_get(previous, recv_msg);
1300 muse_camera_msg_get(current, recv_msg);
1302 LOGW("INTERRUPTED - policy %d, state previous %d, current %d",
1303 policy, previous, current);
1305 if (policy == CAMERA_POLICY_SOUND)
1306 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND is deprecated and will be removed from next release.");
1307 else if (policy == CAMERA_POLICY_SOUND_BY_CALL)
1308 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_CALL is deprecated and will be removed from next release.");
1309 else if (policy == CAMERA_POLICY_SOUND_BY_ALARM)
1310 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_ALARM is deprecated and will be removed from next release.");
1312 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1313 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1316 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1321 muse_camera_msg_get(policy, recv_msg);
1322 muse_camera_msg_get(state, recv_msg);
1324 LOGW("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1326 if (policy == CAMERA_POLICY_SOUND)
1327 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND is deprecated and will be removed from next release.");
1328 else if (policy == CAMERA_POLICY_SOUND_BY_CALL)
1329 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_CALL is deprecated and will be removed from next release.");
1330 else if (policy == CAMERA_POLICY_SOUND_BY_ALARM)
1331 LOGW("DEPRECATION WARNING: CAMERA_POLICY_SOUND_BY_ALARM is deprecated and will be removed from next release.");
1333 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1334 (camera_state_e)state, cb_info->user_data[event]);
1337 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1338 __camera_event_handler_face_detection(cb_info, recv_msg);
1340 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1343 int current_state = 0;
1345 muse_camera_msg_get(error, recv_msg);
1346 muse_camera_msg_get(current_state, recv_msg);
1348 LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
1350 if (error == CAMERA_ERROR_SOUND_POLICY)
1351 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY is deprecated and will be removed from next release.");
1352 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_CALL)
1353 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_CALL is deprecated and will be removed from next release.");
1354 else if (error == CAMERA_ERROR_SOUND_POLICY_BY_ALARM)
1355 LOGW("DEPRECATION WARNING: CAMERA_ERROR_SOUND_POLICY_BY_ALARM is deprecated and will be removed from next release.");
1357 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1358 (camera_state_e)current_state, cb_info->user_data[event]);
1362 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1364 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1365 muse_camera_msg_get(param1, recv_msg);
1366 muse_camera_msg_get(param2, recv_msg);
1368 /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/
1370 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1371 cb_info->user_cb[event] = NULL;
1372 cb_info->user_data[event] = NULL;
1373 LOGW("stop foreach callback for event %d", event);
1376 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1378 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1380 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1382 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1384 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1386 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1388 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1390 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1392 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1394 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1396 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1398 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1400 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1403 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1405 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1406 muse_camera_msg_get(param1, recv_msg);
1408 /*LOGD("event %d SUPPORTED %d ", event, param1);*/
1410 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1411 cb_info->user_cb[event] = NULL;
1412 cb_info->user_data[event] = NULL;
1413 LOGW("stop foreach callback for event %d", event);
1417 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1418 __camera_event_handler_capture(cb_info, recv_msg);
1421 LOGW("unhandled event %d", event);
1425 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1430 static bool _camera_idle_event_callback(void *data)
1432 camera_cb_info_s *cb_info = NULL;
1433 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1435 if (cam_idle_event == NULL) {
1436 LOGE("cam_idle_event is NULL");
1441 g_mutex_lock(&cam_idle_event->event_mutex);
1443 cb_info = cam_idle_event->cb_info;
1444 if (cb_info == NULL) {
1445 LOGW("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1446 goto IDLE_EVENT_CALLBACK_DONE;
1449 /* remove event from list */
1450 g_mutex_lock(&cb_info->idle_event_mutex);
1452 if (cb_info->idle_event_list)
1453 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1455 /*LOGD("remove camera idle event %p, %p", cam_idle_event, cb_info->idle_event_list);*/
1456 g_mutex_unlock(&cb_info->idle_event_mutex);
1459 _camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
1461 /* send signal for waiting thread */
1462 g_cond_signal(&cb_info->idle_event_cond);
1464 IDLE_EVENT_CALLBACK_DONE:
1465 /* unlock and release event */
1466 g_mutex_unlock(&cam_idle_event->event_mutex);
1467 g_mutex_clear(&cam_idle_event->event_mutex);
1469 g_free(cam_idle_event);
1470 cam_idle_event = NULL;
1475 static void *_camera_msg_handler_func(gpointer data)
1479 camera_message_s *cam_msg = NULL;
1480 camera_idle_event_s *cam_idle_event = NULL;
1481 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1482 camera_cb_info_s *cb_info = NULL;
1484 if (!handler_info || !handler_info->cb_info) {
1485 LOGE("NULL handler %p", handler_info);
1489 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1490 type = handler_info->type;
1492 LOGD("t:%d start", type);
1494 g_mutex_lock(&handler_info->mutex);
1496 while (g_atomic_int_get(&handler_info->running)) {
1497 if (g_queue_is_empty(handler_info->queue)) {
1498 /*LOGD("t:%d signal wait...", type);*/
1499 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1500 /*LOGD("t:%d signal received", type);*/
1502 if (g_atomic_int_get(&handler_info->running) == 0) {
1503 LOGD("t:%d stop event thread", type);
1508 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1510 g_mutex_unlock(&handler_info->mutex);
1512 if (cam_msg == NULL) {
1513 LOGE("t:%d NULL message", type);
1514 g_mutex_lock(&handler_info->mutex);
1520 if (api < MUSE_CAMERA_API_MAX) {
1523 g_mutex_lock(&cb_info->api_mutex[api]);
1525 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1526 if (cb_info->api_waiting[api] > 0) {
1527 cb_info->api_ret[api] = ret;
1528 cb_info->api_activating[api] = 1;
1530 /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
1532 g_cond_signal(&cb_info->api_cond[api]);
1534 LOGW("no waiting for this api [%d]", api);
1537 LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1540 g_mutex_unlock(&cb_info->api_mutex[api]);
1541 } else if (api == MUSE_CAMERA_CB_EVENT) {
1542 switch (cam_msg->event_class) {
1543 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1544 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event);
1546 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1547 cam_idle_event = g_new0(camera_idle_event_s, 1);
1548 if (cam_idle_event == NULL) {
1549 LOGE("t:%d cam_idle_event alloc failed", type);
1553 cam_idle_event->event = cam_msg->event;
1554 cam_idle_event->cb_info = cb_info;
1555 g_mutex_init(&cam_idle_event->event_mutex);
1556 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg) - 1);
1558 /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, cam_msg->event, cam_idle_event);*/
1560 g_mutex_lock(&cb_info->idle_event_mutex);
1561 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1562 g_mutex_unlock(&cb_info->idle_event_mutex);
1564 g_idle_add_full(G_PRIORITY_DEFAULT,
1565 (GSourceFunc)_camera_idle_event_callback,
1566 (gpointer)cam_idle_event,
1570 LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
1574 LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1580 g_mutex_lock(&handler_info->mutex);
1583 /* remove remained event */
1584 while (!g_queue_is_empty(handler_info->queue)) {
1585 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1587 LOGD("t:%d remove camera message %p", type, cam_msg);
1591 LOGW("t:%d NULL camera message", type);
1595 g_mutex_unlock(&handler_info->mutex);
1597 LOGD("t:%d return", type);
1603 static void _camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1605 camera_idle_event_s *cam_idle_event = NULL;
1607 gint64 end_time = 0;
1609 if (cb_info == NULL) {
1610 LOGE("cb_info is NULL");
1614 g_mutex_lock(&cb_info->idle_event_mutex);
1616 if (cb_info->idle_event_list == NULL) {
1617 LOGD("No remained idle event");
1618 g_mutex_unlock(&cb_info->idle_event_mutex);
1622 list = cb_info->idle_event_list;
1625 cam_idle_event = list->data;
1626 list = g_list_next(list);
1628 if (!cam_idle_event) {
1629 LOGW("Fail to remove idle event. The event is NULL");
1633 if (g_idle_remove_by_data(cam_idle_event)) {
1634 LOGW("remove idle event %p done", cam_idle_event);
1636 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1638 g_mutex_clear(&cam_idle_event->event_mutex);
1639 g_free(cam_idle_event);
1640 cam_idle_event = NULL;
1645 LOGW("remove idle event %p failed", cam_idle_event);
1647 if (!g_mutex_trylock(&cam_idle_event->event_mutex)) {
1648 LOGW("lock failed, %p event is calling now", cam_idle_event);
1650 end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
1652 if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
1653 LOGW("signal received");
1660 LOGW("set NULL cb_info for event %p %d, it will be freed on idle callback",
1661 cam_idle_event, cam_idle_event->event);
1663 cam_idle_event->cb_info = NULL;
1665 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1667 g_mutex_unlock(&cam_idle_event->event_mutex);
1670 g_list_free(cb_info->idle_event_list);
1671 cb_info->idle_event_list = NULL;
1673 g_mutex_unlock(&cb_info->idle_event_mutex);
1679 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg)
1681 camera_message_s *cam_msg = NULL;
1683 if (!cb_info || !msg) {
1684 LOGE("NULL pointer %p %p", cb_info, msg);
1688 cam_msg = g_new0(camera_message_s, 1);
1690 LOGE("failed to alloc cam_msg for [%s]", msg);
1695 cam_msg->event = event;
1696 cam_msg->event_class = event_class;
1698 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1700 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1702 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1703 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1704 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1705 g_cond_signal(&cb_info->preview_cb_info.cond);
1706 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1707 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1708 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1709 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1710 g_cond_signal(&cb_info->capture_cb_info.cond);
1711 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1713 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1714 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1715 g_cond_signal(&cb_info->msg_handler_info.cond);
1716 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1725 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg)
1727 int ret = CAMERA_ERROR_NONE;
1731 int event_class = -1;
1735 if (!cb_info || !msg) {
1736 LOGE("invalid ptr %p %p", cb_info, msg);
1740 /*LOGD("msg [%s]", msg);*/
1742 if (!muse_camera_msg_get(api, msg)) {
1743 LOGE("failed to get camera api");
1747 if (api == MUSE_CAMERA_CB_EVENT) {
1748 if (!muse_camera_msg_get(event, msg) ||
1749 !muse_camera_msg_get(event_class, msg)) {
1750 LOGE("failed to get camera event or event_class [%s]", msg);
1754 if (!muse_camera_msg_get(api_class, msg)) {
1755 LOGE("failed to get camera api_class [%s]", msg);
1760 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1761 if (api >= MUSE_CAMERA_API_MAX) {
1762 LOGE("invalid api %d", api);
1766 if (!muse_camera_msg_get(ret, msg)) {
1767 LOGE("failed to get camera ret");
1771 g_mutex_lock(&cb_info->api_mutex[api]);
1774 case MUSE_CAMERA_API_CREATE:
1775 if (ret != CAMERA_ERROR_NONE) {
1776 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1777 LOGE("camera create error 0x%x. close client cb handler", ret);
1780 case MUSE_CAMERA_API_DESTROY:
1781 if (ret == CAMERA_ERROR_NONE) {
1782 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1783 LOGD("camera destroy done. close client cb handler");
1787 muse_camera_msg_get(get_type, msg);
1788 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1789 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1790 muse_camera_msg_get(get_index, msg);
1793 case MUSE_CAMERA_GET_TYPE_INT:
1794 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
1796 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1797 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
1798 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
1800 case MUSE_CAMERA_GET_TYPE_ARRAY:
1801 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
1802 muse_core_msg_deserialize("get_value",
1803 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
1804 LOGD("get display roi %d,%d,%dx%d",
1805 cb_info->get_display_roi_area[0],
1806 cb_info->get_display_roi_area[1],
1807 cb_info->get_display_roi_area[2],
1808 cb_info->get_display_roi_area[3]);
1810 muse_core_msg_deserialize("get_value",
1811 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
1812 LOGD("get geotag %lf, %lf, %lf",
1813 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
1816 case MUSE_CAMERA_GET_TYPE_STRING:
1817 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
1820 LOGW("unknown type %d", get_type);
1827 if (cb_info->api_waiting[api] > 0) {
1828 cb_info->api_ret[api] = ret;
1829 cb_info->api_activating[api] = 1;
1831 g_cond_signal(&cb_info->api_cond[api]);
1833 LOGW("no waiting for this api [%d]", api);
1836 g_mutex_unlock(&cb_info->api_mutex[api]);
1837 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
1838 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg);
1840 LOGW("unknown camera api %d, class %d", api, api_class);
1847 static void *_camera_msg_recv_func(gpointer data)
1849 int recv_length = 0;
1850 int single_length = 0;
1851 int remained_length = 0;
1852 char *recv_msg = NULL;
1853 char *single_msg = NULL;
1854 char *remained_msg = NULL;
1858 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
1861 LOGE("cb_info NULL");
1865 LOGD("start - fd : %d", cb_info->fd);
1867 single_msg = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
1869 LOGE("single_msg malloc failed");
1873 recv_msg = cb_info->recv_msg;
1875 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
1876 recv_length = muse_core_msg_recv(cb_info->fd, recv_msg);
1877 if (recv_length <= 0) {
1878 cb_info->is_server_connected = FALSE;
1879 LOGE("receive msg failed - server disconnected");
1887 /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
1889 /* Need to split the combined entering msgs */
1890 for (cur_pos = 0 ; cur_pos < recv_length ; cur_pos++) {
1891 if (recv_msg[cur_pos] == '}') {
1892 single_length = cur_pos - prev_pos + 1;
1894 if (single_length < MUSE_CAMERA_MSG_MAX_LENGTH) {
1895 /* check remained msg */
1896 if (remained_length > 0) {
1898 strncpy(single_msg, remained_msg, remained_length);
1899 strncpy(single_msg + remained_length, recv_msg + prev_pos, single_length);
1900 single_msg[remained_length + single_length] = '\0';
1903 remained_msg = NULL;
1905 strncpy(single_msg, recv_msg + prev_pos, single_length);
1906 single_msg[single_length] = '\0';
1907 LOGE("lost msg [%s], skip...", single_msg);
1910 remained_length = 0;
1912 strncpy(single_msg, recv_msg + prev_pos, single_length);
1913 single_msg[single_length] = '\0';
1916 if (single_msg[0] == '{') {
1918 /*LOGD("splitted msg : [%s], Index : %d", single_msg, num_msg);*/
1919 /* process each message */
1920 __camera_process_msg(cb_info, single_msg);
1922 LOGE("invalid msg [%s]", single_msg);
1925 LOGE("too long message [len %d] skip...", single_length);
1928 prev_pos = cur_pos + 1;
1932 /* check incompleted message */
1933 if (recv_msg[recv_length - 1] != '}') {
1934 remained_length = recv_length - prev_pos;
1936 LOGW("incompleted message [len %d]", remained_length);
1940 remained_msg = NULL;
1943 remained_msg = (char *)malloc(remained_length + 1);
1945 strncpy(remained_msg, recv_msg + prev_pos, remained_length);
1946 remained_msg[remained_length] = '\0';
1948 LOGE("failed to alloc for remained msg");
1951 remained_length = 0;
1955 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
1957 if (!cb_info->is_server_connected) {
1958 char *error_msg = NULL;
1960 if (cb_info->fd < 0) {
1961 LOGE("fd is closed in client side");
1962 goto CB_HANDLER_EXIT;
1965 /* send error msg for server disconnection */
1966 error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
1967 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
1968 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
1972 LOGE("error_msg failed");
1973 goto CB_HANDLER_EXIT;
1976 __camera_add_msg_to_queue(cb_info,
1977 MUSE_CAMERA_CB_EVENT,
1978 MUSE_CAMERA_EVENT_TYPE_ERROR,
1979 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
1982 muse_core_msg_free(error_msg);
1985 LOGE("add error msg for service disconnection done");
1996 remained_msg = NULL;
2003 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2004 int type, const char *thread_name, camera_cb_info_s *cb_info)
2006 if (!handler_info || !thread_name || !cb_info) {
2007 LOGE("t:%d NULL %p %p %p",
2008 type, handler_info, thread_name, cb_info);
2014 handler_info->type = type;
2015 handler_info->queue = g_queue_new();
2016 if (handler_info->queue == NULL) {
2017 LOGE("t:%d queue failed", type);
2021 g_mutex_init(&handler_info->mutex);
2022 g_cond_init(&handler_info->cond);
2024 handler_info->cb_info = (void *)cb_info;
2025 g_atomic_int_set(&handler_info->running, 1);
2027 handler_info->thread = g_thread_try_new(thread_name,
2028 _camera_msg_handler_func, (gpointer)handler_info, NULL);
2029 if (handler_info->thread == NULL) {
2030 LOGE("t:%d thread failed", type);
2032 g_mutex_clear(&handler_info->mutex);
2033 g_cond_clear(&handler_info->cond);
2034 g_queue_free(handler_info->queue);
2035 handler_info->queue = NULL;
2040 LOGD("t:%d done", type);
2046 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2050 if (!handler_info) {
2051 LOGE("NULL handler");
2055 if (!handler_info->thread) {
2056 LOGW("thread is not created");
2060 type = handler_info->type;
2062 LOGD("t:%d thread %p", type, handler_info->thread);
2064 g_mutex_lock(&handler_info->mutex);
2065 g_atomic_int_set(&handler_info->running, 0);
2066 g_cond_signal(&handler_info->cond);
2067 g_mutex_unlock(&handler_info->mutex);
2069 g_thread_join(handler_info->thread);
2070 handler_info->thread = NULL;
2072 g_mutex_clear(&handler_info->mutex);
2073 g_cond_clear(&handler_info->cond);
2074 g_queue_free(handler_info->queue);
2075 handler_info->queue = NULL;
2077 LOGD("t:%d done", type);
2083 static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
2085 camera_cb_info_s *cb_info = NULL;
2088 g_return_val_if_fail(sockfd > 0, NULL);
2090 cb_info = g_new0(camera_cb_info_s, 1);
2091 if (cb_info == NULL) {
2092 LOGE("cb_info failed");
2096 /* display interface handle */
2097 if (mm_display_interface_init(&cb_info->dp_interface) != MM_ERROR_NONE) {
2098 LOGE("display interface init failed");
2102 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2104 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2105 g_mutex_init(&cb_info->api_mutex[i]);
2106 g_cond_init(&cb_info->api_cond[i]);
2109 g_mutex_init(&cb_info->fd_lock);
2110 g_mutex_init(&cb_info->idle_event_mutex);
2111 g_cond_init(&cb_info->idle_event_cond);
2112 g_mutex_init(&cb_info->mp_data_mutex);
2114 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2115 g_mutex_init(&cb_info->user_cb_mutex[i]);
2117 /* message handler thread */
2118 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2119 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2120 LOGE("msg_handler_info failed");
2124 /* message handler thread for preview callback */
2125 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2126 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2127 LOGE("preview_cb_info failed");
2131 /* message handler thread for capture callback */
2132 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2133 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2134 LOGE("capture_cb_info failed");
2138 cb_info->fd = sockfd;
2139 cb_info->preview_cb_flag = 0;
2141 /* message receive thread */
2142 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2143 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2144 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2145 if (cb_info->msg_recv_thread == NULL) {
2146 LOGE("message receive thread creation failed");
2150 cb_info->is_server_connected = TRUE;
2156 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2157 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2158 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2160 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2161 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2163 g_mutex_clear(&cb_info->fd_lock);
2164 g_mutex_clear(&cb_info->idle_event_mutex);
2165 g_cond_clear(&cb_info->idle_event_cond);
2166 g_mutex_clear(&cb_info->mp_data_mutex);
2168 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2169 g_mutex_clear(&cb_info->api_mutex[i]);
2170 g_cond_clear(&cb_info->api_cond[i]);
2173 if (cb_info->dp_interface) {
2174 mm_display_interface_deinit(cb_info->dp_interface);
2175 cb_info->dp_interface = NULL;
2186 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2190 g_return_if_fail(cb_info != NULL);
2192 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2194 g_thread_join(cb_info->msg_recv_thread);
2195 cb_info->msg_recv_thread = NULL;
2197 LOGD("msg_recv thread removed");
2199 /* destroy msg handler threads */
2200 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2201 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2202 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2204 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2205 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2207 g_mutex_clear(&cb_info->fd_lock);
2208 g_mutex_clear(&cb_info->idle_event_mutex);
2209 g_cond_clear(&cb_info->idle_event_cond);
2210 g_mutex_clear(&cb_info->mp_data_mutex);
2212 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2213 g_mutex_clear(&cb_info->api_mutex[i]);
2214 g_cond_clear(&cb_info->api_cond[i]);
2217 if (cb_info->fd > -1) {
2218 muse_client_close(cb_info->fd);
2222 if (cb_info->bufmgr) {
2223 tbm_bufmgr_deinit(cb_info->bufmgr);
2224 cb_info->bufmgr = NULL;
2226 if (cb_info->pkt_fmt) {
2227 media_format_unref(cb_info->pkt_fmt);
2228 cb_info->pkt_fmt = NULL;
2231 if (cb_info->dp_interface) {
2232 mm_display_interface_deinit(cb_info->dp_interface);
2233 cb_info->dp_interface = NULL;
2236 cb_info->preview_cb_flag = 0;
2245 int _camera_start_evas_rendering(camera_h camera)
2247 camera_cli_s *pc = (camera_cli_s *)camera;
2249 if (!pc || !pc->cb_info) {
2250 LOGE("NULL handle");
2251 return CAMERA_ERROR_INVALID_PARAMETER;
2256 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2257 LOGE("EVAS surface is not set");
2258 return CAMERA_ERROR_NONE;
2261 /* set evas render flag as RUN */
2262 pc->cb_info->run_evas_render = true;
2264 return CAMERA_ERROR_NONE;
2268 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2270 int ret = CAMERA_ERROR_NONE;
2271 camera_cli_s *pc = (camera_cli_s *)camera;
2273 if (!pc || !pc->cb_info) {
2274 LOGE("NULL handle");
2275 return CAMERA_ERROR_INVALID_PARAMETER;
2278 LOGD("stop - keep screen %d", keep_screen);
2280 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2281 LOGE("EVAS surface is not set");
2282 return CAMERA_ERROR_NONE;
2285 /* set evas render flag as STOP and release buffers */
2286 pc->cb_info->run_evas_render = false;
2288 ret = mm_display_interface_evas_flush(pc->cb_info->dp_interface, keep_screen);
2289 if (ret == MM_ERROR_NONE) {
2290 ret = CAMERA_ERROR_NONE;
2292 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2293 ret = CAMERA_ERROR_INVALID_OPERATION;
2300 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2302 int ret = CAMERA_ERROR_NONE;
2305 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2307 /* create muse connection */
2308 if (!key || !value) {
2309 LOGE("NULL pointer");
2310 return CAMERA_ERROR_INVALID_PARAMETER;
2313 sock_fd = muse_client_new();
2315 LOGE("muse_client_new failed");
2316 return CAMERA_ERROR_INVALID_OPERATION;
2319 msg = muse_core_msg_new(api,
2320 MUSE_TYPE_INT, "module", MUSE_CAMERA,
2321 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2325 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2329 ret = muse_core_msg_send(sock_fd, msg);
2331 muse_core_msg_free(msg);
2335 LOGE("send msg failed");
2336 ret = CAMERA_ERROR_INVALID_OPERATION;
2340 ret = muse_core_msg_recv(sock_fd, recv_msg);
2342 LOGE("recv msg failed %d", errno);
2343 ret = CAMERA_ERROR_INVALID_OPERATION;
2347 if (!muse_camera_msg_get(ret, recv_msg)) {
2348 LOGE("failed to get return value from msg [%s]", recv_msg);
2349 ret = CAMERA_ERROR_INVALID_OPERATION;
2353 if (ret == CAMERA_ERROR_NONE)
2354 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2356 LOGD("api %d - value %d", api, *value);
2360 muse_client_close(sock_fd);
2368 int camera_create(camera_device_e device, camera_h *camera)
2371 char *send_msg = NULL;
2373 int ret = CAMERA_ERROR_NONE;
2375 camera_cli_s *pc = NULL;
2376 tbm_bufmgr bufmgr = NULL;
2378 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2379 muse_core_api_module_e muse_module = MUSE_CAMERA;
2380 int device_type = (int)device;
2383 LOGE("NULL pointer");
2384 return CAMERA_ERROR_INVALID_PARAMETER;
2387 sock_fd = muse_client_new();
2389 LOGE("muse_client_new failed - returned fd %d", sock_fd);
2390 ret = CAMERA_ERROR_INVALID_OPERATION;
2396 send_msg = muse_core_msg_new(api,
2397 MUSE_TYPE_INT, "module", muse_module,
2398 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2399 MUSE_TYPE_INT, "pid", pid,
2404 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2408 send_ret = muse_core_msg_send(sock_fd, send_msg);
2410 muse_core_msg_free(send_msg);
2414 LOGE("send msg failed %d", errno);
2415 ret = CAMERA_ERROR_INVALID_OPERATION;
2419 pc = g_new0(camera_cli_s, 1);
2421 LOGE("camera_cli_s alloc failed");
2422 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2426 bufmgr = tbm_bufmgr_init(-1);
2427 if (bufmgr == NULL) {
2428 LOGE("get tbm bufmgr failed");
2429 ret = CAMERA_ERROR_INVALID_OPERATION;
2433 pc->cb_info = _camera_client_callback_new(sock_fd);
2434 if (pc->cb_info == NULL) {
2435 LOGE("cb_info alloc failed");
2436 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2442 LOGD("cb info : %d", pc->cb_info->fd);
2444 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2446 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2448 if (ret == CAMERA_ERROR_NONE) {
2449 intptr_t handle = 0;
2450 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2452 LOGE("Receiving Handle Failed!!");
2453 ret = CAMERA_ERROR_INVALID_OPERATION;
2457 pc->remote_handle = handle;
2458 pc->cb_info->bufmgr = bufmgr;
2460 ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL);
2461 if (ret != CAMERA_ERROR_NONE) {
2462 LOGE("init display failed 0x%x", ret);
2466 LOGD("camera create 0x%x", pc->remote_handle);
2467 *camera = (camera_h)pc;
2476 tbm_bufmgr_deinit(bufmgr);
2481 muse_client_close(sock_fd);
2487 int temp_fd = pc->cb_info->fd;
2489 /* pc->cb_info->fd should be closed,
2490 because g_thread_join for msg_recv_thread is not returned
2491 in _camera_client_callback_destroy. */
2493 pc->cb_info->fd = -1;
2494 muse_client_close(temp_fd);
2497 _camera_client_callback_destroy(pc->cb_info);
2504 LOGE("camera create error : 0x%x", ret);
2511 int camera_change_device(camera_h camera, camera_device_e device)
2514 int ret = CAMERA_ERROR_NONE;
2515 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2516 camera_cli_s *pc = (camera_cli_s *)camera;
2517 camera_msg_param param;
2519 if (!pc || !pc->cb_info) {
2520 LOGE("NULL handle");
2521 return CAMERA_ERROR_INVALID_PARAMETER;
2524 CAMERA_MSG_PARAM_SET(param, INT, device);
2526 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2528 if (ret == CAMERA_ERROR_NONE) {
2529 /* reset callback and user data */
2530 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2531 pc->cb_info->user_cb[i] = NULL;
2532 pc->cb_info->user_data[i] = NULL;
2534 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
2541 int camera_destroy(camera_h camera)
2543 int ret = CAMERA_ERROR_NONE;
2544 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2545 camera_cli_s *pc = (camera_cli_s *)camera;
2547 if (!pc || !pc->cb_info) {
2548 LOGE("NULL handle");
2549 return CAMERA_ERROR_INVALID_PARAMETER;
2554 if (pc->cb_info->is_server_connected)
2555 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2557 LOGW("server disconnected. release resource without send message.");
2559 if (ret == CAMERA_ERROR_NONE) {
2560 _camera_deactivate_idle_event_all(pc->cb_info);
2561 _camera_client_callback_destroy(pc->cb_info);
2568 LOGD("ret : 0x%x", ret);
2573 int camera_start_preview(camera_h camera)
2575 int ret = CAMERA_ERROR_NONE;
2576 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2577 camera_cli_s *pc = (camera_cli_s *)camera;
2579 if (!pc || !pc->cb_info) {
2580 LOGE("NULL handle");
2581 return CAMERA_ERROR_INVALID_PARAMETER;
2586 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2587 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2588 ret = _camera_start_evas_rendering(camera);
2589 if (ret != CAMERA_ERROR_NONE) {
2590 LOGE("stop preview because of error");
2591 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, pc->cb_info, NULL, 0);
2595 LOGD("ret : 0x%x", ret);
2601 int camera_stop_preview(camera_h camera)
2603 int ret = CAMERA_ERROR_NONE;
2604 camera_cli_s *pc = (camera_cli_s *)camera;
2605 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2606 camera_state_e current_state = CAMERA_STATE_NONE;
2608 if (!pc || !pc->cb_info) {
2609 LOGE("NULL handle");
2610 return CAMERA_ERROR_INVALID_PARAMETER;
2616 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2617 ret = camera_get_state(camera, ¤t_state);
2618 if (ret != CAMERA_ERROR_NONE) {
2619 LOGE("failed to get current state 0x%x", ret);
2623 if (current_state == CAMERA_STATE_PREVIEW) {
2624 ret = _camera_stop_evas_rendering(camera, false);
2625 if (ret != CAMERA_ERROR_NONE)
2630 /* send stop preview message */
2631 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2633 if (ret != CAMERA_ERROR_NONE &&
2634 current_state == CAMERA_STATE_PREVIEW) {
2635 LOGW("restart evas rendering");
2636 _camera_start_evas_rendering(camera);
2639 LOGD("ret : 0x%x", ret);
2645 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2647 int ret = CAMERA_ERROR_NONE;
2648 camera_cli_s *pc = (camera_cli_s *)camera;
2649 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2651 if (!pc || !pc->cb_info) {
2652 LOGE("NULL handle");
2653 return CAMERA_ERROR_INVALID_PARAMETER;
2658 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2659 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2661 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2662 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2664 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2666 LOGD("ret : 0x%x", ret);
2672 bool camera_is_supported_continuous_capture(camera_h camera)
2674 int ret = CAMERA_ERROR_NONE;
2675 camera_cli_s *pc = (camera_cli_s *)camera;
2676 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2678 if (!pc || !pc->cb_info) {
2679 LOGE("NULL handle");
2680 return CAMERA_ERROR_INVALID_PARAMETER;
2685 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2688 LOGE("error is occurred 0x%x", ret);
2692 LOGD("ret : %d", ret);
2698 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)
2700 int ret = CAMERA_ERROR_NONE;
2701 camera_cli_s *pc = (camera_cli_s *)camera;
2702 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2703 camera_msg_param param;
2706 if (!pc || !pc->cb_info) {
2707 LOGE("NULL handle");
2708 return CAMERA_ERROR_INVALID_PARAMETER;
2713 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2714 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2716 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2717 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2719 value = (count << 16) | interval;
2720 CAMERA_MSG_PARAM_SET(param, INT, value);
2722 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2724 LOGD("ret : 0x%x", ret);
2730 int camera_stop_continuous_capture(camera_h camera)
2732 int ret = CAMERA_ERROR_NONE;
2733 camera_cli_s *pc = (camera_cli_s *)camera;
2734 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2736 if (!pc || !pc->cb_info) {
2737 LOGE("NULL handle");
2738 return CAMERA_ERROR_INVALID_PARAMETER;
2743 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2745 LOGD("ret : 0x%x", ret);
2751 bool camera_is_supported_face_detection(camera_h camera)
2753 int ret = CAMERA_ERROR_NONE;
2754 camera_cli_s *pc = (camera_cli_s *)camera;
2755 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2757 if (!pc || !pc->cb_info) {
2758 LOGE("NULL handle");
2759 return CAMERA_ERROR_INVALID_PARAMETER;
2764 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2767 LOGE("error is occurred 0x%x", ret);
2771 LOGD("ret : %d", ret);
2777 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2779 int ret = CAMERA_ERROR_NONE;
2780 camera_cli_s *pc = (camera_cli_s *)camera;
2781 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2783 if (!pc || !pc->cb_info) {
2784 LOGE("NULL handle");
2785 return CAMERA_ERROR_INVALID_PARAMETER;
2790 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2793 LOGE("error is occurred 0x%x", ret);
2797 LOGD("ret : %d", ret);
2803 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2805 int ret = CAMERA_ERROR_NONE;
2806 camera_cli_s *pc = (camera_cli_s *)camera;
2807 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2809 if (!pc || !pc->cb_info) {
2810 LOGE("NULL handle");
2811 return CAMERA_ERROR_INVALID_PARAMETER;
2816 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2819 LOGE("error is occurred 0x%x", ret);
2823 LOGD("ret : %d", ret);
2828 int camera_get_device_count(camera_h camera, int *device_count)
2830 int ret = CAMERA_ERROR_NONE;
2831 camera_cli_s *pc = (camera_cli_s *)camera;
2832 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2834 if (!pc || !pc->cb_info) {
2835 LOGE("NULL handle");
2836 return CAMERA_ERROR_INVALID_PARAMETER;
2841 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2843 if (ret == CAMERA_ERROR_NONE)
2844 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2846 LOGD("ret : 0x%x", ret);
2851 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2853 int ret = CAMERA_ERROR_NONE;
2854 camera_cli_s *pc = (camera_cli_s *)camera;
2855 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2857 if (!pc || !pc->cb_info) {
2858 LOGE("NULL handle");
2859 return CAMERA_ERROR_INVALID_PARAMETER;
2864 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2866 if (ret == CAMERA_ERROR_NONE) {
2867 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2869 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2870 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2872 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2875 LOGD("ret : 0x%x", ret);
2880 int camera_stop_face_detection(camera_h camera)
2882 int ret = CAMERA_ERROR_NONE;
2883 camera_cli_s *pc = (camera_cli_s *)camera;
2884 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
2886 if (!pc || !pc->cb_info) {
2887 LOGE("NULL handle");
2888 return CAMERA_ERROR_INVALID_PARAMETER;
2893 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2895 if (ret == CAMERA_ERROR_NONE) {
2896 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2898 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
2899 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
2901 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2904 LOGD("ret : 0x%x", ret);
2909 int camera_get_state(camera_h camera, camera_state_e *state)
2911 int ret = CAMERA_ERROR_NONE;
2912 camera_cli_s *pc = (camera_cli_s *)camera;
2913 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
2915 if (!pc || !pc->cb_info || !state) {
2916 LOGE("NULL pointer %p %p", pc, state);
2917 return CAMERA_ERROR_INVALID_PARAMETER;
2922 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2924 if (ret == CAMERA_ERROR_NONE)
2925 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
2927 LOGD("ret : 0x%x", ret);
2932 int camera_start_focusing(camera_h camera, bool continuous)
2934 int ret = CAMERA_ERROR_NONE;
2935 camera_cli_s *pc = (camera_cli_s *)camera;
2936 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
2937 camera_msg_param param;
2938 int is_continuous = (int)continuous;
2940 if (!pc || !pc->cb_info) {
2941 LOGE("NULL handle");
2942 return CAMERA_ERROR_INVALID_PARAMETER;
2947 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
2949 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2951 LOGD("ret : 0x%x", ret);
2956 int camera_cancel_focusing(camera_h camera)
2958 int ret = CAMERA_ERROR_NONE;
2959 camera_cli_s *pc = (camera_cli_s *)camera;
2960 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
2962 if (!pc || !pc->cb_info) {
2963 LOGE("NULL handle");
2964 return CAMERA_ERROR_INVALID_PARAMETER;
2967 LOGD("Enter, remote_handle : %x", pc->remote_handle);
2969 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2971 LOGD("ret : 0x%x", ret);
2976 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
2978 int ret = CAMERA_ERROR_NONE;
2979 camera_cli_s *pc = (camera_cli_s *)camera;
2980 camera_cb_info_s *cb_info = NULL;
2981 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
2982 camera_state_e current_state = CAMERA_STATE_NONE;
2983 camera_msg_param param;
2987 if (!pc || !pc->cb_info) {
2988 LOGE("NULL handle");
2989 return CAMERA_ERROR_INVALID_PARAMETER;
2992 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
2993 LOGE("invalid type %d", type);
2994 return CAMERA_ERROR_INVALID_PARAMETER;
2997 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
2998 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
2999 return CAMERA_ERROR_INVALID_PARAMETER;
3002 cb_info = (camera_cb_info_s *)pc->cb_info;
3004 ret = camera_get_state(camera, ¤t_state);
3005 if (ret != CAMERA_ERROR_NONE) {
3006 LOGE("failed to get current state 0x%x", ret);
3010 if (current_state != CAMERA_STATE_CREATED) {
3011 LOGE("INVALID_STATE : current %d", current_state);
3012 return CAMERA_ERROR_INVALID_STATE;
3015 LOGD("Enter - display : %p", display);
3017 if (type == CAMERA_DISPLAY_TYPE_NONE) {
3018 LOGD("display type NONE");
3020 ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &cb_info->parent_id);
3021 if (ret == MM_ERROR_NONE && type == CAMERA_DISPLAY_TYPE_EVAS) {
3023 camera_flip_e flip = CAMERA_FLIP_NONE;
3024 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3025 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3032 camera_get_display_flip(camera, &flip);
3033 camera_get_display_mode(camera, &mode);
3034 camera_get_display_rotation(camera, &rotation);
3035 camera_is_display_visible(camera, &visible);
3036 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3038 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
3039 flip, mode, rotation, visible, x, y, width, height);
3041 ret = mm_display_interface_evas_set_flip(cb_info->dp_interface, flip);
3042 ret |= mm_display_interface_evas_set_mode(cb_info->dp_interface, mode);
3043 ret |= mm_display_interface_evas_set_rotation(cb_info->dp_interface, rotation);
3044 ret |= mm_display_interface_evas_set_visible(cb_info->dp_interface, visible);
3046 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
3047 ret |= mm_display_interface_evas_set_roi_area(cb_info->dp_interface, x, y, width, height);
3052 if (type == CAMERA_DISPLAY_TYPE_OVERLAY) {
3055 length = sizeof(camera_wl_info_s) / sizeof(int) + \
3056 (sizeof(camera_wl_info_s) % sizeof(int) ? 1 : 0);
3058 msg = muse_core_msg_new(api,
3059 MUSE_TYPE_INT, "type", type,
3060 MUSE_TYPE_INT, "parent_id", cb_info->parent_id,
3063 LOGE("msg creation failed: api %d", api);
3064 return CAMERA_ERROR_OUT_OF_MEMORY;
3067 if (pc->cb_info->is_server_connected) {
3068 __camera_update_api_waiting(pc->cb_info, api, 1);
3070 g_mutex_lock(&pc->cb_info->fd_lock);
3071 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
3072 g_mutex_unlock(&pc->cb_info->fd_lock);
3076 LOGE("message send failed");
3077 ret = CAMERA_ERROR_INVALID_OPERATION;
3079 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
3082 __camera_update_api_waiting(pc->cb_info, api, -1);
3084 muse_core_msg_free(msg);
3086 CAMERA_MSG_PARAM_SET(param, INT, type);
3088 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3091 if (ret != CAMERA_ERROR_NONE)
3092 LOGE("set display error 0x%x", ret);
3093 else if (type == CAMERA_DISPLAY_TYPE_EVAS)
3094 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3100 int camera_set_preview_resolution(camera_h camera, int width, int height)
3102 int ret = CAMERA_ERROR_NONE;
3103 camera_state_e current_state = CAMERA_STATE_NONE;
3104 camera_cli_s *pc = (camera_cli_s *)camera;
3105 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3106 camera_msg_param param;
3109 if (!pc || !pc->cb_info) {
3110 LOGE("NULL handle");
3111 return CAMERA_ERROR_INVALID_PARAMETER;
3114 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3115 ret = camera_get_state(camera, ¤t_state);
3116 if (ret != CAMERA_ERROR_NONE) {
3117 LOGE("failed to get current state 0x%x", ret);
3121 if (current_state == CAMERA_STATE_PREVIEW) {
3122 ret = _camera_stop_evas_rendering(camera, true);
3123 if (ret != CAMERA_ERROR_NONE)
3128 value = (width << 16) | height;
3129 CAMERA_MSG_PARAM_SET(param, INT, value);
3131 LOGD("%dx%d -> 0x%x", width, height, value);
3133 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3135 LOGD("ret : 0x%x", ret);
3137 if (current_state == CAMERA_STATE_PREVIEW) {
3138 LOGW("restart evas rendering");
3139 _camera_start_evas_rendering(camera);
3146 int camera_set_capture_resolution(camera_h camera, int width, int height)
3148 int ret = CAMERA_ERROR_NONE;
3149 camera_cli_s *pc = (camera_cli_s *)camera;
3150 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3151 camera_msg_param param;
3154 if (!pc || !pc->cb_info) {
3155 LOGE("NULL handle");
3156 return CAMERA_ERROR_INVALID_PARAMETER;
3161 value = (width << 16) | height;
3162 CAMERA_MSG_PARAM_SET(param, INT, value);
3164 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3166 LOGD("ret : 0x%x", ret);
3172 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3174 int ret = CAMERA_ERROR_NONE;
3175 int set_format = (int)format;
3176 camera_cli_s *pc = (camera_cli_s *)camera;
3177 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3178 camera_msg_param param;
3180 if (!pc || !pc->cb_info) {
3181 LOGE("NULL handle");
3182 return CAMERA_ERROR_INVALID_PARAMETER;
3185 LOGD("Enter - format %d", set_format);
3187 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3189 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3191 LOGD("ret : 0x%x", ret);
3197 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3199 int ret = CAMERA_ERROR_NONE;
3200 int set_format = (int)format;
3201 camera_msg_param param;
3202 camera_cli_s *pc = (camera_cli_s *)camera;
3203 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3205 if (!pc || !pc->cb_info) {
3206 LOGE("NULL handle");
3207 return CAMERA_ERROR_INVALID_PARAMETER;
3210 LOGD("Enter - capture_format %d", set_format);
3212 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3214 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3216 LOGD("ret : 0x%x", ret);
3222 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3224 int ret = CAMERA_ERROR_NONE;
3225 camera_cli_s *pc = (camera_cli_s *)camera;
3226 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3228 if (!pc || !pc->cb_info || !width || !height) {
3229 LOGE("NULL pointer %p %p %p", pc, width, height);
3230 return CAMERA_ERROR_INVALID_PARAMETER;
3235 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3237 if (ret == CAMERA_ERROR_NONE) {
3238 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3239 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3242 LOGD("ret : 0x%x", ret);
3248 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3250 int ret = CAMERA_ERROR_NONE;
3251 int set_rotation = (int)rotation;
3252 camera_cli_s *pc = (camera_cli_s *)camera;
3253 camera_msg_param param;
3255 if (!pc || !pc->cb_info) {
3256 LOGE("NULL handle");
3257 return CAMERA_ERROR_INVALID_PARAMETER;
3260 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3261 ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
3262 if (ret != MM_ERROR_NONE) {
3263 LOGE("failed to set rotation for evas surface 0x%x", ret);
3264 return CAMERA_ERROR_INVALID_OPERATION;
3268 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3270 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3276 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3278 int ret = CAMERA_ERROR_NONE;
3279 camera_cli_s *pc = (camera_cli_s *)camera;
3281 if (!pc || !pc->cb_info || !rotation) {
3282 LOGE("NULL pointer %p %p", pc, rotation);
3283 return CAMERA_ERROR_INVALID_PARAMETER;
3286 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3288 if (ret == CAMERA_ERROR_NONE)
3289 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3295 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3297 int ret = CAMERA_ERROR_NONE;
3298 int set_flip = (int)flip;
3299 camera_cli_s *pc = (camera_cli_s *)camera;
3300 camera_msg_param param;
3302 if (!pc || !pc->cb_info) {
3303 LOGE("NULL handle");
3304 return CAMERA_ERROR_INVALID_PARAMETER;
3307 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3308 ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
3309 if (ret != MM_ERROR_NONE) {
3310 LOGE("failed to set flip for evas surface 0x%x", ret);
3311 return CAMERA_ERROR_INVALID_OPERATION;
3315 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3317 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3323 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3325 int ret = CAMERA_ERROR_NONE;
3326 camera_cli_s *pc = (camera_cli_s *)camera;
3328 if (!pc || !pc->cb_info || !flip) {
3329 LOGE("NULL pointer %p %p", pc, flip);
3330 return CAMERA_ERROR_INVALID_PARAMETER;
3333 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3335 if (ret == CAMERA_ERROR_NONE)
3336 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3342 int camera_set_display_visible(camera_h camera, bool visible)
3344 int ret = CAMERA_ERROR_NONE;
3345 int set_visible = (int)visible;
3346 camera_cli_s *pc = (camera_cli_s *)camera;
3347 camera_msg_param param;
3349 if (!pc || !pc->cb_info) {
3350 LOGE("NULL handle");
3351 return CAMERA_ERROR_INVALID_PARAMETER;
3354 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3355 ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
3356 if (ret != MM_ERROR_NONE) {
3357 LOGE("failed to set visible for evas surface 0x%x", ret);
3358 return CAMERA_ERROR_INVALID_OPERATION;
3362 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3364 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3370 int camera_is_display_visible(camera_h camera, bool *visible)
3372 int ret = CAMERA_ERROR_NONE;
3373 camera_cli_s *pc = (camera_cli_s *)camera;
3375 if (!pc || !pc->cb_info || !visible) {
3376 LOGE("NULL pointer %p %p", pc, visible);
3377 return CAMERA_ERROR_INVALID_PARAMETER;
3380 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3382 if (ret == CAMERA_ERROR_NONE)
3383 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3389 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3391 int ret = CAMERA_ERROR_NONE;
3392 int set_mode = (int)mode;
3393 camera_cli_s *pc = (camera_cli_s *)camera;
3394 camera_msg_param param;
3396 if (!pc || !pc->cb_info) {
3397 LOGE("NULL handle");
3398 return CAMERA_ERROR_INVALID_PARAMETER;
3401 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3402 ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
3403 if (ret != MM_ERROR_NONE) {
3404 LOGE("failed to set geometry for evas surface 0x%x", ret);
3405 return CAMERA_ERROR_INVALID_OPERATION;
3409 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3411 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3417 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3419 int ret = CAMERA_ERROR_NONE;
3420 camera_cli_s *pc = (camera_cli_s *)camera;
3422 if (!pc || !pc->cb_info || !mode) {
3423 LOGE("NULL pointer %p %p", pc, mode);
3424 return CAMERA_ERROR_INVALID_PARAMETER;
3427 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3429 if (ret == CAMERA_ERROR_NONE)
3430 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3436 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3438 int ret = CAMERA_ERROR_NONE;
3439 int set_hint = (int)hint;
3440 camera_cli_s *pc = (camera_cli_s *)camera;
3441 camera_msg_param param;
3443 if (!pc || !pc->cb_info) {
3444 LOGE("NULL handle");
3445 return CAMERA_ERROR_INVALID_PARAMETER;
3448 LOGD("Enter - hint %d", set_hint);
3450 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3452 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3458 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3460 int ret = CAMERA_ERROR_NONE;
3461 camera_cli_s *pc = (camera_cli_s *)camera;
3462 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3464 if (!pc || !pc->cb_info || !hint) {
3465 LOGE("NULL pointer %p %p", pc, hint);
3466 return CAMERA_ERROR_INVALID_PARAMETER;
3469 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3471 if (ret == CAMERA_ERROR_NONE) {
3472 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3473 LOGD("display reuse hint %d", *hint);
3480 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
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_RESOLUTION;
3486 if (!pc || !pc->cb_info || !width || !height) {
3487 LOGE("NULL pointer %p %p %p", pc, width, height);
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 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3497 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3500 LOGD("ret : 0x%x", ret);
3506 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3508 int ret = CAMERA_ERROR_NONE;
3509 camera_cli_s *pc = (camera_cli_s *)camera;
3510 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3512 if (!pc || !pc->cb_info || !format) {
3513 LOGE("NULL pointer %p %p", pc, format);
3514 return CAMERA_ERROR_INVALID_PARAMETER;
3519 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3521 if (ret == CAMERA_ERROR_NONE)
3522 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3524 LOGD("ret : 0x%x", ret);
3530 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3532 int ret = CAMERA_ERROR_NONE;
3533 camera_cli_s *pc = (camera_cli_s *)camera;
3534 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3536 if (!pc || !pc->cb_info || !format) {
3537 LOGE("NULL pointer %p %p", pc, format);
3538 return CAMERA_ERROR_INVALID_PARAMETER;
3543 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3545 if (ret == CAMERA_ERROR_NONE)
3546 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3548 LOGD("ret : 0x%x", ret);
3554 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3556 int ret = CAMERA_ERROR_NONE;
3557 camera_cli_s *pc = (camera_cli_s *)camera;
3558 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3560 if (!pc || !pc->cb_info || !facing_direction) {
3561 LOGE("NULL pointer %p %p", pc, facing_direction);
3562 return CAMERA_ERROR_INVALID_PARAMETER;
3567 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3569 if (ret == CAMERA_ERROR_NONE)
3570 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3572 LOGD("ret : 0x%x", ret);
3578 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3580 int ret = CAMERA_ERROR_NONE;
3581 camera_cli_s *pc = (camera_cli_s *)camera;
3582 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3584 if (!pc || !pc->cb_info || !callback) {
3585 LOGE("NULL pointer %p %p", pc, callback);
3586 return CAMERA_ERROR_INVALID_PARAMETER;
3591 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3593 if (ret == CAMERA_ERROR_NONE) {
3594 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3596 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3597 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3599 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3601 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3604 LOGD("ret : 0x%x", ret);
3610 int camera_unset_preview_cb(camera_h camera)
3612 int ret = CAMERA_ERROR_NONE;
3613 camera_cli_s *pc = (camera_cli_s *)camera;
3614 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3616 if (!pc || !pc->cb_info) {
3617 LOGE("NULL handle");
3618 return CAMERA_ERROR_INVALID_PARAMETER;
3623 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3625 if (ret == CAMERA_ERROR_NONE) {
3626 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3628 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3629 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3631 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3633 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3636 LOGD("ret : 0x%x", ret);
3642 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3644 int ret = CAMERA_ERROR_NONE;
3645 camera_cli_s *pc = (camera_cli_s *)camera;
3646 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3648 if (!pc || !pc->cb_info) {
3649 LOGE("NULL handle");
3650 return CAMERA_ERROR_INVALID_PARAMETER;
3653 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3654 LOGE("NOT SUPPORTED");
3655 return CAMERA_ERROR_NOT_SUPPORTED;
3658 if (callback == NULL) {
3659 LOGE("NULL callback");
3660 return CAMERA_ERROR_INVALID_PARAMETER;
3665 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3667 if (ret == CAMERA_ERROR_NONE) {
3668 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3670 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3671 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3673 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3676 LOGD("ret : 0x%x", ret);
3682 int camera_unset_media_packet_preview_cb(camera_h camera)
3684 int ret = CAMERA_ERROR_NONE;
3685 camera_cli_s *pc = (camera_cli_s *)camera;
3686 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3688 if (!pc || !pc->cb_info) {
3689 LOGE("NULL handle");
3690 return CAMERA_ERROR_INVALID_PARAMETER;
3695 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3697 if (ret == CAMERA_ERROR_NONE) {
3698 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3700 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3701 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3703 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3706 LOGD("ret : 0x%x", ret);
3712 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3714 int ret = CAMERA_ERROR_NONE;
3715 camera_cli_s *pc = (camera_cli_s *)camera;
3716 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3718 if (!pc || !pc->cb_info || !callback) {
3719 LOGE("NULL pointer %p %p", pc, callback);
3720 return CAMERA_ERROR_INVALID_PARAMETER;
3725 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3727 if (ret == CAMERA_ERROR_NONE) {
3728 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3730 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3731 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3733 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3736 LOGD("ret : 0x%x", ret);
3742 int camera_unset_state_changed_cb(camera_h camera)
3744 int ret = CAMERA_ERROR_NONE;
3745 camera_cli_s *pc = (camera_cli_s *)camera;
3746 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3748 if (!pc || !pc->cb_info) {
3749 LOGE("NULL handle");
3750 return CAMERA_ERROR_INVALID_PARAMETER;
3755 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3757 if (ret == CAMERA_ERROR_NONE) {
3758 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3760 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3761 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3763 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3766 LOGD("ret : 0x%x", ret);
3772 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3774 int ret = CAMERA_ERROR_NONE;
3775 camera_cli_s *pc = (camera_cli_s *)camera;
3776 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3778 if (!pc || !pc->cb_info || !callback) {
3779 LOGE("NULL pointer %p %p", pc, callback);
3780 return CAMERA_ERROR_INVALID_PARAMETER;
3785 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3787 if (ret == CAMERA_ERROR_NONE) {
3788 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3790 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3791 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3793 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3796 LOGD("ret : 0x%x", ret);
3802 int camera_unset_interrupted_cb(camera_h camera)
3804 int ret = CAMERA_ERROR_NONE;
3805 camera_cli_s *pc = (camera_cli_s *)camera;
3806 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3808 if (!pc || !pc->cb_info) {
3809 LOGE("NULL handle");
3810 return CAMERA_ERROR_INVALID_PARAMETER;
3815 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3817 if (ret == CAMERA_ERROR_NONE) {
3818 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3820 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3821 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3823 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3826 LOGD("ret : 0x%x", ret);
3832 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
3834 int ret = CAMERA_ERROR_NONE;
3835 camera_cli_s *pc = (camera_cli_s *)camera;
3836 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
3838 if (!pc || !pc->cb_info || !callback) {
3839 LOGE("NULL pointer %p %p", pc, callback);
3840 return CAMERA_ERROR_INVALID_PARAMETER;
3845 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3847 if (ret == CAMERA_ERROR_NONE) {
3848 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3850 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
3851 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
3853 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3856 LOGD("ret : 0x%x", ret);
3862 int camera_unset_interrupt_started_cb(camera_h camera)
3864 int ret = CAMERA_ERROR_NONE;
3865 camera_cli_s *pc = (camera_cli_s *)camera;
3866 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
3868 if (!pc || !pc->cb_info) {
3869 LOGE("NULL handle");
3870 return CAMERA_ERROR_INVALID_PARAMETER;
3875 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3877 if (ret == CAMERA_ERROR_NONE) {
3878 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3880 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3881 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3883 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3886 LOGD("ret : 0x%x", ret);
3892 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
3894 int ret = CAMERA_ERROR_NONE;
3895 camera_cli_s *pc = (camera_cli_s *)camera;
3896 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3898 if (!pc || !pc->cb_info || !callback) {
3899 LOGE("NULL pointer %p %p", pc, callback);
3900 return CAMERA_ERROR_INVALID_PARAMETER;
3905 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3907 if (ret == CAMERA_ERROR_NONE) {
3908 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3910 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3911 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3913 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3916 LOGD("ret : 0x%x", ret);
3922 int camera_unset_focus_changed_cb(camera_h camera)
3924 int ret = CAMERA_ERROR_NONE;
3925 camera_cli_s *pc = (camera_cli_s *)camera;
3926 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
3928 if (!pc || !pc->cb_info) {
3929 LOGE("NULL handle");
3930 return CAMERA_ERROR_INVALID_PARAMETER;
3935 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3937 if (ret == CAMERA_ERROR_NONE) {
3938 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3940 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3941 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3943 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3946 LOGD("ret : 0x%x", ret);
3952 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
3954 int ret = CAMERA_ERROR_NONE;
3955 camera_cli_s *pc = (camera_cli_s *)camera;
3956 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
3958 if (!pc || !pc->cb_info || !callback) {
3959 LOGE("NULL pointer %p %p", pc, callback);
3960 return CAMERA_ERROR_INVALID_PARAMETER;
3965 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3967 if (ret == CAMERA_ERROR_NONE) {
3968 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3970 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
3971 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
3973 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3976 LOGD("ret : 0x%x", ret);
3982 int camera_unset_error_cb(camera_h camera)
3984 int ret = CAMERA_ERROR_NONE;
3985 camera_cli_s *pc = (camera_cli_s *)camera;
3986 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
3988 if (!pc || !pc->cb_info) {
3989 LOGE("NULL handle");
3990 return CAMERA_ERROR_INVALID_PARAMETER;
3995 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3997 if (ret == CAMERA_ERROR_NONE) {
3998 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4000 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4001 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
4003 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
4006 LOGD("ret : 0x%x", ret);
4012 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4014 int ret = CAMERA_ERROR_NONE;
4015 camera_cli_s *pc = (camera_cli_s *)camera;
4016 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4018 if (!pc || !pc->cb_info || !foreach_cb) {
4019 LOGE("NULL pointer %p %p", pc, foreach_cb);
4020 return CAMERA_ERROR_INVALID_PARAMETER;
4025 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4026 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4028 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4030 LOGD("ret : 0x%x", ret);
4036 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4038 int ret = CAMERA_ERROR_NONE;
4039 camera_cli_s *pc = (camera_cli_s *)camera;
4040 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4042 if (!pc || !pc->cb_info || !foreach_cb) {
4043 LOGE("NULL pointer %p %p", pc, foreach_cb);
4044 return CAMERA_ERROR_INVALID_PARAMETER;
4049 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4050 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4052 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4054 LOGD("ret : 0x%x", ret);
4060 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4062 int ret = CAMERA_ERROR_NONE;
4063 camera_cli_s *pc = (camera_cli_s *)camera;
4064 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4066 if (!pc || !pc->cb_info || !foreach_cb) {
4067 LOGE("NULL pointer %p %p", pc, foreach_cb);
4068 return CAMERA_ERROR_INVALID_PARAMETER;
4073 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4074 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4076 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4078 LOGD("ret : 0x%x", ret);
4084 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4086 int ret = CAMERA_ERROR_NONE;
4087 camera_cli_s *pc = (camera_cli_s *)camera;
4088 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4090 if (!pc || !pc->cb_info || !foreach_cb) {
4091 LOGE("NULL pointer %p %p", pc, foreach_cb);
4092 return CAMERA_ERROR_INVALID_PARAMETER;
4097 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4098 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4100 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4102 LOGD("ret : 0x%x", ret);
4108 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4110 int ret = CAMERA_ERROR_NONE;
4111 camera_cli_s *pc = (camera_cli_s *)camera;
4112 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4114 if (!pc || !pc->cb_info || !width || !height) {
4115 LOGE("NULL pointer %p %p %p", pc, width, height);
4116 return CAMERA_ERROR_INVALID_PARAMETER;
4120 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4122 if (ret == CAMERA_ERROR_NONE) {
4123 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4124 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4127 LOGD("ret : 0x%x", ret);
4133 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4135 int ret = CAMERA_ERROR_NONE;
4136 camera_cli_s *pc = (camera_cli_s *)camera;
4137 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4139 if (!pc || !pc->cb_info || !angle) {
4140 LOGE("NULL pointer %p %p", pc, angle);
4141 return CAMERA_ERROR_INVALID_PARAMETER;
4146 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4148 if (ret == CAMERA_ERROR_NONE)
4149 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4151 LOGD("ret : 0x%x", ret);
4157 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4159 int ret = CAMERA_ERROR_NONE;
4160 camera_cli_s *pc = (camera_cli_s *)camera;
4161 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4162 camera_msg_param param;
4163 int set_mode = (int)mode;
4165 if (!pc || !pc->cb_info) {
4166 LOGE("NULL handle");
4167 return CAMERA_ERROR_INVALID_PARAMETER;
4172 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4174 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4176 LOGD("ret : 0x%x", ret);
4182 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4184 int ret = CAMERA_ERROR_NONE;
4185 camera_cli_s *pc = (camera_cli_s *)camera;
4186 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4188 if (!pc || !pc->cb_info || !mode) {
4189 LOGE("NULL pointer %p %p", pc, mode);
4190 return CAMERA_ERROR_INVALID_PARAMETER;
4195 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4197 if (ret == CAMERA_ERROR_NONE)
4198 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4200 LOGD("ret : 0x%x", ret);
4206 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4208 int ret = CAMERA_ERROR_NONE;
4209 camera_cli_s *pc = (camera_cli_s *)camera;
4210 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4212 if (!pc || !pc->cb_info || !foreach_cb) {
4213 LOGE("NULL pointer %p %p", pc, foreach_cb);
4214 return CAMERA_ERROR_INVALID_PARAMETER;
4219 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4220 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4222 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4224 LOGD("Finish, return :%x", ret);
4230 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4232 int ret = CAMERA_ERROR_NONE;
4233 camera_cli_s *pc = (camera_cli_s *)camera;
4234 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4235 camera_msg_param param;
4236 int set_fps = (int)fps;
4238 if (!pc || !pc->cb_info) {
4239 LOGE("NULL handle");
4240 return CAMERA_ERROR_INVALID_PARAMETER;
4245 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4247 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4249 LOGD("ret : 0x%x", ret);
4255 int camera_attr_set_image_quality(camera_h camera, int quality)
4257 int ret = CAMERA_ERROR_NONE;
4258 camera_cli_s *pc = (camera_cli_s *)camera;
4259 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4260 camera_msg_param param;
4262 if (!pc || !pc->cb_info) {
4263 LOGE("NULL handle");
4264 return CAMERA_ERROR_INVALID_PARAMETER;
4269 CAMERA_MSG_PARAM_SET(param, INT, quality);
4271 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4273 LOGD("ret : 0x%x", ret);
4279 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4281 int ret = CAMERA_ERROR_NONE;
4282 camera_cli_s *pc = (camera_cli_s *)camera;
4283 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4285 if (!pc || !pc->cb_info || !fps) {
4286 LOGE("NULL pointer %p %p", pc, fps);
4287 return CAMERA_ERROR_INVALID_PARAMETER;
4292 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4294 if (ret == CAMERA_ERROR_NONE)
4295 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4297 LOGD("ret : 0x%x", ret);
4303 int camera_attr_get_image_quality(camera_h camera, int *quality)
4305 int ret = CAMERA_ERROR_NONE;
4306 camera_cli_s *pc = (camera_cli_s *)camera;
4307 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4309 if (!pc || !pc->cb_info || !quality) {
4310 LOGE("NULL pointer %p %p", pc, quality);
4311 return CAMERA_ERROR_INVALID_PARAMETER;
4316 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4318 if (ret == CAMERA_ERROR_NONE)
4319 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4321 LOGD("ret : 0x%x", ret);
4327 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4329 int ret = CAMERA_ERROR_NONE;
4330 camera_cli_s *pc = (camera_cli_s *)camera;
4331 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4333 if (!pc || !pc->cb_info || !bitrate) {
4334 LOGE("NULL pointer %p %p", pc, bitrate);
4335 return CAMERA_ERROR_INVALID_PARAMETER;
4340 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4342 if (ret == CAMERA_ERROR_NONE)
4343 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4345 LOGD("ret : 0x%x", ret);
4351 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4353 int ret = CAMERA_ERROR_NONE;
4354 camera_cli_s *pc = (camera_cli_s *)camera;
4355 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4356 camera_msg_param param;
4357 int set_bitrate = bitrate;
4359 if (!pc || !pc->cb_info) {
4360 LOGE("NULL handle");
4361 return CAMERA_ERROR_INVALID_PARAMETER;
4366 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4368 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4370 LOGD("ret : 0x%x", ret);
4376 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4378 int ret = CAMERA_ERROR_NONE;
4379 camera_cli_s *pc = (camera_cli_s *)camera;
4380 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4382 if (!pc || !pc->cb_info || !interval) {
4383 LOGE("NULL pointer %p %p", pc, interval);
4384 return CAMERA_ERROR_INVALID_PARAMETER;
4389 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4391 if (ret == CAMERA_ERROR_NONE)
4392 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4394 LOGD("ret : 0x%x", ret);
4400 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4402 int ret = CAMERA_ERROR_NONE;
4403 camera_cli_s *pc = (camera_cli_s *)camera;
4404 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4405 camera_msg_param param;
4406 int set_gop_interval = interval;
4408 if (!pc || !pc->cb_info) {
4409 LOGE("NULL handle");
4410 return CAMERA_ERROR_INVALID_PARAMETER;
4415 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4417 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4419 LOGD("ret : 0x%x", ret);
4425 int camera_attr_set_zoom(camera_h camera, int zoom)
4427 int ret = CAMERA_ERROR_NONE;
4428 camera_cli_s *pc = (camera_cli_s *)camera;
4429 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4430 camera_msg_param param;
4432 if (!pc || !pc->cb_info) {
4433 LOGE("NULL handle");
4434 return CAMERA_ERROR_INVALID_PARAMETER;
4437 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4439 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4441 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4443 LOGD("ret : 0x%x", ret);
4449 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4451 int ret = CAMERA_ERROR_NONE;
4452 camera_cli_s *pc = (camera_cli_s *)camera;
4453 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4454 camera_msg_param param;
4455 int set_mode = (int)mode;
4457 if (!pc || !pc->cb_info) {
4458 LOGE("NULL handle");
4459 return CAMERA_ERROR_INVALID_PARAMETER;
4462 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4464 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4466 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4472 int camera_attr_set_af_area(camera_h camera, int x, int y)
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_SET_AF_AREA;
4477 camera_msg_param param;
4480 if (!pc || !pc->cb_info) {
4481 LOGE("NULL handle");
4482 return CAMERA_ERROR_INVALID_PARAMETER;
4485 LOGD("Enter - %d,%d", x, y);
4487 value = (x << 16) | y;
4488 CAMERA_MSG_PARAM_SET(param, INT, value);
4490 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4492 LOGD("ret : 0x%x", ret);
4498 int camera_attr_clear_af_area(camera_h camera)
4500 int ret = CAMERA_ERROR_NONE;
4501 camera_cli_s *pc = (camera_cli_s *)camera;
4502 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4504 if (!pc || !pc->cb_info) {
4505 LOGE("NULL handle");
4506 return CAMERA_ERROR_INVALID_PARAMETER;
4511 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4513 LOGD("ret : 0x%x", ret);
4519 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4521 int ret = CAMERA_ERROR_NONE;
4522 camera_cli_s *pc = (camera_cli_s *)camera;
4523 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4524 camera_msg_param param;
4525 int set_mode = (int)mode;
4527 if (!pc || !pc->cb_info) {
4528 LOGE("NULL handle");
4529 return CAMERA_ERROR_INVALID_PARAMETER;
4534 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4536 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4538 LOGD("ret : 0x%x", ret);
4544 int camera_attr_set_exposure(camera_h camera, int value)
4546 int ret = CAMERA_ERROR_NONE;
4547 camera_cli_s *pc = (camera_cli_s *)camera;
4548 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4549 camera_msg_param param;
4551 if (!pc || !pc->cb_info) {
4552 LOGE("NULL handle");
4553 return CAMERA_ERROR_INVALID_PARAMETER;
4558 CAMERA_MSG_PARAM_SET(param, INT, value);
4560 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4562 LOGD("ret : 0x%x", ret);
4568 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4570 int ret = CAMERA_ERROR_NONE;
4571 camera_cli_s *pc = (camera_cli_s *)camera;
4572 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4573 camera_msg_param param;
4574 int set_iso = (int)iso;
4576 if (!pc || !pc->cb_info) {
4577 LOGE("NULL handle");
4578 return CAMERA_ERROR_INVALID_PARAMETER;
4583 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4585 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4587 LOGD("ret : 0x%x", ret);
4593 int camera_attr_set_brightness(camera_h camera, int level)
4595 int ret = CAMERA_ERROR_NONE;
4596 camera_cli_s *pc = (camera_cli_s *)camera;
4597 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4598 camera_msg_param param;
4600 if (!pc || !pc->cb_info) {
4601 LOGE("NULL handle");
4602 return CAMERA_ERROR_INVALID_PARAMETER;
4607 CAMERA_MSG_PARAM_SET(param, INT, level);
4609 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4611 LOGD("ret : 0x%x", ret);
4617 int camera_attr_set_contrast(camera_h camera, int level)
4619 int ret = CAMERA_ERROR_NONE;
4620 camera_cli_s *pc = (camera_cli_s *)camera;
4621 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4622 camera_msg_param param;
4624 if (!pc || !pc->cb_info) {
4625 LOGE("NULL handle");
4626 return CAMERA_ERROR_INVALID_PARAMETER;
4631 CAMERA_MSG_PARAM_SET(param, INT, level);
4633 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4635 LOGD("ret : 0x%x", ret);
4641 int camera_attr_set_hue(camera_h camera, int level)
4643 int ret = CAMERA_ERROR_NONE;
4644 camera_cli_s *pc = (camera_cli_s *)camera;
4645 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HUE;
4646 camera_msg_param param;
4648 if (!pc || !pc->cb_info) {
4649 LOGE("NULL handle");
4650 return CAMERA_ERROR_INVALID_PARAMETER;
4655 CAMERA_MSG_PARAM_SET(param, INT, level);
4657 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4659 LOGD("ret : 0x%x", ret);
4665 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4667 int ret = CAMERA_ERROR_NONE;
4668 camera_cli_s *pc = (camera_cli_s *)camera;
4669 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4670 camera_msg_param param;
4671 int set_whitebalance = (int)wb;
4673 if (!pc || !pc->cb_info) {
4674 LOGE("NULL handle");
4675 return CAMERA_ERROR_INVALID_PARAMETER;
4680 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4682 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4684 LOGD("ret : 0x%x", ret);
4690 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4692 int ret = CAMERA_ERROR_NONE;
4693 camera_cli_s *pc = (camera_cli_s *)camera;
4694 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4695 camera_msg_param param;
4696 int set_effect = (int)effect;
4698 if (!pc || !pc->cb_info) {
4699 LOGE("NULL handle");
4700 return CAMERA_ERROR_INVALID_PARAMETER;
4705 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4707 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4709 LOGD("ret : 0x%x", ret);
4715 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4717 int ret = CAMERA_ERROR_NONE;
4718 camera_cli_s *pc = (camera_cli_s *)camera;
4719 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4720 camera_msg_param param;
4721 int set_mode = (int)mode;
4723 if (!pc || !pc->cb_info) {
4724 LOGE("NULL handle");
4725 return CAMERA_ERROR_INVALID_PARAMETER;
4730 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4732 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4734 LOGD("ret : 0x%x", ret);
4740 int camera_attr_enable_tag(camera_h camera, bool enable)
4742 int ret = CAMERA_ERROR_NONE;
4743 camera_cli_s *pc = (camera_cli_s *)camera;
4744 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4745 camera_msg_param param;
4746 int set_enable = (int)enable;
4748 if (!pc || !pc->cb_info) {
4749 LOGE("NULL handle");
4750 return CAMERA_ERROR_INVALID_PARAMETER;
4755 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4757 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4759 LOGD("ret : 0x%x", ret);
4765 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4767 int ret = CAMERA_ERROR_NONE;
4768 camera_cli_s *pc = (camera_cli_s *)camera;
4769 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4770 camera_msg_param param;
4772 if (!pc || !pc->cb_info || !description) {
4773 LOGE("NULL pointer %p %p", pc, description);
4774 return CAMERA_ERROR_INVALID_PARAMETER;
4779 CAMERA_MSG_PARAM_SET(param, STRING, description);
4781 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4783 LOGD("ret : 0x%x", ret);
4789 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4791 int ret = CAMERA_ERROR_NONE;
4792 camera_cli_s *pc = (camera_cli_s *)camera;
4793 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4794 camera_msg_param param;
4795 int set_orientation = (int)orientation;
4797 if (!pc || !pc->cb_info) {
4798 LOGE("NULL handle");
4799 return CAMERA_ERROR_INVALID_PARAMETER;
4804 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4806 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4808 LOGD("ret : 0x%x", ret);
4814 int camera_attr_set_tag_software(camera_h camera, const char *software)
4816 int ret = CAMERA_ERROR_NONE;
4817 camera_cli_s *pc = (camera_cli_s *)camera;
4818 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4819 camera_msg_param param;
4821 if (!pc || !pc->cb_info || !software) {
4822 LOGE("NULL pointer %p %p", pc, software);
4823 return CAMERA_ERROR_INVALID_PARAMETER;
4826 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4828 CAMERA_MSG_PARAM_SET(param, STRING, software);
4830 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4832 LOGD("ret : 0x%x", ret);
4838 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4840 int ret = CAMERA_ERROR_NONE;
4841 camera_cli_s *pc = (camera_cli_s *)camera;
4842 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4843 double set_geotag[3] = {latitude, longitude, altitude};
4848 if (!pc || !pc->cb_info) {
4849 LOGE("NULL handle");
4850 return CAMERA_ERROR_INVALID_PARAMETER;
4855 length = sizeof(set_geotag) / sizeof(int) + \
4856 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4858 msg = muse_core_msg_new(api,
4859 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4862 LOGE("msg creation failed: api %d", api);
4863 return CAMERA_ERROR_OUT_OF_MEMORY;
4866 if (pc->cb_info->is_server_connected) {
4867 __camera_update_api_waiting(pc->cb_info, api, 1);
4869 g_mutex_lock(&pc->cb_info->fd_lock);
4870 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
4871 g_mutex_unlock(&pc->cb_info->fd_lock);
4875 LOGE("message send failed");
4876 ret = CAMERA_ERROR_INVALID_OPERATION;
4878 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
4881 __camera_update_api_waiting(pc->cb_info, api, -1);
4883 muse_core_msg_free(msg);
4885 LOGD("ret : 0x%x", ret);
4891 int camera_attr_remove_geotag(camera_h camera)
4893 int ret = CAMERA_ERROR_NONE;
4894 camera_cli_s *pc = (camera_cli_s *)camera;
4895 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4897 if (!pc || !pc->cb_info) {
4898 LOGE("NULL handle");
4899 return CAMERA_ERROR_INVALID_PARAMETER;
4904 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4906 LOGD("ret : 0x%x", ret);
4912 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4914 int ret = CAMERA_ERROR_NONE;
4915 camera_cli_s *pc = (camera_cli_s *)camera;
4916 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
4917 camera_msg_param param;
4918 int set_mode = (int)mode;
4920 if (!pc || !pc->cb_info) {
4921 LOGE("NULL handle");
4922 return CAMERA_ERROR_INVALID_PARAMETER;
4927 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4929 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4931 LOGD("ret : 0x%x", ret);
4937 int camera_attr_get_zoom(camera_h camera, int *zoom)
4939 int ret = CAMERA_ERROR_NONE;
4940 camera_cli_s *pc = (camera_cli_s *)camera;
4941 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4943 if (!pc || !pc->cb_info || !zoom) {
4944 LOGE("NULL pointer %p %p", pc, zoom);
4945 return CAMERA_ERROR_INVALID_PARAMETER;
4950 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4952 if (ret == CAMERA_ERROR_NONE)
4953 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
4955 LOGD("ret : 0x%x", ret);
4961 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
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_ZOOM_RANGE;
4967 if (!pc || !pc->cb_info || !min || !max) {
4968 LOGE("NULL pointer %p %p %p", pc, min, max);
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 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
4978 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
4981 LOGD("ret : 0x%x", ret);
4987 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
4989 int ret = CAMERA_ERROR_NONE;
4990 camera_cli_s *pc = (camera_cli_s *)camera;
4991 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
4993 if (!pc || !pc->cb_info || !mode) {
4994 LOGE("NULL pointer %p %p", pc, mode);
4995 return CAMERA_ERROR_INVALID_PARAMETER;
5000 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5002 if (ret == CAMERA_ERROR_NONE)
5003 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
5005 LOGD("ret : 0x%x", ret);
5011 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5013 int ret = CAMERA_ERROR_NONE;
5014 camera_cli_s *pc = (camera_cli_s *)camera;
5015 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5017 if (!pc || !pc->cb_info || !mode) {
5018 LOGE("NULL pointer %p %p", pc, mode);
5019 return CAMERA_ERROR_INVALID_PARAMETER;
5024 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5026 if (ret == CAMERA_ERROR_NONE)
5027 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5029 LOGD("ret : 0x%x", ret);
5035 int camera_attr_get_exposure(camera_h camera, int *value)
5037 int ret = CAMERA_ERROR_NONE;
5038 camera_cli_s *pc = (camera_cli_s *)camera;
5039 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5041 if (!pc || !pc->cb_info || !value) {
5042 LOGE("NULL pointer %p %p", pc, value);
5043 return CAMERA_ERROR_INVALID_PARAMETER;
5048 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5050 if (ret == CAMERA_ERROR_NONE)
5051 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5053 LOGD("ret : 0x%x", ret);
5059 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
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_EXPOSURE_RANGE;
5065 if (!pc || !pc->cb_info || !min || !max) {
5066 LOGE("NULL pointer %p %p %p", pc, min, max);
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 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5076 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5079 LOGD("ret : 0x%x", ret);
5085 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5087 int ret = CAMERA_ERROR_NONE;
5088 camera_cli_s *pc = (camera_cli_s *)camera;
5089 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5091 if (!pc || !pc->cb_info || !iso) {
5092 LOGE("NULL pointer %p %p", pc, iso);
5093 return CAMERA_ERROR_INVALID_PARAMETER;
5098 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5100 if (ret == CAMERA_ERROR_NONE)
5101 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5103 LOGD("ret : 0x%x", ret);
5109 int camera_attr_get_brightness(camera_h camera, int *level)
5111 int ret = CAMERA_ERROR_NONE;
5112 camera_cli_s *pc = (camera_cli_s *)camera;
5113 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5115 if (!pc || !pc->cb_info || !level) {
5116 LOGE("NULL pointer %p %p", pc, level);
5117 return CAMERA_ERROR_INVALID_PARAMETER;
5122 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5124 if (ret == CAMERA_ERROR_NONE)
5125 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5127 LOGD("ret : 0x%x", ret);
5133 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
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_BRIGHTNESS_RANGE;
5139 if (!pc || !pc->cb_info || !min || !max) {
5140 LOGE("NULL pointer %p %p %p", pc, min, max);
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 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5150 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5153 LOGD("ret : 0x%x", ret);
5159 int camera_attr_get_contrast(camera_h camera, int *level)
5161 int ret = CAMERA_ERROR_NONE;
5162 camera_cli_s *pc = (camera_cli_s *)camera;
5163 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5165 if (!pc || !pc->cb_info || !level) {
5166 LOGE("NULL pointer %p %p", pc, level);
5167 return CAMERA_ERROR_INVALID_PARAMETER;
5172 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5174 if (ret == CAMERA_ERROR_NONE)
5175 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5177 LOGD("ret : 0x%x", ret);
5183 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5185 int ret = CAMERA_ERROR_NONE;
5186 camera_cli_s *pc = (camera_cli_s *)camera;
5187 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5189 if (!pc || !pc->cb_info || !min || !max) {
5190 LOGE("NULL pointer %p %p %p", pc, min, max);
5191 return CAMERA_ERROR_INVALID_PARAMETER;
5196 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5198 if (ret == CAMERA_ERROR_NONE) {
5199 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5200 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5201 LOGD("min %d, max %d", *min, *max);
5204 LOGD("ret : 0x%x", ret);
5210 int camera_attr_get_hue(camera_h camera, int *level)
5212 int ret = CAMERA_ERROR_NONE;
5213 camera_cli_s *pc = (camera_cli_s *)camera;
5214 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE;
5216 if (!pc || !pc->cb_info || !level) {
5217 LOGE("NULL pointer %p %p", pc, level);
5218 return CAMERA_ERROR_INVALID_PARAMETER;
5223 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5225 if (ret == CAMERA_ERROR_NONE)
5226 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HUE];
5228 LOGD("ret : 0x%x", ret);
5234 int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
5236 int ret = CAMERA_ERROR_NONE;
5237 camera_cli_s *pc = (camera_cli_s *)camera;
5238 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE_RANGE;
5240 if (!pc || !pc->cb_info || !min || !max) {
5241 LOGE("NULL pointer %p %p %p", pc, min, max);
5242 return CAMERA_ERROR_INVALID_PARAMETER;
5247 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5249 if (ret == CAMERA_ERROR_NONE) {
5250 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][0];
5251 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][1];
5252 LOGD("min %d, max %d", *min, *max);
5255 LOGD("ret : 0x%x", ret);
5261 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5263 int ret = CAMERA_ERROR_NONE;
5264 camera_cli_s *pc = (camera_cli_s *)camera;
5265 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5267 if (!pc || !pc->cb_info || !wb) {
5268 LOGE("NULL pointer %p %p", pc, wb);
5269 return CAMERA_ERROR_INVALID_PARAMETER;
5274 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5276 if (ret == CAMERA_ERROR_NONE)
5277 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5279 LOGD("ret : 0x%x", ret);
5285 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5287 int ret = CAMERA_ERROR_NONE;
5288 camera_cli_s *pc = (camera_cli_s *)camera;
5289 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5291 if (!pc || !pc->cb_info || !effect) {
5292 LOGE("NULL pointer %p %p", pc, effect);
5293 return CAMERA_ERROR_INVALID_PARAMETER;
5298 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5300 if (ret == CAMERA_ERROR_NONE)
5301 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5303 LOGD("ret : 0x%x", ret);
5309 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5311 int ret = CAMERA_ERROR_NONE;
5312 camera_cli_s *pc = (camera_cli_s *)camera;
5313 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5315 if (!pc || !pc->cb_info || !mode) {
5316 LOGE("NULL pointer %p %p", pc, mode);
5317 return CAMERA_ERROR_INVALID_PARAMETER;
5322 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5324 if (ret == CAMERA_ERROR_NONE)
5325 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5327 LOGD("ret : 0x%x", ret);
5333 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5335 int ret = CAMERA_ERROR_NONE;
5336 camera_cli_s *pc = (camera_cli_s *)camera;
5337 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5339 if (!pc || !pc->cb_info || !enable) {
5340 LOGE("NULL pointer %p %p", pc, enable);
5341 return CAMERA_ERROR_INVALID_PARAMETER;
5346 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5348 if (ret == CAMERA_ERROR_NONE)
5349 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5351 LOGD("ret : 0x%x", ret);
5357 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5359 int ret = CAMERA_ERROR_NONE;
5360 camera_cli_s *pc = (camera_cli_s *)camera;
5361 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5363 if (!pc || !pc->cb_info || !description) {
5364 LOGE("NULL pointer %p %p", pc, description);
5365 return CAMERA_ERROR_INVALID_PARAMETER;
5370 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5372 if (ret == CAMERA_ERROR_NONE)
5373 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5375 LOGD("ret : 0x%x", ret);
5381 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5383 int ret = CAMERA_ERROR_NONE;
5384 camera_cli_s *pc = (camera_cli_s *)camera;
5385 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5387 if (!pc || !pc->cb_info || !orientation) {
5388 LOGE("NULL pointer %p %p", pc, orientation);
5389 return CAMERA_ERROR_INVALID_PARAMETER;
5394 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5396 if (ret == CAMERA_ERROR_NONE)
5397 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5399 LOGD("ret : 0x%x", ret);
5405 int camera_attr_get_tag_software(camera_h camera, char **software)
5407 int ret = CAMERA_ERROR_NONE;
5408 camera_cli_s *pc = (camera_cli_s *)camera;
5409 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5411 if (!pc || !pc->cb_info || !software) {
5412 LOGE("NULL pointer %p %p", pc, software);
5413 return CAMERA_ERROR_INVALID_PARAMETER;
5418 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5420 if (ret == CAMERA_ERROR_NONE)
5421 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5423 LOGD("ret : 0x%x", ret);
5429 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5431 int ret = CAMERA_ERROR_NONE;
5432 camera_cli_s *pc = (camera_cli_s *)camera;
5433 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5435 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5436 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5437 return CAMERA_ERROR_INVALID_PARAMETER;
5442 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5444 if (ret == CAMERA_ERROR_NONE) {
5445 *latitude = pc->cb_info->get_geotag[0];
5446 *longitude = pc->cb_info->get_geotag[1];
5447 *altitude = pc->cb_info->get_geotag[2];
5450 LOGD("ret : 0x%x", ret);
5456 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5458 int ret = CAMERA_ERROR_NONE;
5459 camera_cli_s *pc = (camera_cli_s *)camera;
5460 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5462 if (!pc || !pc->cb_info || !mode) {
5463 LOGE("NULL pointer %p %p", pc, mode);
5464 return CAMERA_ERROR_INVALID_PARAMETER;
5469 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5471 if (ret == CAMERA_ERROR_NONE)
5472 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5474 LOGD("ret : 0x%x", ret);
5480 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5482 int ret = CAMERA_ERROR_NONE;
5483 int get_flash_state = 0;
5486 LOGE("NULL pointer");
5487 return CAMERA_ERROR_INVALID_PARAMETER;
5490 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5491 (int)device, "get_flash_state", &get_flash_state);
5493 if (ret == CAMERA_ERROR_NONE) {
5494 *state = (camera_flash_state_e)get_flash_state;
5495 LOGD("flash state %d", *state);
5497 LOGE("failed 0x%x", ret);
5504 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5506 int ret = CAMERA_ERROR_NONE;
5507 camera_cli_s *pc = (camera_cli_s *)camera;
5508 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5510 if (!pc || !pc->cb_info || !foreach_cb) {
5511 LOGE("NULL pointer %p %p", pc, foreach_cb);
5512 return CAMERA_ERROR_INVALID_PARAMETER;
5517 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5518 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5520 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5522 LOGD("ret : 0x%x", ret);
5528 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5530 int ret = CAMERA_ERROR_NONE;
5531 camera_cli_s *pc = (camera_cli_s *)camera;
5532 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5534 if (!pc || !pc->cb_info || !foreach_cb) {
5535 LOGE("NULL pointer %p %p", pc, foreach_cb);
5536 return CAMERA_ERROR_INVALID_PARAMETER;
5541 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5542 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5544 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5546 LOGD("ret : 0x%x", ret);
5552 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5554 int ret = CAMERA_ERROR_NONE;
5555 camera_cli_s *pc = (camera_cli_s *)camera;
5556 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5558 if (!pc || !pc->cb_info || !foreach_cb) {
5559 LOGE("NULL pointer %p %p", pc, foreach_cb);
5560 return CAMERA_ERROR_INVALID_PARAMETER;
5565 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5566 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5568 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5570 LOGD("ret : 0x%x", ret);
5576 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5578 int ret = CAMERA_ERROR_NONE;
5579 camera_cli_s *pc = (camera_cli_s *)camera;
5580 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5582 if (!pc || !pc->cb_info || !foreach_cb) {
5583 LOGE("NULL pointer %p %p", pc, foreach_cb);
5584 return CAMERA_ERROR_INVALID_PARAMETER;
5589 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5590 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5592 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5594 LOGD("ret : 0x%x", ret);
5600 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5602 int ret = CAMERA_ERROR_NONE;
5603 camera_cli_s *pc = (camera_cli_s *)camera;
5604 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5606 if (!pc || !pc->cb_info || !foreach_cb) {
5607 LOGE("NULL pointer %p %p", pc, foreach_cb);
5608 return CAMERA_ERROR_INVALID_PARAMETER;
5613 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5614 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5616 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5618 LOGD("ret : 0x%x", ret);
5624 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5626 int ret = CAMERA_ERROR_NONE;
5627 camera_cli_s *pc = (camera_cli_s *)camera;
5628 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5630 if (!pc || !pc->cb_info || !foreach_cb) {
5631 LOGE("NULL pointer %p %p", pc, foreach_cb);
5632 return CAMERA_ERROR_INVALID_PARAMETER;
5637 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5638 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5640 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5642 LOGD("ret : 0x%x", ret);
5648 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5650 int ret = CAMERA_ERROR_NONE;
5651 camera_cli_s *pc = (camera_cli_s *)camera;
5652 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5654 if (!pc || !pc->cb_info || !foreach_cb) {
5655 LOGE("NULL pointer %p %p", pc, foreach_cb);
5656 return CAMERA_ERROR_INVALID_PARAMETER;
5661 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5662 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5664 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5666 LOGD("ret : 0x%x", ret);
5672 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5674 int ret = CAMERA_ERROR_NONE;
5675 camera_cli_s *pc = (camera_cli_s *)camera;
5676 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
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] = foreach_cb;
5686 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5688 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5690 LOGD("Enter, handle :%x", pc->remote_handle);
5696 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)
5698 int ret = CAMERA_ERROR_NONE;
5699 camera_cli_s *pc = (camera_cli_s *)camera;
5700 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5701 camera_msg_param param;
5704 if (!pc || !pc->cb_info || !foreach_cb) {
5705 LOGE("NULL pointer %p %p", pc, foreach_cb);
5706 return CAMERA_ERROR_INVALID_PARAMETER;
5711 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5712 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5714 value = (width << 16) | height;
5715 CAMERA_MSG_PARAM_SET(param, INT, value);
5717 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5719 LOGD("ret : 0x%x", ret);
5725 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5727 int ret = CAMERA_ERROR_NONE;
5728 camera_cli_s *pc = (camera_cli_s *)camera;
5729 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5731 if (!pc || !pc->cb_info || !foreach_cb) {
5732 LOGE("NULL pointer %p %p", pc, foreach_cb);
5733 return CAMERA_ERROR_INVALID_PARAMETER;
5738 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5739 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5741 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5743 LOGD("ret : 0x%x", ret);
5749 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5751 int ret = CAMERA_ERROR_NONE;
5752 camera_cli_s *pc = (camera_cli_s *)camera;
5753 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5755 if (!pc || !pc->cb_info || !foreach_cb) {
5756 LOGE("NULL pointer %p %p", pc, foreach_cb);
5757 return CAMERA_ERROR_INVALID_PARAMETER;
5762 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5763 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5765 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5767 LOGD("ret : 0x%x", ret);
5773 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5775 int ret = CAMERA_ERROR_NONE;
5776 camera_cli_s *pc = (camera_cli_s *)camera;
5777 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5778 camera_msg_param param;
5779 int set_rotation = (int)rotation;
5781 if (!pc || !pc->cb_info) {
5782 LOGE("NULL handle");
5783 return CAMERA_ERROR_INVALID_PARAMETER;
5788 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5790 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5792 LOGD("ret : 0x%x", ret);
5798 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5800 int ret = CAMERA_ERROR_NONE;
5801 camera_cli_s *pc = (camera_cli_s *)camera;
5802 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5804 if (!pc || !pc->cb_info || !rotation) {
5805 LOGE("NULL pointer %p %p", pc, rotation);
5806 return CAMERA_ERROR_INVALID_PARAMETER;
5811 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5813 if (ret == CAMERA_ERROR_NONE)
5814 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5816 LOGD("ret : 0x%x", ret);
5822 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5824 int ret = CAMERA_ERROR_NONE;
5825 camera_cli_s *pc = (camera_cli_s *)camera;
5826 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5827 camera_msg_param param;
5828 int set_flip = (int)flip;
5830 if (!pc || !pc->cb_info) {
5831 LOGE("NULL handle");
5832 return CAMERA_ERROR_INVALID_PARAMETER;
5837 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5839 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5841 LOGD("ret : 0x%x", ret);
5847 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5849 int ret = CAMERA_ERROR_NONE;
5850 camera_cli_s *pc = (camera_cli_s *)camera;
5851 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5853 if (!pc || !pc->cb_info || !flip) {
5854 LOGE("NULL pointer %p %p", pc, flip);
5855 return CAMERA_ERROR_INVALID_PARAMETER;
5860 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5862 if (ret == CAMERA_ERROR_NONE)
5863 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5865 LOGD("ret : 0x%x", ret);
5870 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5872 int ret = CAMERA_ERROR_NONE;
5873 camera_cli_s *pc = (camera_cli_s *)camera;
5874 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5875 camera_msg_param param;
5876 int set_mode = (int)mode;
5878 if (!pc || !pc->cb_info) {
5879 LOGE("NULL handle");
5880 return CAMERA_ERROR_INVALID_PARAMETER;
5885 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5887 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5889 LOGD("ret : 0x%x", ret);
5895 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5897 int ret = CAMERA_ERROR_NONE;
5898 camera_cli_s *pc = (camera_cli_s *)camera;
5899 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5901 if (!pc || !pc->cb_info || !mode) {
5902 LOGE("NULL pointer %p %p", pc, mode);
5903 return CAMERA_ERROR_INVALID_PARAMETER;
5908 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5910 if (ret == CAMERA_ERROR_NONE)
5911 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
5913 LOGD("ret : 0x%x", ret);
5919 bool camera_attr_is_supported_hdr_capture(camera_h camera)
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_IS_SUPPORTED_HDR_CAPTURE;
5925 if (!pc || !pc->cb_info) {
5926 LOGE("NULL handle");
5927 return CAMERA_ERROR_INVALID_PARAMETER;
5932 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5935 LOGE("error is occurred 0x%x", ret);
5939 LOGD("ret : %d", ret);
5945 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5947 int ret = CAMERA_ERROR_NONE;
5948 camera_cli_s *pc = (camera_cli_s *)camera;
5949 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5951 if (!pc || !pc->cb_info) {
5952 LOGE("NULL handle");
5953 return CAMERA_ERROR_INVALID_PARAMETER;
5958 if (!camera_attr_is_supported_hdr_capture(camera)) {
5959 LOGE("HDR not supported");
5960 return CAMERA_ERROR_NOT_SUPPORTED;
5964 LOGE("NULL callback");
5965 return CAMERA_ERROR_INVALID_PARAMETER;
5968 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5970 if (ret == CAMERA_ERROR_NONE) {
5971 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5973 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5974 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5976 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5979 LOGD("ret : 0x%x", ret);
5985 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5987 int ret = CAMERA_ERROR_NONE;
5988 camera_cli_s *pc = (camera_cli_s *)camera;
5989 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5991 if (!pc || !pc->cb_info) {
5992 LOGE("NULL handle");
5993 return CAMERA_ERROR_INVALID_PARAMETER;
5998 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6000 if (ret == CAMERA_ERROR_NONE) {
6001 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6003 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6004 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
6006 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6009 LOGD("ret : 0x%x", ret);
6015 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6017 int ret = CAMERA_ERROR_NONE;
6018 camera_cli_s *pc = (camera_cli_s *)camera;
6019 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
6020 camera_msg_param param;
6021 int set_enable = (int)enable;
6023 if (!pc || !pc->cb_info) {
6024 LOGE("NULL handle");
6025 return CAMERA_ERROR_INVALID_PARAMETER;
6030 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6032 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6034 LOGD("ret : 0x%x", ret);
6040 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6042 int ret = CAMERA_ERROR_NONE;
6043 camera_cli_s *pc = (camera_cli_s *)camera;
6044 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6046 if (!pc || !pc->cb_info || !enabled) {
6047 LOGE("NULL pointer %p %p", pc, enabled);
6048 return CAMERA_ERROR_INVALID_PARAMETER;
6053 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6055 if (ret == CAMERA_ERROR_NONE)
6056 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6058 LOGD("ret : 0x%x", ret);
6064 bool camera_attr_is_supported_anti_shake(camera_h camera)
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_IS_SUPPORTED_ANTI_SHAKE;
6070 if (!pc || !pc->cb_info) {
6071 LOGE("NULL handle");
6072 return CAMERA_ERROR_INVALID_PARAMETER;
6077 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6080 LOGE("error is occurred 0x%x", ret);
6084 LOGD("ret : %d", ret);
6090 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6092 int ret = CAMERA_ERROR_NONE;
6093 camera_cli_s *pc = (camera_cli_s *)camera;
6094 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6095 camera_msg_param param;
6096 int set_enable = (int)enable;
6098 if (!pc || !pc->cb_info) {
6099 LOGE("NULL handle");
6100 return CAMERA_ERROR_INVALID_PARAMETER;
6105 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6107 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6109 LOGD("ret : 0x%x", ret);
6115 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6117 int ret = CAMERA_ERROR_NONE;
6118 camera_cli_s *pc = (camera_cli_s *)camera;
6119 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6121 if (!pc || !pc->cb_info || !enabled) {
6122 LOGE("NULL pointer %p %p", pc, enabled);
6123 return CAMERA_ERROR_INVALID_PARAMETER;
6128 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6130 if (ret == CAMERA_ERROR_NONE)
6131 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6133 LOGD("ret : 0x%x", ret);
6139 bool camera_attr_is_supported_video_stabilization(camera_h camera)
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_IS_SUPPORTED_VIDEO_STABILIZATION;
6145 if (!pc || !pc->cb_info) {
6146 LOGE("NULL handle");
6147 return CAMERA_ERROR_INVALID_PARAMETER;
6152 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6155 LOGE("error is occurred 0x%x", ret);
6159 LOGD("ret : %d", ret);
6165 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6167 int ret = CAMERA_ERROR_NONE;
6168 camera_cli_s *pc = (camera_cli_s *)camera;
6169 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6170 camera_msg_param param;
6171 int set_enable = (int)enable;
6173 if (!pc || !pc->cb_info) {
6174 LOGE("NULL handle");
6175 return CAMERA_ERROR_INVALID_PARAMETER;
6180 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6182 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6184 LOGD("ret : 0x%x", ret);
6190 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6192 int ret = CAMERA_ERROR_NONE;
6193 camera_cli_s *pc = (camera_cli_s *)camera;
6194 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6196 if (!pc || !pc->cb_info || !enabled) {
6197 LOGE("NULL pointer %p %p", pc, enabled);
6198 return CAMERA_ERROR_INVALID_PARAMETER;
6203 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6205 if (ret == CAMERA_ERROR_NONE)
6206 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6208 LOGD("ret : 0x%x", ret);
6214 bool camera_attr_is_supported_auto_contrast(camera_h camera)
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_IS_SUPPORTED_AUTO_CONTRAST;
6220 if (!pc || !pc->cb_info) {
6221 LOGE("NULL handle");
6222 return CAMERA_ERROR_INVALID_PARAMETER;
6227 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6230 LOGE("error is occurred 0x%x", ret);
6234 LOGD("ret : %d", ret);
6240 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6242 int ret = CAMERA_ERROR_NONE;
6243 camera_cli_s *pc = (camera_cli_s *)camera;
6244 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6245 camera_msg_param param;
6246 int set_disable = (int)disable;
6248 if (!pc || !pc->cb_info) {
6249 LOGE("NULL handle");
6250 return CAMERA_ERROR_INVALID_PARAMETER;
6255 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6257 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6259 LOGD("ret : 0x%x", ret);
6265 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6267 int ret = CAMERA_ERROR_NONE;
6268 camera_cli_s *pc = (camera_cli_s *)camera;
6269 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6270 camera_msg_param param;
6271 int set_move_type = (int)move_type;
6274 if (!pc || !pc->cb_info) {
6275 LOGE("NULL handle");
6276 return CAMERA_ERROR_INVALID_PARAMETER;
6281 value = (set_move_type << 16) | pan_step;
6282 CAMERA_MSG_PARAM_SET(param, INT, value);
6284 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6286 LOGD("ret : 0x%x", ret);
6292 int camera_attr_get_pan(camera_h camera, int *pan_step)
6294 int ret = CAMERA_ERROR_NONE;
6295 camera_cli_s *pc = (camera_cli_s *)camera;
6296 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6298 if (!pc || !pc->cb_info || !pan_step) {
6299 LOGE("NULL pointer %p %p", pc, pan_step);
6300 return CAMERA_ERROR_INVALID_PARAMETER;
6305 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6307 if (ret == CAMERA_ERROR_NONE)
6308 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6310 LOGD("ret : 0x%x", ret);
6316 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
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_GET_PAN_RANGE;
6322 if (!pc || !pc->cb_info || !min || !max) {
6323 LOGE("NULL pointer %p %p %p", pc, min, max);
6324 return CAMERA_ERROR_INVALID_PARAMETER;
6329 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6331 if (ret == CAMERA_ERROR_NONE) {
6332 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6333 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6336 LOGD("ret : 0x%x", ret);
6342 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6344 int ret = CAMERA_ERROR_NONE;
6345 camera_cli_s *pc = (camera_cli_s *)camera;
6346 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6347 camera_msg_param param;
6348 int set_move_type = (int)move_type;
6351 if (!pc || !pc->cb_info) {
6352 LOGE("NULL handle");
6353 return CAMERA_ERROR_INVALID_PARAMETER;
6358 value = (set_move_type << 16) | tilt_step;
6359 CAMERA_MSG_PARAM_SET(param, INT, value);
6361 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6363 LOGD("ret : 0x%x", ret);
6369 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6371 int ret = CAMERA_ERROR_NONE;
6372 camera_cli_s *pc = (camera_cli_s *)camera;
6373 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6375 if (!pc || !pc->cb_info || !tilt_step) {
6376 LOGE("NULL pointer %p %p", pc, tilt_step);
6377 return CAMERA_ERROR_INVALID_PARAMETER;
6382 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6384 if (ret == CAMERA_ERROR_NONE)
6385 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6387 LOGD("ret : 0x%x", ret);
6393 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
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_GET_TILT_RANGE;
6399 if (!pc || !pc->cb_info || !min || !max) {
6400 LOGE("NULL pointer %p %p %p", pc, min, max);
6401 return CAMERA_ERROR_INVALID_PARAMETER;
6406 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6408 if (ret == CAMERA_ERROR_NONE) {
6409 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6410 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6413 LOGD("ret : 0x%x", ret);
6419 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6421 int ret = CAMERA_ERROR_NONE;
6422 camera_cli_s *pc = (camera_cli_s *)camera;
6423 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6424 camera_msg_param param;
6425 int set_ptz_type = (int)ptz_type;
6427 if (!pc || !pc->cb_info) {
6428 LOGE("NULL handle");
6429 return CAMERA_ERROR_INVALID_PARAMETER;
6434 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6436 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6438 LOGD("ret : 0x%x", ret);
6444 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6446 int ret = CAMERA_ERROR_NONE;
6447 camera_cli_s *pc = (camera_cli_s *)camera;
6448 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6450 if (!pc || !pc->cb_info || !foreach_cb) {
6451 LOGE("NULL pointer %p %p", pc, foreach_cb);
6452 return CAMERA_ERROR_INVALID_PARAMETER;
6457 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6458 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6460 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6462 LOGD("ret : 0x%x", ret);
6468 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6470 int ret = CAMERA_ERROR_NONE;
6471 camera_cli_s *pc = (camera_cli_s *)camera;
6472 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6473 int set_display_roi_area[4] = {x, y, width, height};
6478 if (!pc || !pc->cb_info) {
6479 LOGE("NULL handle");
6480 return CAMERA_ERROR_INVALID_PARAMETER;
6485 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6486 ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
6487 if (ret != MM_ERROR_NONE) {
6488 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6489 return CAMERA_ERROR_INVALID_OPERATION;
6493 length = sizeof(set_display_roi_area) / sizeof(int) + \
6494 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6496 msg = muse_core_msg_new(api,
6497 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6500 LOGE("msg creation failed: api %d", api);
6501 return CAMERA_ERROR_OUT_OF_MEMORY;
6504 if (pc->cb_info->is_server_connected) {
6505 __camera_update_api_waiting(pc->cb_info, api, 1);
6507 g_mutex_lock(&pc->cb_info->fd_lock);
6508 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
6509 g_mutex_unlock(&pc->cb_info->fd_lock);
6513 LOGE("message send failed");
6514 ret = CAMERA_ERROR_INVALID_OPERATION;
6516 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6519 __camera_update_api_waiting(pc->cb_info, api, -1);
6521 muse_core_msg_free(msg);
6523 LOGD("ret : 0x%x", ret);
6529 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6531 camera_cli_s *pc = (camera_cli_s *)camera;
6532 int ret = CAMERA_ERROR_NONE;
6533 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6535 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6536 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6537 return CAMERA_ERROR_INVALID_PARAMETER;
6542 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6544 if (ret == CAMERA_ERROR_NONE) {
6545 *x = pc->cb_info->get_display_roi_area[0];
6546 *y = pc->cb_info->get_display_roi_area[1];
6547 *width = pc->cb_info->get_display_roi_area[2];
6548 *height = pc->cb_info->get_display_roi_area[3];
6551 LOGD("ret : 0x%x", ret);
6557 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6559 int ret = CAMERA_ERROR_NONE;
6560 int get_device_state = 0;
6563 LOGE("NULL pointer");
6564 return CAMERA_ERROR_INVALID_PARAMETER;
6567 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6568 (int)device, "get_device_state", &get_device_state);
6570 if (ret == CAMERA_ERROR_NONE) {
6571 *state = (camera_device_state_e)get_device_state;
6572 LOGD("device state %d", *state);
6574 LOGE("failed 0x%x", ret);
6581 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6583 int ret = CAMERA_ERROR_NONE;
6584 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6585 camera_cb_info *info = NULL;
6587 if (!callback || !cb_id) {
6588 LOGE("invalid pointer %p %p", callback, cb_id);
6589 return CAMERA_ERROR_INVALID_PARAMETER;
6592 /* check camera support */
6593 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6594 if (ret != CAMERA_ERROR_NONE) {
6595 LOGE("get device state failed");
6599 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6601 info = g_new0(camera_cb_info, 1);
6603 LOGE("info failed");
6604 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6608 info->id = ++g_cam_dev_state_changed_cb_id;
6609 info->callback = (void *)callback;
6610 info->user_data = user_data;
6614 /* subscribe dbus signal for camera state change */
6615 if (!g_cam_dev_state_changed_cb_conn) {
6616 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6617 if (!g_cam_dev_state_changed_cb_conn) {
6618 LOGE("failed to get gdbus connection");
6619 ret = CAMERA_ERROR_INVALID_OPERATION;
6623 LOGD("subscribe signal %s - %s - %s",
6624 MM_CAMCORDER_DBUS_OBJECT,
6625 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6626 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6628 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6629 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6630 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6631 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6632 LOGE("failed to get gdbus connection");
6633 ret = CAMERA_ERROR_INVALID_OPERATION;
6637 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6640 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6642 LOGD("callback id %d", info->id);
6645 if (ret != CAMERA_ERROR_NONE) {
6651 if (g_cam_dev_state_changed_cb_conn) {
6652 g_object_unref(g_cam_dev_state_changed_cb_conn);
6653 g_cam_dev_state_changed_cb_conn = NULL;
6657 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6663 int camera_remove_device_state_changed_cb(int cb_id)
6665 int ret = CAMERA_ERROR_NONE;
6666 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6667 GList *tmp_list = NULL;
6668 camera_cb_info *info = NULL;
6670 /* check camera support */
6671 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6672 if (ret != CAMERA_ERROR_NONE) {
6673 LOGE("get device state failed");
6677 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6679 if (!g_cam_dev_state_changed_cb_list) {
6680 LOGE("there is no callback info");
6681 ret = CAMERA_ERROR_INVALID_OPERATION;
6685 tmp_list = g_cam_dev_state_changed_cb_list;
6688 info = tmp_list->data;
6689 tmp_list = tmp_list->next;
6696 if (info->id == cb_id) {
6697 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6702 if (!g_cam_dev_state_changed_cb_list) {
6703 /* no remained callback */
6704 if (g_cam_dev_state_changed_cb_conn) {
6705 /* unsubscribe signal */
6706 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6707 g_cam_dev_state_changed_cb_subscribe_id = 0;
6709 /* unref connection */
6710 g_object_unref(g_cam_dev_state_changed_cb_conn);
6711 g_cam_dev_state_changed_cb_conn = NULL;
6715 LOGD("id %d callback removed", cb_id);
6716 ret = CAMERA_ERROR_NONE;
6722 LOGE("id %d callback not found", cb_id);
6723 ret = CAMERA_ERROR_INVALID_PARAMETER;
6726 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);