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 void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
50 int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout);
51 static int _camera_import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle);
52 static void _camera_release_imported_bo(tbm_bo *bo);
53 static void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_key,
54 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame);
55 static int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
56 camera_media_packet_data *mp_data, media_packet_h *packet);
57 static int _camera_media_packet_data_create(int tbm_key, int num_buffer_key, tbm_bo bo,
58 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data);
59 static void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info);
62 static void __camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value)
65 api < 0 || api >= MUSE_CAMERA_API_MAX) {
66 LOGE("invalid param %p %d", cb_info, api);
70 g_mutex_lock(&(cb_info->api_mutex[api]));
71 cb_info->api_waiting[api] += value;
72 g_mutex_unlock(&(cb_info->api_mutex[api]));
74 /*LOGD("api %d, value %d, waiting %d",
75 api, value, cb_info->api_waiting[api]);*/
81 static void __camera_device_state_changed_cb(GDBusConnection *connection,
82 const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
83 const gchar *signal_name, GVariant *param, gpointer user_data)
86 camera_device_e device = CAMERA_DEVICE_CAMERA0;
87 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
88 GList *tmp_list = NULL;
89 camera_cb_info *info = NULL;
91 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
93 if (!g_cam_dev_state_changed_cb_list || !param) {
94 LOGW("no callback or NULL param %p", param);
98 /* get device and state */
99 g_variant_get(param, "(i)", &value);
101 device = value >> 16;
102 state = 0x0000ffff & value;
104 LOGD("device %d, state %d", device, state);
106 tmp_list = g_cam_dev_state_changed_cb_list;
109 info = (camera_cb_info *)tmp_list->data;
112 if (info->callback) {
113 LOGD("start id[%d] callback", info->id);
114 ((camera_device_state_changed_cb)info->callback)(device, state, info->user_data);
115 LOGD("returned id[%d] callback", info->id);
117 LOGW("NULL callback for id %d", info->id);
121 tmp_list = tmp_list->next;
125 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
131 static void __camera_event_handler_preview(camera_cb_info_s *cb_info, char *recv_msg)
135 int num_buffer_key = 0;
136 int buffer_key[BUFFER_MAX_PLANE_NUM] = {0, };
139 unsigned char *buf_pos = NULL;
140 camera_msg_param param;
143 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
144 tbm_bo_handle bo_handle = {.ptr = NULL};
145 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
146 tbm_bo data_bo = NULL;
147 tbm_bo_handle data_bo_handle = {.ptr = NULL};
149 camera_preview_data_s frame;
150 camera_stream_data_s *stream = NULL;
151 camera_media_packet_data *mp_data = NULL;
152 media_packet_h pkt = NULL;
153 media_packet_h pkt_evas = NULL;
155 if (!cb_info || !recv_msg) {
156 LOGE("invalid param %p %p", cb_info, recv_msg);
160 muse_camera_msg_get(tbm_key, recv_msg);
161 muse_camera_msg_get(num_buffer_key, recv_msg);
162 muse_camera_msg_get_array(buffer_key, recv_msg);
163 muse_camera_msg_get(data_key, recv_msg);
165 memset(&frame, 0x0, sizeof(camera_preview_data_s));
168 LOGE("invalid key %d", tbm_key);
172 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
174 if (num_buffer_key < 0 || num_buffer_key > BUFFER_MAX_PLANE_NUM) {
175 LOGE("invalid num buffer key %d", num_buffer_key);
176 goto _PREVIEW_CB_HANDLER_DONE;
180 /* import tbm data_bo and get virtual address */
181 if (!_camera_import_tbm_key(cb_info->bufmgr, data_key, &data_bo, &data_bo_handle)) {
182 LOGE("failed to import data key %d", data_key);
183 goto _PREVIEW_CB_HANDLER_DONE;
187 /* import tbm bo and get virtual address */
188 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
189 LOGE("failed to import key %d", tbm_key);
190 goto _PREVIEW_CB_HANDLER_DONE;
193 buf_pos = (unsigned char *)bo_handle.ptr;
195 /* get stream info */
196 stream = (camera_stream_data_s *)buf_pos;
198 for (i = 0 ; i < num_buffer_key ; i++) {
199 /* import buffer bo and get virtual address */
200 if (!_camera_import_tbm_key(cb_info->bufmgr, buffer_key[i], &buffer_bo[i], &buffer_bo_handle[i])) {
201 LOGE("failed to import buffer key %d", buffer_key[i]);
202 goto _PREVIEW_CB_HANDLER_DONE;
206 /* call preview callback */
207 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
208 _camera_preview_frame_create(stream, num_buffer_key, buffer_bo_handle, &data_bo_handle, &frame);
210 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
211 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
214 if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
215 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
217 if (ret == CAMERA_ERROR_NONE) {
218 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt_evas);
219 if (ret != CAMERA_ERROR_NONE) {
220 LOGE("create pkt for evas failed");
221 _camera_media_packet_data_release(mp_data, cb_info);
227 /* call media packet callback */
228 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
229 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
231 if (ret == CAMERA_ERROR_NONE) {
232 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt);
234 if (ret == CAMERA_ERROR_NONE) {
235 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
236 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
238 _camera_media_packet_data_release(mp_data, cb_info);
244 /* call evas renderer */
246 if (cb_info->run_evas_render) {
247 mm_display_interface_evas_render(cb_info->dp_interface, pkt_evas);
249 LOGW("evas renderer is stopped, skip this buffer...");
250 media_packet_destroy(pkt_evas);
255 /* send message for preview callback return */
256 if (!CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS))
257 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info, NULL, 0);
259 _PREVIEW_CB_HANDLER_DONE:
260 if (mp_data == NULL) {
261 /* release imported bo */
262 for (i = 0 ; i < num_buffer_key && i < BUFFER_MAX_PLANE_NUM ; i++)
263 _camera_release_imported_bo(&buffer_bo[i]);
265 /* unmap and unref tbm bo */
266 _camera_release_imported_bo(&data_bo);
267 _camera_release_imported_bo(&bo);
270 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
272 /*LOGD("return buffer Done");*/
279 static void __camera_event_handler_capture(camera_cb_info_s *cb_info, char *recv_msg)
282 int tbm_key_main = 0;
283 int tbm_key_post = 0;
284 int tbm_key_thumb = 0;
285 unsigned char *buf_pos = NULL;
287 camera_msg_param param;
288 camera_image_data_s *rImage = NULL;
289 camera_image_data_s *rPostview = NULL;
290 camera_image_data_s *rThumbnail = NULL;
292 tbm_bo bo_main = NULL;
293 tbm_bo bo_post = NULL;
294 tbm_bo bo_thumb = NULL;
295 tbm_bo_handle bo_main_handle = {.ptr = NULL};
296 tbm_bo_handle bo_post_handle = {.ptr = NULL};
297 tbm_bo_handle bo_thumb_handle = {.ptr = NULL};
299 if (!cb_info || !recv_msg) {
300 LOGE("invalid param %p %p", cb_info, recv_msg);
304 muse_camera_msg_get(tbm_key_main, recv_msg);
305 muse_camera_msg_get(tbm_key_post, recv_msg);
306 muse_camera_msg_get(tbm_key_thumb, recv_msg);
309 LOGD("camera capture callback came in. tbm_key_main %d, tbm_key_post %d, tbm_key_thumb %d",
310 tbm_key_main, tbm_key_post, tbm_key_thumb);
313 if (tbm_key_main <= 0) {
314 LOGE("invalid key %d", tbm_key_main);
315 goto _CAPTURE_CB_HANDLER_DONE;
318 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] == NULL) {
319 LOGW("NULL callback");
320 goto _CAPTURE_CB_HANDLER_DONE;
323 /* import tbm bo and get virtual address */
324 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_main, &bo_main, &bo_main_handle)) {
325 LOGE("failed to import key [%d] for main", tbm_key_main);
326 goto _CAPTURE_CB_HANDLER_DONE;
329 buf_pos = (unsigned char *)bo_main_handle.ptr;
330 rImage = (camera_image_data_s *)buf_pos;
331 rImage->data = buf_pos + sizeof(camera_image_data_s);
332 if (rImage->exif && rImage->exif_size > 0) {
333 rImage->exif = rImage->data + rImage->size;
336 rImage->exif_size = 0;
339 LOGD("image info %dx%d, size %d, EXIF info %p, size %d",
340 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
342 if (tbm_key_post > 0) {
343 /* import tbm bo and get virtual address */
344 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key_post, &bo_post, &bo_post_handle)) {
345 buf_pos = (unsigned char *)bo_post_handle.ptr;
346 rPostview = (camera_image_data_s *)buf_pos;
347 LOGD("rPostview->size : %d", rPostview->size);
348 rPostview->data = buf_pos + sizeof(camera_image_data_s);
350 LOGE("failed to import key [%d] for postview", tbm_key_post);
354 if (tbm_key_thumb > 0) {
355 /* import tbm bo and get virtual address */
356 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key_thumb, &bo_thumb, &bo_thumb_handle)) {
357 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
358 rThumbnail = (camera_image_data_s *)buf_pos;
359 LOGD("rThumbnail->size : %d", rThumbnail->size);
360 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
362 LOGE("failed to import key [%d] for thumbnail", tbm_key_thumb);
366 ((camera_capturing_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE])(rImage,
367 rPostview, rThumbnail, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE]);
369 _CAPTURE_CB_HANDLER_DONE:
371 if (tbm_key_main > 0) {
372 _camera_release_imported_bo(&bo_main);
374 tbm_key = tbm_key_main;
375 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
377 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
380 if (tbm_key_post > 0) {
381 _camera_release_imported_bo(&bo_post);
383 tbm_key = tbm_key_post;
384 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
386 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
389 if (tbm_key_thumb > 0) {
390 _camera_release_imported_bo(&bo_thumb);
392 tbm_key = tbm_key_thumb;
393 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
395 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
398 LOGD("return buffer done");
404 static void __camera_event_handler_face_detection(camera_cb_info_s *cb_info, char *recv_msg)
408 camera_detected_face_s *faces = NULL;
409 camera_msg_param param;
412 tbm_bo_handle bo_handle = {.ptr = NULL};
414 if (!cb_info || !recv_msg) {
415 LOGE("invalid param %p %p", cb_info, recv_msg);
419 muse_camera_msg_get(count, recv_msg);
420 muse_camera_msg_get(tbm_key, recv_msg);
422 if (count >= 0 && cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]) {
423 LOGD("FACE_DETECTION - count %d, tbm_key %d", count, tbm_key);
427 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
429 faces = bo_handle.ptr;
433 ((camera_face_detected_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION])(faces,
434 count, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
437 _camera_release_imported_bo(&bo);
439 LOGW("skip face detection message [count %d, key %d, cb %p",
440 count, tbm_key, cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
445 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
446 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
447 /*LOGD("return buffer done");*/
454 static int _camera_import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle)
456 tbm_bo tmp_bo = NULL;
457 tbm_bo_handle tmp_bo_handle = {NULL, };
459 if (!bufmgr || !bo || !bo_handle || !tbm_key) {
460 LOGE("invalid parameter - %p %p %p, key %d",
461 bufmgr, bo, bo_handle, tbm_key);
465 tmp_bo = tbm_bo_import(bufmgr, tbm_key);
466 if (tmp_bo == NULL) {
467 LOGE("import failed - key %d", tbm_key);
471 tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
472 if (tmp_bo_handle.ptr == NULL) {
473 LOGE("map failed %p", tmp_bo);
474 tbm_bo_unref(tmp_bo);
479 tbm_bo_unmap(tmp_bo);
481 /* set bo and bo_handle */
483 *bo_handle = tmp_bo_handle;
488 static void _camera_release_imported_bo(tbm_bo *bo)
501 static int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
503 int ret = CAMERA_ERROR_NONE;
506 /*LOGD("Enter api : %d", api);*/
508 if (!cb_info->is_server_connected) {
509 LOGE("server is disconnected");
510 return CAMERA_ERROR_SERVICE_DISCONNECTED;
513 g_mutex_lock(&(cb_info->api_mutex[api]));
515 if (cb_info->api_activating[api] == 0) {
516 if (time_out == CAMERA_CB_NO_TIMEOUT) {
517 LOGW("wait for api %d", api);
518 g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
519 ret = cb_info->api_ret[api];
520 cb_info->api_activating[api] = 0;
521 LOGW("api %d returned 0x%x", api, ret);
523 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
524 if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
525 ret = cb_info->api_ret[api];
526 cb_info->api_activating[api] = 0;
527 /*LOGD("return value : 0x%x", ret);*/
529 ret = CAMERA_ERROR_INVALID_OPERATION;
530 LOGE("api %d was TIMED OUT!", api);
534 ret = cb_info->api_ret[api];
535 cb_info->api_activating[api] = 0;
537 /*LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);*/
540 g_mutex_unlock(&(cb_info->api_mutex[api]));
542 if (ret != CAMERA_ERROR_NONE)
543 LOGE("api %d : error 0x%x", api, ret);
549 static void _camera_msg_send(int api, camera_cb_info_s *cb_info,
550 int *ret, int timeout)
556 LOGE("NULL info - api %d", api);
559 *ret = CAMERA_ERROR_INVALID_PARAMETER;
564 msg = muse_core_msg_new(api, NULL);
566 LOGE("msg failed: api %d", api);
569 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
574 /*LOGD("send msg %s", msg);*/
576 if (cb_info->is_server_connected) {
577 __camera_update_api_waiting(cb_info, api, 1);
579 g_mutex_lock(&cb_info->fd_lock);
580 send_ret = muse_core_msg_send(cb_info->fd, msg);
581 g_mutex_unlock(&cb_info->fd_lock);
585 LOGE("msg send failed");
587 *ret = CAMERA_ERROR_INVALID_OPERATION;
590 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
593 __camera_update_api_waiting(cb_info, api, -1);
595 muse_core_msg_free(msg);
601 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
602 int *ret, camera_msg_param *param, int timeout)
607 if (!cb_info || !param) {
608 LOGE("invalid pointer : api %d - %p %p", api, cb_info, param);
611 *ret = CAMERA_ERROR_INVALID_PARAMETER;
616 /*LOGD("type %d, name %s", param->type, param->name);*/
618 switch (param->type) {
620 msg = muse_core_msg_new(api,
621 param->type, param->name, param->value.value_INT,
624 case MUSE_TYPE_STRING:
625 msg = muse_core_msg_new(api,
626 param->type, param->name, param->value.value_STRING,
630 LOGE("unknown type %d", param->type);
635 LOGE("msg failed: api %d", api);
638 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
643 /*LOGD("send msg %s", msg);*/
645 if (cb_info->is_server_connected) {
646 __camera_update_api_waiting(cb_info, api, 1);
648 g_mutex_lock(&cb_info->fd_lock);
649 send_ret = muse_core_msg_send(cb_info->fd, msg);
650 g_mutex_unlock(&cb_info->fd_lock);
654 LOGE("msg send failed");
657 *ret = CAMERA_ERROR_INVALID_OPERATION;
660 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
663 __camera_update_api_waiting(cb_info, api, -1);
665 muse_core_msg_free(msg);
671 static void _camera_msg_send_param2_int(int api, camera_cb_info_s *cb_info,
672 int *ret, camera_msg_param *param0, camera_msg_param *param1, int timeout)
674 int func_ret = CAMERA_ERROR_NONE;
678 if (!cb_info || !param0 || !param1) {
679 LOGE("invalid ptr %p %p %p : api %d",
680 cb_info, param0, param1, api);
681 func_ret = CAMERA_ERROR_INVALID_PARAMETER;
682 goto _SEND_PARAM2_INT_DONE;
685 /*LOGD("api %d, param0 [%s:%d], param1 [%s:%d]",
687 param0->name, param0->value.value_INT,
688 param1->name, param1->value.value_INT);*/
690 msg = muse_core_msg_new(api,
691 param0->type, param0->name, param0->value.value_INT,
692 param1->type, param1->name, param1->value.value_INT,
695 LOGE("msg failed: api %d", api);
696 func_ret = CAMERA_ERROR_OUT_OF_MEMORY;
697 goto _SEND_PARAM2_INT_DONE;
700 /*LOGD("send msg [%s]", msg);*/
702 if (cb_info->is_server_connected) {
703 __camera_update_api_waiting(cb_info, api, 1);
705 g_mutex_lock(&cb_info->fd_lock);
706 send_ret = muse_core_msg_send(cb_info->fd, msg);
707 g_mutex_unlock(&cb_info->fd_lock);
711 LOGE("msg send failed");
713 func_ret = CAMERA_ERROR_INVALID_OPERATION;
715 func_ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
718 __camera_update_api_waiting(cb_info, api, -1);
720 muse_core_msg_free(msg);
722 _SEND_PARAM2_INT_DONE:
730 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
732 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
733 in_format >= MM_PIXEL_FORMAT_NUM ||
734 out_format == NULL) {
735 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
736 return CAMERA_ERROR_INVALID_PARAMETER;
740 case MM_PIXEL_FORMAT_NV12:
741 case MM_PIXEL_FORMAT_NV12T:
742 *out_format = TBM_FORMAT_NV12;
744 case MM_PIXEL_FORMAT_NV16:
745 *out_format = TBM_FORMAT_NV16;
747 case MM_PIXEL_FORMAT_NV21:
748 *out_format = TBM_FORMAT_NV21;
750 case MM_PIXEL_FORMAT_YUYV:
751 *out_format = TBM_FORMAT_YUYV;
753 case MM_PIXEL_FORMAT_UYVY:
754 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
755 *out_format = TBM_FORMAT_UYVY;
757 case MM_PIXEL_FORMAT_422P:
758 *out_format = TBM_FORMAT_YUV422;
760 case MM_PIXEL_FORMAT_I420:
761 *out_format = TBM_FORMAT_YUV420;
763 case MM_PIXEL_FORMAT_YV12:
764 *out_format = TBM_FORMAT_YVU420;
766 case MM_PIXEL_FORMAT_RGB565:
767 *out_format = TBM_FORMAT_RGB565;
769 case MM_PIXEL_FORMAT_RGB888:
770 *out_format = TBM_FORMAT_RGB888;
772 case MM_PIXEL_FORMAT_RGBA:
773 *out_format = TBM_FORMAT_RGBA8888;
775 case MM_PIXEL_FORMAT_ARGB:
776 *out_format = TBM_FORMAT_ARGB8888;
779 LOGE("invalid in_format %d", in_format);
780 return CAMERA_ERROR_INVALID_PARAMETER;
783 return CAMERA_ERROR_NONE;
787 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
789 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
790 in_format >= MM_PIXEL_FORMAT_NUM ||
792 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
793 return CAMERA_ERROR_INVALID_PARAMETER;
797 case MM_PIXEL_FORMAT_NV12:
798 case MM_PIXEL_FORMAT_NV12T:
799 *mimetype = MEDIA_FORMAT_NV12;
801 case MM_PIXEL_FORMAT_NV16:
802 *mimetype = MEDIA_FORMAT_NV16;
804 case MM_PIXEL_FORMAT_NV21:
805 *mimetype = MEDIA_FORMAT_NV21;
807 case MM_PIXEL_FORMAT_YUYV:
808 *mimetype = MEDIA_FORMAT_YUYV;
810 case MM_PIXEL_FORMAT_UYVY:
811 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
812 *mimetype = MEDIA_FORMAT_UYVY;
814 case MM_PIXEL_FORMAT_422P:
815 *mimetype = MEDIA_FORMAT_422P;
817 case MM_PIXEL_FORMAT_I420:
818 *mimetype = MEDIA_FORMAT_I420;
820 case MM_PIXEL_FORMAT_YV12:
821 *mimetype = MEDIA_FORMAT_YV12;
823 case MM_PIXEL_FORMAT_RGB565:
824 *mimetype = MEDIA_FORMAT_RGB565;
826 case MM_PIXEL_FORMAT_RGB888:
827 *mimetype = MEDIA_FORMAT_RGB888;
829 case MM_PIXEL_FORMAT_RGBA:
830 *mimetype = MEDIA_FORMAT_RGBA;
832 case MM_PIXEL_FORMAT_ARGB:
833 *mimetype = MEDIA_FORMAT_ARGB;
836 LOGE("invalid in_format %d", in_format);
837 return CAMERA_ERROR_INVALID_PARAMETER;
840 return CAMERA_ERROR_NONE;
843 static void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_key,
844 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame)
847 unsigned char *buf_pos = NULL;
849 if (stream == NULL || buffer_bo_handle == NULL || frame == NULL) {
850 LOGE("invalid parameter - stream:%p, buffer_bo_handle:%p", stream, buffer_bo_handle);
855 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
856 frame->format = MM_PIXEL_FORMAT_UYVY;
858 frame->format = stream->format;
860 frame->width = stream->width;
861 frame->height = stream->height;
862 frame->timestamp = stream->timestamp;
863 frame->num_of_planes = stream->num_planes;
865 if (num_buffer_key == 0) {
867 if (!data_bo_handle || !data_bo_handle->ptr) {
868 LOGE("NULL pointer");
872 buf_pos = data_bo_handle->ptr;
874 if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) {
875 frame->data.encoded_plane.data = buf_pos;
876 frame->data.encoded_plane.size = stream->data.encoded.length_data;
877 total_size = stream->data.encoded.length_data;
879 switch (stream->num_planes) {
881 frame->data.single_plane.yuv = buf_pos;
882 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
883 total_size = stream->data.yuv420.length_yuv;
886 frame->data.double_plane.y = buf_pos;
887 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
888 buf_pos += stream->data.yuv420sp.length_y;
889 frame->data.double_plane.uv = buf_pos;
890 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
891 total_size = stream->data.yuv420sp.length_y + \
892 stream->data.yuv420sp.length_uv;
895 frame->data.triple_plane.y = buf_pos;
896 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
897 buf_pos += stream->data.yuv420p.length_y;
898 frame->data.triple_plane.u = buf_pos;
899 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
900 buf_pos += stream->data.yuv420p.length_u;
901 frame->data.triple_plane.v = buf_pos;
902 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
903 total_size = stream->data.yuv420p.length_y + \
904 stream->data.yuv420p.length_u + \
905 stream->data.yuv420p.length_v;
913 switch (stream->num_planes) {
915 frame->data.single_plane.yuv = buffer_bo_handle[0].ptr;
916 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
917 total_size = stream->data.yuv420.length_yuv;
920 frame->data.double_plane.y = buffer_bo_handle[0].ptr;
921 if (stream->num_planes == (unsigned int)num_buffer_key)
922 frame->data.double_plane.uv = buffer_bo_handle[1].ptr;
924 frame->data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
925 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
926 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
927 total_size = stream->data.yuv420sp.length_y + \
928 stream->data.yuv420sp.length_uv;
931 frame->data.triple_plane.y = buffer_bo_handle[0].ptr;
932 if (stream->num_planes == (unsigned int)num_buffer_key) {
933 frame->data.triple_plane.u = buffer_bo_handle[1].ptr;
934 frame->data.triple_plane.v = buffer_bo_handle[2].ptr;
936 frame->data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y;
937 frame->data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u;
939 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
940 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
941 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
942 total_size = stream->data.yuv420p.length_y + \
943 stream->data.yuv420p.length_u + \
944 stream->data.yuv420p.length_v;
952 LOGD("format %d, %dx%d, size %d plane num %d",
953 frame.format, frame.width, frame.height, total_size, frame.num_of_planes);
959 static int _camera_media_packet_data_create(int tbm_key, int num_buffer_key, tbm_bo bo,
960 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
963 int ret = CAMERA_ERROR_NONE;
964 camera_media_packet_data *tmp_mp_data = NULL;
966 if (*mp_data == NULL) {
967 tmp_mp_data = g_new0(camera_media_packet_data, 1);
969 tmp_mp_data->tbm_key = tbm_key;
970 tmp_mp_data->num_buffer_key = num_buffer_key;
971 tmp_mp_data->bo = bo;
972 tmp_mp_data->data_bo = data_bo;
973 tmp_mp_data->ref_cnt++;
975 for (i = 0 ; i < num_buffer_key ; i++)
976 tmp_mp_data->buffer_bo[i] = buffer_bo[i];
978 *mp_data = tmp_mp_data;
979 /*LOGD("mp_data %p", tmp_mp_data);*/
981 ret = CAMERA_ERROR_OUT_OF_MEMORY;
982 LOGE("failed to alloc media packet data");
985 ((camera_media_packet_data *)*mp_data)->ref_cnt++;
991 static void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
995 camera_msg_param param;
997 if (!mp_data || !cb_info) {
998 LOGE("NULL pointer %p %p", mp_data, cb_info);
1002 if (mp_data->ref_cnt > 1) {
1004 LOGD("ref count %d", mp_data->ref_cnt);
1006 /* release imported bo */
1007 for (i = 0 ; i < mp_data->num_buffer_key ; i++) {
1008 tbm_bo_unref(mp_data->buffer_bo[i]);
1009 mp_data->buffer_bo[i] = NULL;
1013 _camera_release_imported_bo(&mp_data->bo);
1014 _camera_release_imported_bo(&mp_data->data_bo);
1017 tbm_key = mp_data->tbm_key;
1019 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
1021 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
1030 static int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
1031 camera_media_packet_data *mp_data, media_packet_h *packet)
1033 media_packet_h pkt = NULL;
1034 bool make_pkt_fmt = false;
1035 tbm_surface_h tsurf = NULL;
1036 tbm_surface_info_s tsurf_info;
1037 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
1038 uint32_t bo_format = 0;
1041 int num_buffer_key = 0;
1042 tbm_bo *buffer_bo = NULL;
1044 if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) {
1045 LOGE("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p",
1046 cb_info, stream, mp_data, packet);
1047 return CAMERA_ERROR_INVALID_PARAMETER;
1050 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
1051 buffer_bo = mp_data->buffer_bo;
1052 num_buffer_key = mp_data->num_buffer_key;
1054 /* create tbm surface */
1055 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
1056 tsurf_info.planes[i].stride = stream->stride[i];
1058 /* get tbm surface format */
1059 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
1060 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
1062 if (ret == CAMERA_ERROR_NONE) {
1063 tsurf_info.width = stream->width;
1064 tsurf_info.height = stream->height;
1065 tsurf_info.format = bo_format;
1066 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
1067 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
1069 if (num_buffer_key > 0) {
1070 switch (bo_format) {
1071 case TBM_FORMAT_NV12:
1072 case TBM_FORMAT_NV21:
1073 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1074 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1075 tsurf_info.planes[0].offset = 0;
1076 if (num_buffer_key == 1)
1077 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1078 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1080 case TBM_FORMAT_YUV420:
1081 case TBM_FORMAT_YVU420:
1082 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1083 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1084 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
1085 tsurf_info.planes[0].offset = 0;
1086 if (num_buffer_key == 1) {
1087 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1088 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1090 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1092 case TBM_FORMAT_UYVY:
1093 case TBM_FORMAT_YUYV:
1094 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
1095 tsurf_info.planes[0].offset = 0;
1096 tsurf_info.size = tsurf_info.planes[0].size;
1102 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_key);
1103 } else if (mp_data->data_bo) {
1104 switch (bo_format) {
1105 case TBM_FORMAT_NV12:
1106 case TBM_FORMAT_NV21:
1107 tsurf_info.planes[0].size = stream->width * stream->height;
1108 tsurf_info.planes[1].size = (tsurf_info.planes[0].size) >> 1;
1109 tsurf_info.planes[0].offset = 0;
1110 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1111 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1113 case TBM_FORMAT_YUV420:
1114 case TBM_FORMAT_YVU420:
1115 tsurf_info.planes[0].size = stream->width * stream->height;
1116 tsurf_info.planes[1].size = (stream->width >> 1) * (stream->height >> 1);
1117 tsurf_info.planes[2].size = tsurf_info.planes[1].size;
1118 tsurf_info.planes[0].offset = 0;
1119 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1120 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1121 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1123 case TBM_FORMAT_UYVY:
1124 case TBM_FORMAT_YUYV:
1125 tsurf_info.planes[0].size = (stream->width * stream->height) << 1;
1126 tsurf_info.planes[0].offset = 0;
1127 tsurf_info.size = tsurf_info.planes[0].size;
1133 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1);
1135 /*LOGD("tbm surface %p", tsurf);*/
1139 /* check media packet format */
1140 if (cb_info->pkt_fmt) {
1141 int pkt_fmt_width = 0;
1142 int pkt_fmt_height = 0;
1143 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
1145 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
1146 if (pkt_fmt_mimetype != mimetype ||
1147 pkt_fmt_width != stream->width ||
1148 pkt_fmt_height != stream->height) {
1149 LOGW("change fmt: current 0x%x, %dx%d",
1150 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
1151 media_format_unref(cb_info->pkt_fmt);
1152 cb_info->pkt_fmt = NULL;
1153 make_pkt_fmt = true;
1156 make_pkt_fmt = true;
1159 /* create packet format */
1161 LOGW("make new pkt_fmt - 0x%x, %dx%d", mimetype, stream->width, stream->height);
1162 ret = media_format_create(&cb_info->pkt_fmt);
1163 if (ret == MEDIA_FORMAT_ERROR_NONE) {
1164 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
1165 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
1166 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
1167 LOGW("media_format_set : 0x%x", ret);
1169 LOGW("media_format_create failed 0x%x", ret);
1173 /* create media packet */
1174 ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt,
1175 tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
1176 (void *)cb_info, &pkt);
1177 if (ret != MEDIA_PACKET_ERROR_NONE) {
1178 LOGE("media_packet_create failed 0x%x", ret);
1179 tbm_surface_destroy(tsurf);
1183 LOGE("tbm surface failed. %dx%d, format %d, num_buffer_key %d, data_bo %p",
1184 stream->width, stream->height, stream->format, num_buffer_key, mp_data->data_bo);
1188 /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
1189 /* set media packet data */
1190 ret = media_packet_set_extra(pkt, (void *)mp_data);
1191 if (ret != MEDIA_PACKET_ERROR_NONE) {
1192 LOGE("media_packet_set_extra failed");
1194 _camera_media_packet_data_release(mp_data, cb_info);
1197 media_packet_destroy(pkt);
1200 /* set timestamp : msec -> nsec */
1201 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
1202 LOGW("media_packet_set_pts failed");
1211 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
1214 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1215 camera_media_packet_data *mp_data = NULL;
1216 tbm_surface_h tsurf = NULL;
1218 if (!pkt || !cb_info) {
1219 LOGE("NULL pointer %p %p", pkt, cb_info);
1220 return MEDIA_PACKET_FINALIZE;
1223 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1224 if (ret != MEDIA_PACKET_ERROR_NONE) {
1225 LOGE("media_packet_get_extra failed 0x%x", ret);
1226 return MEDIA_PACKET_FINALIZE;
1229 /*LOGD("mp_data %p", mp_data);*/
1231 g_mutex_lock(&cb_info->mp_data_mutex);
1233 _camera_media_packet_data_release(mp_data, cb_info);
1236 g_mutex_unlock(&cb_info->mp_data_mutex);
1238 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1239 if (ret != MEDIA_PACKET_ERROR_NONE)
1240 LOGE("get tbm_surface failed 0x%x", ret);
1243 tbm_surface_destroy(tsurf);
1247 return MEDIA_PACKET_FINALIZE;
1250 static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event)
1255 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1256 LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event);
1260 /*LOGD("get camera msg %s, event %d", recv_msg, event);*/
1262 g_mutex_lock(&cb_info->user_cb_mutex[event]);
1264 if (cb_info->user_cb[event] == NULL) {
1265 if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
1266 event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
1267 event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
1268 event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1269 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1270 LOGW("NULL callback for event %d, return here", event);
1274 /* return buffer message should be sent for some events.
1275 - MUSE_CAMERA_EVENT_TYPE_PREVIEW
1276 - MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW
1277 - MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION
1278 - MUSE_CAMERA_EVENT_TYPE_CAPTURE
1283 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1289 muse_camera_msg_get(previous, recv_msg);
1290 muse_camera_msg_get(current, recv_msg);
1291 muse_camera_msg_get(by_policy, recv_msg);
1293 LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
1294 previous, current, by_policy);
1296 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1297 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1300 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1304 muse_camera_msg_get(state, recv_msg);
1306 LOGD("FOCUS state - %d", state);
1308 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1311 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1312 LOGD("CAPTURE_COMPLETED");
1313 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1315 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1316 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1317 __camera_event_handler_preview(cb_info, recv_msg);
1319 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1323 muse_camera_msg_get(percent, recv_msg);
1325 LOGD("HDR progress - %d %%", percent);
1327 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1330 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1336 muse_camera_msg_get(policy, recv_msg);
1337 muse_camera_msg_get(previous, recv_msg);
1338 muse_camera_msg_get(current, recv_msg);
1340 LOGW("INTERRUPTED - policy %d, state %d -> %d", policy, previous, current);
1342 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1343 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1346 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1351 muse_camera_msg_get(policy, recv_msg);
1352 muse_camera_msg_get(state, recv_msg);
1354 LOGW("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1356 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1357 (camera_state_e)state, cb_info->user_data[event]);
1360 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1361 __camera_event_handler_face_detection(cb_info, recv_msg);
1363 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1366 int current_state = 0;
1368 muse_camera_msg_get(error, recv_msg);
1369 muse_camera_msg_get(current_state, recv_msg);
1371 LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
1373 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1374 (camera_state_e)current_state, cb_info->user_data[event]);
1377 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1379 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1380 muse_camera_msg_get(param1, recv_msg);
1381 muse_camera_msg_get(param2, recv_msg);
1383 /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/
1385 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1386 cb_info->user_cb[event] = NULL;
1387 cb_info->user_data[event] = NULL;
1388 LOGW("stop foreach callback for event %d", event);
1391 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1393 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1395 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1397 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1399 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1401 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1403 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1405 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1407 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1409 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1411 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1413 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1415 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1417 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1419 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1420 muse_camera_msg_get(param1, recv_msg);
1422 /*LOGD("event %d SUPPORTED %d ", event, param1);*/
1424 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1425 cb_info->user_cb[event] = NULL;
1426 cb_info->user_data[event] = NULL;
1427 LOGW("stop foreach callback for event %d", event);
1430 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1431 __camera_event_handler_capture(cb_info, recv_msg);
1434 LOGW("unhandled event %d", event);
1438 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1443 static bool _camera_idle_event_callback(void *data)
1445 camera_cb_info_s *cb_info = NULL;
1446 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1448 if (cam_idle_event == NULL) {
1449 LOGE("cam_idle_event is NULL");
1454 g_mutex_lock(&cam_idle_event->event_mutex);
1456 cb_info = cam_idle_event->cb_info;
1457 if (cb_info == NULL) {
1458 LOGW("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1459 goto IDLE_EVENT_CALLBACK_DONE;
1462 /* remove event from list */
1463 g_mutex_lock(&cb_info->idle_event_mutex);
1465 if (cb_info->idle_event_list)
1466 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1468 /*LOGD("remove camera idle event %p, %p", cam_idle_event, cb_info->idle_event_list);*/
1469 g_mutex_unlock(&cb_info->idle_event_mutex);
1472 _camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
1474 /* send signal for waiting thread */
1475 g_cond_signal(&cb_info->idle_event_cond);
1477 IDLE_EVENT_CALLBACK_DONE:
1478 /* unlock and release event */
1479 g_mutex_unlock(&cam_idle_event->event_mutex);
1480 g_mutex_clear(&cam_idle_event->event_mutex);
1482 g_free(cam_idle_event);
1483 cam_idle_event = NULL;
1488 static void *_camera_msg_handler_func(gpointer data)
1492 camera_message_s *cam_msg = NULL;
1493 camera_idle_event_s *cam_idle_event = NULL;
1494 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1495 camera_cb_info_s *cb_info = NULL;
1497 if (!handler_info || !handler_info->cb_info) {
1498 LOGE("NULL handler %p", handler_info);
1502 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1503 type = handler_info->type;
1505 LOGD("t:%d start", type);
1507 g_mutex_lock(&handler_info->mutex);
1509 while (g_atomic_int_get(&handler_info->running)) {
1510 if (g_queue_is_empty(handler_info->queue)) {
1511 /*LOGD("t:%d signal wait...", type);*/
1512 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1513 /*LOGD("t:%d signal received", type);*/
1515 if (g_atomic_int_get(&handler_info->running) == 0) {
1516 LOGD("t:%d stop event thread", type);
1521 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1523 g_mutex_unlock(&handler_info->mutex);
1525 if (cam_msg == NULL) {
1526 LOGE("t:%d NULL message", type);
1527 g_mutex_lock(&handler_info->mutex);
1533 if (api < MUSE_CAMERA_API_MAX) {
1536 g_mutex_lock(&cb_info->api_mutex[api]);
1538 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1539 if (cb_info->api_waiting[api] > 0) {
1540 cb_info->api_ret[api] = ret;
1541 cb_info->api_activating[api] = 1;
1543 /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
1545 g_cond_signal(&cb_info->api_cond[api]);
1547 LOGW("no waiting for this api [%d]", api);
1550 LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1553 g_mutex_unlock(&cb_info->api_mutex[api]);
1554 } else if (api == MUSE_CAMERA_CB_EVENT) {
1555 switch (cam_msg->event_class) {
1556 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1557 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event);
1559 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1560 cam_idle_event = g_new0(camera_idle_event_s, 1);
1561 if (cam_idle_event == NULL) {
1562 LOGE("t:%d cam_idle_event alloc failed", type);
1566 cam_idle_event->event = cam_msg->event;
1567 cam_idle_event->cb_info = cb_info;
1568 g_mutex_init(&cam_idle_event->event_mutex);
1569 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg) - 1);
1571 /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, cam_msg->event, cam_idle_event);*/
1573 g_mutex_lock(&cb_info->idle_event_mutex);
1574 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1575 g_mutex_unlock(&cb_info->idle_event_mutex);
1577 g_idle_add_full(G_PRIORITY_DEFAULT,
1578 (GSourceFunc)_camera_idle_event_callback,
1579 (gpointer)cam_idle_event,
1583 LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
1587 LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1593 g_mutex_lock(&handler_info->mutex);
1596 /* remove remained event */
1597 while (!g_queue_is_empty(handler_info->queue)) {
1598 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1600 LOGD("t:%d remove camera message %p", type, cam_msg);
1604 LOGW("t:%d NULL camera message", type);
1608 g_mutex_unlock(&handler_info->mutex);
1610 LOGD("t:%d return", type);
1616 static void _camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1618 camera_idle_event_s *cam_idle_event = NULL;
1620 gint64 end_time = 0;
1622 if (cb_info == NULL) {
1623 LOGE("cb_info is NULL");
1627 g_mutex_lock(&cb_info->idle_event_mutex);
1629 if (cb_info->idle_event_list == NULL) {
1630 LOGD("No remained idle event");
1631 g_mutex_unlock(&cb_info->idle_event_mutex);
1635 list = cb_info->idle_event_list;
1638 cam_idle_event = list->data;
1639 list = g_list_next(list);
1641 if (!cam_idle_event) {
1642 LOGW("Fail to remove idle event. The event is NULL");
1646 if (g_idle_remove_by_data(cam_idle_event)) {
1647 LOGW("remove idle event %p done", cam_idle_event);
1649 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1651 g_mutex_clear(&cam_idle_event->event_mutex);
1652 g_free(cam_idle_event);
1653 cam_idle_event = NULL;
1658 LOGW("remove idle event %p failed", cam_idle_event);
1660 if (!g_mutex_trylock(&cam_idle_event->event_mutex)) {
1661 LOGW("lock failed, %p event is calling now", cam_idle_event);
1663 end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
1665 if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
1666 LOGW("signal received");
1673 LOGW("set NULL cb_info for event %p %d, it will be freed on idle callback",
1674 cam_idle_event, cam_idle_event->event);
1676 cam_idle_event->cb_info = NULL;
1678 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1680 g_mutex_unlock(&cam_idle_event->event_mutex);
1683 g_list_free(cb_info->idle_event_list);
1684 cb_info->idle_event_list = NULL;
1686 g_mutex_unlock(&cb_info->idle_event_mutex);
1692 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg)
1694 camera_message_s *cam_msg = NULL;
1696 if (!cb_info || !msg) {
1697 LOGE("NULL pointer %p %p", cb_info, msg);
1701 cam_msg = g_new0(camera_message_s, 1);
1703 LOGE("failed to alloc cam_msg for [%s]", msg);
1708 cam_msg->event = event;
1709 cam_msg->event_class = event_class;
1711 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1713 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1715 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1716 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1717 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1718 g_cond_signal(&cb_info->preview_cb_info.cond);
1719 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1720 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1721 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1722 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1723 g_cond_signal(&cb_info->capture_cb_info.cond);
1724 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1726 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1727 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1728 g_cond_signal(&cb_info->msg_handler_info.cond);
1729 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1738 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg)
1740 int ret = CAMERA_ERROR_NONE;
1744 int event_class = -1;
1748 if (!cb_info || !msg) {
1749 LOGE("invalid ptr %p %p", cb_info, msg);
1753 /*LOGD("msg [%s]", msg);*/
1755 if (!muse_camera_msg_get(api, msg)) {
1756 LOGE("failed to get camera api");
1760 if (api == MUSE_CAMERA_CB_EVENT) {
1761 if (!muse_camera_msg_get(event, msg) ||
1762 !muse_camera_msg_get(event_class, msg)) {
1763 LOGE("failed to get camera event or event_class [%s]", msg);
1767 if (!muse_camera_msg_get(api_class, msg)) {
1768 LOGE("failed to get camera api_class [%s]", msg);
1773 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1774 if (api >= MUSE_CAMERA_API_MAX) {
1775 LOGE("invalid api %d", api);
1779 if (!muse_camera_msg_get(ret, msg)) {
1780 LOGE("failed to get camera ret");
1784 g_mutex_lock(&cb_info->api_mutex[api]);
1787 case MUSE_CAMERA_API_CREATE:
1788 if (ret != CAMERA_ERROR_NONE) {
1789 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1790 LOGE("camera create error 0x%x. close client cb handler", ret);
1793 case MUSE_CAMERA_API_DESTROY:
1794 if (ret == CAMERA_ERROR_NONE) {
1795 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1796 LOGD("camera destroy done. close client cb handler");
1800 muse_camera_msg_get(get_type, msg);
1801 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1802 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1803 muse_camera_msg_get(get_index, msg);
1806 case MUSE_CAMERA_GET_TYPE_INT:
1807 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
1809 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1810 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
1811 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
1813 case MUSE_CAMERA_GET_TYPE_ARRAY:
1814 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
1815 muse_core_msg_deserialize("get_value",
1816 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
1817 LOGD("get display roi %d,%d,%dx%d",
1818 cb_info->get_display_roi_area[0],
1819 cb_info->get_display_roi_area[1],
1820 cb_info->get_display_roi_area[2],
1821 cb_info->get_display_roi_area[3]);
1823 muse_core_msg_deserialize("get_value",
1824 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
1825 LOGD("get geotag %lf, %lf, %lf",
1826 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
1829 case MUSE_CAMERA_GET_TYPE_STRING:
1830 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
1833 LOGW("unknown type %d", get_type);
1840 if (cb_info->api_waiting[api] > 0) {
1841 cb_info->api_ret[api] = ret;
1842 cb_info->api_activating[api] = 1;
1844 g_cond_signal(&cb_info->api_cond[api]);
1846 LOGW("no waiting for this api [%d]", api);
1849 g_mutex_unlock(&cb_info->api_mutex[api]);
1850 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
1851 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg);
1853 LOGW("unknown camera api %d, class %d", api, api_class);
1860 static void *_camera_msg_recv_func(gpointer data)
1862 int recv_length = 0;
1863 int single_length = 0;
1864 int remained_length = 0;
1865 char *recv_msg = NULL;
1866 char *single_msg = NULL;
1867 char *remained_msg = NULL;
1871 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
1874 LOGE("cb_info NULL");
1878 LOGD("start - fd : %d", cb_info->fd);
1880 single_msg = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
1882 LOGE("single_msg malloc failed");
1886 recv_msg = cb_info->recv_msg;
1888 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
1889 recv_length = muse_core_msg_recv(cb_info->fd, recv_msg);
1890 if (recv_length <= 0) {
1891 cb_info->is_server_connected = FALSE;
1892 LOGE("receive msg failed - server disconnected");
1900 /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
1902 /* Need to split the combined entering msgs */
1903 for (cur_pos = 0 ; cur_pos < recv_length ; cur_pos++) {
1904 if (recv_msg[cur_pos] == '}') {
1905 single_length = cur_pos - prev_pos + 1;
1907 if (single_length < MUSE_CAMERA_MSG_MAX_LENGTH) {
1908 /* check remained msg */
1909 if (remained_length > 0) {
1911 strncpy(single_msg, remained_msg, remained_length);
1912 strncpy(single_msg + remained_length, recv_msg + prev_pos, single_length);
1913 single_msg[remained_length + single_length] = '\0';
1916 remained_msg = NULL;
1918 strncpy(single_msg, recv_msg + prev_pos, single_length);
1919 single_msg[single_length] = '\0';
1920 LOGE("lost msg [%s], skip...", single_msg);
1923 remained_length = 0;
1925 strncpy(single_msg, recv_msg + prev_pos, single_length);
1926 single_msg[single_length] = '\0';
1929 if (single_msg[0] == '{') {
1931 /*LOGD("splitted msg : [%s], Index : %d", single_msg, num_msg);*/
1932 /* process each message */
1933 __camera_process_msg(cb_info, single_msg);
1935 LOGE("invalid msg [%s]", single_msg);
1938 LOGE("too long message [len %d] skip...", single_length);
1941 prev_pos = cur_pos + 1;
1945 /* check incompleted message */
1946 if (recv_msg[recv_length - 1] != '}') {
1947 remained_length = recv_length - prev_pos;
1949 LOGW("incompleted message [len %d]", remained_length);
1953 remained_msg = NULL;
1956 remained_msg = (char *)malloc(remained_length + 1);
1958 strncpy(remained_msg, recv_msg + prev_pos, remained_length);
1959 remained_msg[remained_length] = '\0';
1961 LOGE("failed to alloc for remained msg");
1964 remained_length = 0;
1968 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
1970 if (!cb_info->is_server_connected) {
1971 char *error_msg = NULL;
1973 if (cb_info->fd < 0) {
1974 LOGE("fd is closed in client side");
1975 goto CB_HANDLER_EXIT;
1978 /* send error msg for server disconnection */
1979 error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
1980 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
1981 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
1985 LOGE("error_msg failed");
1986 goto CB_HANDLER_EXIT;
1989 __camera_add_msg_to_queue(cb_info,
1990 MUSE_CAMERA_CB_EVENT,
1991 MUSE_CAMERA_EVENT_TYPE_ERROR,
1992 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
1995 muse_core_msg_free(error_msg);
1998 LOGE("add error msg for service disconnection done");
2009 remained_msg = NULL;
2016 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
2017 int type, const char *thread_name, camera_cb_info_s *cb_info)
2019 if (!handler_info || !thread_name || !cb_info) {
2020 LOGE("t:%d NULL %p %p %p",
2021 type, handler_info, thread_name, cb_info);
2027 handler_info->type = type;
2028 handler_info->queue = g_queue_new();
2029 if (handler_info->queue == NULL) {
2030 LOGE("t:%d queue failed", type);
2034 g_mutex_init(&handler_info->mutex);
2035 g_cond_init(&handler_info->cond);
2037 handler_info->cb_info = (void *)cb_info;
2038 g_atomic_int_set(&handler_info->running, 1);
2040 handler_info->thread = g_thread_try_new(thread_name,
2041 _camera_msg_handler_func, (gpointer)handler_info, NULL);
2042 if (handler_info->thread == NULL) {
2043 LOGE("t:%d thread failed", type);
2045 g_mutex_clear(&handler_info->mutex);
2046 g_cond_clear(&handler_info->cond);
2047 g_queue_free(handler_info->queue);
2048 handler_info->queue = NULL;
2053 LOGD("t:%d done", type);
2059 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2063 if (!handler_info) {
2064 LOGE("NULL handler");
2068 if (!handler_info->thread) {
2069 LOGW("thread is not created");
2073 type = handler_info->type;
2075 LOGD("t:%d thread %p", type, handler_info->thread);
2077 g_mutex_lock(&handler_info->mutex);
2078 g_atomic_int_set(&handler_info->running, 0);
2079 g_cond_signal(&handler_info->cond);
2080 g_mutex_unlock(&handler_info->mutex);
2082 g_thread_join(handler_info->thread);
2083 handler_info->thread = NULL;
2085 g_mutex_clear(&handler_info->mutex);
2086 g_cond_clear(&handler_info->cond);
2087 g_queue_free(handler_info->queue);
2088 handler_info->queue = NULL;
2090 LOGD("t:%d done", type);
2096 static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
2098 camera_cb_info_s *cb_info = NULL;
2101 g_return_val_if_fail(sockfd > 0, NULL);
2103 cb_info = g_new0(camera_cb_info_s, 1);
2104 if (cb_info == NULL) {
2105 LOGE("cb_info failed");
2109 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2111 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2112 g_mutex_init(&cb_info->api_mutex[i]);
2113 g_cond_init(&cb_info->api_cond[i]);
2116 g_mutex_init(&cb_info->fd_lock);
2117 g_mutex_init(&cb_info->idle_event_mutex);
2118 g_cond_init(&cb_info->idle_event_cond);
2119 g_mutex_init(&cb_info->mp_data_mutex);
2121 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2122 g_mutex_init(&cb_info->user_cb_mutex[i]);
2124 /* message handler thread */
2125 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2126 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2127 LOGE("msg_handler_info failed");
2131 /* message handler thread for preview callback */
2132 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2133 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2134 LOGE("preview_cb_info failed");
2138 /* message handler thread for capture callback */
2139 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2140 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2141 LOGE("capture_cb_info failed");
2145 cb_info->fd = sockfd;
2146 cb_info->preview_cb_flag = 0;
2148 /* message receive thread */
2149 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2150 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2151 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2152 if (cb_info->msg_recv_thread == NULL) {
2153 LOGE("message receive thread creation failed");
2157 cb_info->is_server_connected = TRUE;
2163 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2164 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2165 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2167 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2168 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2170 g_mutex_clear(&cb_info->fd_lock);
2171 g_mutex_clear(&cb_info->idle_event_mutex);
2172 g_cond_clear(&cb_info->idle_event_cond);
2173 g_mutex_clear(&cb_info->mp_data_mutex);
2175 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2176 g_mutex_clear(&cb_info->api_mutex[i]);
2177 g_cond_clear(&cb_info->api_cond[i]);
2187 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2191 g_return_if_fail(cb_info != NULL);
2193 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2195 g_thread_join(cb_info->msg_recv_thread);
2196 cb_info->msg_recv_thread = NULL;
2198 LOGD("msg_recv thread removed");
2200 /* destroy msg handler threads */
2201 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2202 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2203 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2205 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2206 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2208 g_mutex_clear(&cb_info->fd_lock);
2209 g_mutex_clear(&cb_info->idle_event_mutex);
2210 g_cond_clear(&cb_info->idle_event_cond);
2211 g_mutex_clear(&cb_info->mp_data_mutex);
2213 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2214 g_mutex_clear(&cb_info->api_mutex[i]);
2215 g_cond_clear(&cb_info->api_cond[i]);
2218 if (cb_info->fd > -1) {
2219 muse_client_close(cb_info->fd);
2223 if (cb_info->bufmgr) {
2224 tbm_bufmgr_deinit(cb_info->bufmgr);
2225 cb_info->bufmgr = NULL;
2227 if (cb_info->pkt_fmt) {
2228 media_format_unref(cb_info->pkt_fmt);
2229 cb_info->pkt_fmt = NULL;
2232 if (cb_info->dp_interface) {
2233 mm_display_interface_deinit(cb_info->dp_interface);
2234 cb_info->dp_interface = NULL;
2237 cb_info->preview_cb_flag = 0;
2246 int _camera_start_evas_rendering(camera_h camera)
2248 camera_cli_s *pc = (camera_cli_s *)camera;
2250 if (!pc || !pc->cb_info) {
2251 LOGE("NULL handle");
2252 return CAMERA_ERROR_INVALID_PARAMETER;
2257 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2258 LOGE("EVAS surface is not set");
2259 return CAMERA_ERROR_NONE;
2262 /* set evas render flag as RUN */
2263 pc->cb_info->run_evas_render = true;
2265 return CAMERA_ERROR_NONE;
2269 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2271 int ret = CAMERA_ERROR_NONE;
2272 camera_cli_s *pc = (camera_cli_s *)camera;
2274 if (!pc || !pc->cb_info) {
2275 LOGE("NULL handle");
2276 return CAMERA_ERROR_INVALID_PARAMETER;
2279 LOGD("stop - keep screen %d", keep_screen);
2281 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2282 LOGE("EVAS surface is not set");
2283 return CAMERA_ERROR_NONE;
2286 /* set evas render flag as STOP and release buffers */
2287 pc->cb_info->run_evas_render = false;
2289 ret = mm_display_interface_evas_flush(pc->cb_info->dp_interface, keep_screen);
2290 if (ret == MM_ERROR_NONE) {
2291 ret = CAMERA_ERROR_NONE;
2293 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2294 ret = CAMERA_ERROR_INVALID_OPERATION;
2301 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2303 int ret = CAMERA_ERROR_NONE;
2306 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2308 /* create muse connection */
2309 if (!key || !value) {
2310 LOGE("NULL pointer");
2311 return CAMERA_ERROR_INVALID_PARAMETER;
2314 sock_fd = muse_client_new();
2316 LOGE("muse_client_new failed");
2317 return CAMERA_ERROR_INVALID_OPERATION;
2320 msg = muse_core_msg_new(api,
2321 MUSE_TYPE_INT, "module", MUSE_CAMERA,
2322 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2326 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2330 ret = muse_core_msg_send(sock_fd, msg);
2332 muse_core_msg_free(msg);
2336 LOGE("send msg failed");
2337 ret = CAMERA_ERROR_INVALID_OPERATION;
2341 ret = muse_core_msg_recv(sock_fd, recv_msg);
2343 LOGE("recv msg failed %d", errno);
2344 ret = CAMERA_ERROR_INVALID_OPERATION;
2348 if (!muse_camera_msg_get(ret, recv_msg)) {
2349 LOGE("failed to get return value from msg [%s]", recv_msg);
2350 ret = CAMERA_ERROR_INVALID_OPERATION;
2354 if (ret == CAMERA_ERROR_NONE)
2355 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2357 LOGD("api %d - value %d", api, *value);
2361 muse_client_close(sock_fd);
2369 int camera_create(camera_device_e device, camera_h *camera)
2372 char *send_msg = NULL;
2374 int ret = CAMERA_ERROR_NONE;
2376 camera_cli_s *pc = NULL;
2377 tbm_bufmgr bufmgr = NULL;
2379 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2380 muse_core_api_module_e muse_module = MUSE_CAMERA;
2381 int device_type = (int)device;
2384 LOGE("NULL pointer");
2385 return CAMERA_ERROR_INVALID_PARAMETER;
2388 sock_fd = muse_client_new();
2390 LOGE("muse_client_new failed - returned fd %d", sock_fd);
2391 ret = CAMERA_ERROR_INVALID_OPERATION;
2397 send_msg = muse_core_msg_new(api,
2398 MUSE_TYPE_INT, "module", muse_module,
2399 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2400 MUSE_TYPE_INT, "pid", pid,
2405 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2409 send_ret = muse_core_msg_send(sock_fd, send_msg);
2411 muse_core_msg_free(send_msg);
2415 LOGE("send msg failed %d", errno);
2416 ret = CAMERA_ERROR_INVALID_OPERATION;
2420 pc = g_new0(camera_cli_s, 1);
2422 LOGE("camera_cli_s alloc failed");
2423 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2427 bufmgr = tbm_bufmgr_init(-1);
2428 if (bufmgr == NULL) {
2429 LOGE("get tbm bufmgr failed");
2430 ret = CAMERA_ERROR_INVALID_OPERATION;
2434 pc->cb_info = _camera_client_callback_new(sock_fd);
2435 if (pc->cb_info == NULL) {
2436 LOGE("cb_info alloc failed");
2437 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2443 LOGD("cb info : %d", pc->cb_info->fd);
2445 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2447 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2449 if (ret == CAMERA_ERROR_NONE) {
2450 intptr_t handle = 0;
2452 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2454 LOGE("Receiving Handle Failed!!");
2455 ret = CAMERA_ERROR_INVALID_OPERATION;
2459 pc->remote_handle = handle;
2460 pc->cb_info->bufmgr = bufmgr;
2462 ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL);
2463 if (ret != CAMERA_ERROR_NONE) {
2464 LOGE("init display failed 0x%x", ret);
2468 LOGD("camera create 0x%x", pc->remote_handle);
2470 *camera = (camera_h)pc;
2472 /* get display interface handle */
2473 if (mm_display_interface_init(&pc->cb_info->dp_interface) != MM_ERROR_NONE)
2474 LOGW("display interface init failed");
2476 /* get default preview format */
2477 if (camera_get_preview_format(*camera, &pc->cb_info->preview_format) != CAMERA_ERROR_NONE) {
2478 LOGW("get default preview format failed");
2479 pc->cb_info->preview_format = CAMERA_PIXEL_FORMAT_INVALID;
2489 tbm_bufmgr_deinit(bufmgr);
2494 muse_client_close(sock_fd);
2500 int temp_fd = pc->cb_info->fd;
2502 /* pc->cb_info->fd should be closed,
2503 because g_thread_join for msg_recv_thread is not returned
2504 in _camera_client_callback_destroy. */
2506 pc->cb_info->fd = -1;
2507 muse_client_close(temp_fd);
2510 _camera_client_callback_destroy(pc->cb_info);
2517 LOGE("camera create error : 0x%x", ret);
2523 int camera_change_device(camera_h camera, camera_device_e device)
2526 int ret = CAMERA_ERROR_NONE;
2527 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2528 camera_cli_s *pc = (camera_cli_s *)camera;
2529 camera_msg_param param;
2531 if (!pc || !pc->cb_info) {
2532 LOGE("NULL handle");
2533 return CAMERA_ERROR_INVALID_PARAMETER;
2536 CAMERA_MSG_PARAM_SET(param, INT, device);
2538 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2540 if (ret == CAMERA_ERROR_NONE) {
2541 /* reset callback and user data */
2542 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2543 pc->cb_info->user_cb[i] = NULL;
2544 pc->cb_info->user_data[i] = NULL;
2546 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
2553 int camera_destroy(camera_h camera)
2555 int ret = CAMERA_ERROR_NONE;
2556 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2557 camera_cli_s *pc = (camera_cli_s *)camera;
2559 if (!pc || !pc->cb_info) {
2560 LOGE("NULL handle");
2561 return CAMERA_ERROR_INVALID_PARAMETER;
2566 if (pc->cb_info->is_server_connected)
2567 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2569 LOGW("server disconnected. release resource without send message.");
2571 if (ret == CAMERA_ERROR_NONE) {
2572 _camera_deactivate_idle_event_all(pc->cb_info);
2573 _camera_client_callback_destroy(pc->cb_info);
2580 LOGD("ret : 0x%x", ret);
2585 int camera_start_preview(camera_h camera)
2587 int ret = CAMERA_ERROR_NONE;
2588 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2589 camera_cli_s *pc = (camera_cli_s *)camera;
2591 if (!pc || !pc->cb_info) {
2592 LOGE("NULL handle");
2593 return CAMERA_ERROR_INVALID_PARAMETER;
2596 LOGD("Enter : preview format %d, display type %d",
2597 pc->cb_info->preview_format, pc->cb_info->dp_type);
2599 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2600 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2601 ret = _camera_start_evas_rendering(camera);
2602 if (ret != CAMERA_ERROR_NONE) {
2603 LOGE("stop preview because of error");
2604 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, pc->cb_info, NULL, 0);
2608 LOGD("ret : 0x%x", ret);
2614 int camera_stop_preview(camera_h camera)
2616 int ret = CAMERA_ERROR_NONE;
2617 camera_cli_s *pc = (camera_cli_s *)camera;
2618 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2619 camera_state_e current_state = CAMERA_STATE_NONE;
2621 if (!pc || !pc->cb_info) {
2622 LOGE("NULL handle");
2623 return CAMERA_ERROR_INVALID_PARAMETER;
2628 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2629 ret = camera_get_state(camera, ¤t_state);
2630 if (ret != CAMERA_ERROR_NONE) {
2631 LOGE("failed to get current state 0x%x", ret);
2635 if (current_state == CAMERA_STATE_PREVIEW) {
2636 ret = _camera_stop_evas_rendering(camera, false);
2637 if (ret != CAMERA_ERROR_NONE)
2642 /* send stop preview message */
2643 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2645 if (ret != CAMERA_ERROR_NONE &&
2646 current_state == CAMERA_STATE_PREVIEW) {
2647 LOGW("restart evas rendering");
2648 _camera_start_evas_rendering(camera);
2651 LOGD("ret : 0x%x", ret);
2657 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2659 int ret = CAMERA_ERROR_NONE;
2660 camera_cli_s *pc = (camera_cli_s *)camera;
2661 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2663 if (!pc || !pc->cb_info) {
2664 LOGE("NULL handle");
2665 return CAMERA_ERROR_INVALID_PARAMETER;
2670 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2671 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2673 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2674 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2676 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2678 LOGD("ret : 0x%x", ret);
2684 bool camera_is_supported_continuous_capture(camera_h camera)
2686 int ret = CAMERA_ERROR_NONE;
2687 camera_cli_s *pc = (camera_cli_s *)camera;
2688 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2690 if (!pc || !pc->cb_info) {
2691 LOGE("NULL handle");
2692 return CAMERA_ERROR_INVALID_PARAMETER;
2697 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2700 LOGE("error is occurred 0x%x", ret);
2704 LOGD("ret : %d", ret);
2710 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)
2712 int ret = CAMERA_ERROR_NONE;
2713 camera_cli_s *pc = (camera_cli_s *)camera;
2714 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2715 camera_msg_param param;
2718 if (!pc || !pc->cb_info) {
2719 LOGE("NULL handle");
2720 return CAMERA_ERROR_INVALID_PARAMETER;
2725 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2726 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2728 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2729 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2731 value = (count << 16) | interval;
2732 CAMERA_MSG_PARAM_SET(param, INT, value);
2734 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2736 LOGD("ret : 0x%x", ret);
2742 int camera_stop_continuous_capture(camera_h camera)
2744 int ret = CAMERA_ERROR_NONE;
2745 camera_cli_s *pc = (camera_cli_s *)camera;
2746 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2748 if (!pc || !pc->cb_info) {
2749 LOGE("NULL handle");
2750 return CAMERA_ERROR_INVALID_PARAMETER;
2755 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2757 LOGD("ret : 0x%x", ret);
2763 bool camera_is_supported_face_detection(camera_h camera)
2765 int ret = CAMERA_ERROR_NONE;
2766 camera_cli_s *pc = (camera_cli_s *)camera;
2767 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2769 if (!pc || !pc->cb_info) {
2770 LOGE("NULL handle");
2771 return CAMERA_ERROR_INVALID_PARAMETER;
2776 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2779 LOGE("error is occurred 0x%x", ret);
2783 LOGD("ret : %d", ret);
2789 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2791 int ret = CAMERA_ERROR_NONE;
2792 camera_cli_s *pc = (camera_cli_s *)camera;
2793 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2795 if (!pc || !pc->cb_info) {
2796 LOGE("NULL handle");
2797 return CAMERA_ERROR_INVALID_PARAMETER;
2802 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2805 LOGE("error is occurred 0x%x", ret);
2809 LOGD("ret : %d", ret);
2815 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2817 int ret = CAMERA_ERROR_NONE;
2818 camera_cli_s *pc = (camera_cli_s *)camera;
2819 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2821 if (!pc || !pc->cb_info) {
2822 LOGE("NULL handle");
2823 return CAMERA_ERROR_INVALID_PARAMETER;
2828 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2831 LOGE("error is occurred 0x%x", ret);
2835 LOGD("ret : %d", ret);
2840 int camera_get_device_count(camera_h camera, int *device_count)
2842 int ret = CAMERA_ERROR_NONE;
2843 camera_cli_s *pc = (camera_cli_s *)camera;
2844 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2846 if (!pc || !pc->cb_info) {
2847 LOGE("NULL handle");
2848 return CAMERA_ERROR_INVALID_PARAMETER;
2853 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2855 if (ret == CAMERA_ERROR_NONE)
2856 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2858 LOGD("ret : 0x%x", ret);
2863 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2865 int ret = CAMERA_ERROR_NONE;
2866 camera_cli_s *pc = (camera_cli_s *)camera;
2867 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2869 if (!pc || !pc->cb_info) {
2870 LOGE("NULL handle");
2871 return CAMERA_ERROR_INVALID_PARAMETER;
2876 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2878 if (ret == CAMERA_ERROR_NONE) {
2879 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2881 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2882 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2884 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2887 LOGD("ret : 0x%x", ret);
2892 int camera_stop_face_detection(camera_h camera)
2894 int ret = CAMERA_ERROR_NONE;
2895 camera_cli_s *pc = (camera_cli_s *)camera;
2896 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
2898 if (!pc || !pc->cb_info) {
2899 LOGE("NULL handle");
2900 return CAMERA_ERROR_INVALID_PARAMETER;
2905 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2907 if (ret == CAMERA_ERROR_NONE) {
2908 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2910 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
2911 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
2913 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2916 LOGD("ret : 0x%x", ret);
2921 int camera_get_state(camera_h camera, camera_state_e *state)
2923 int ret = CAMERA_ERROR_NONE;
2924 camera_cli_s *pc = (camera_cli_s *)camera;
2925 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
2927 if (!pc || !pc->cb_info || !state) {
2928 LOGE("NULL pointer %p %p", pc, state);
2929 return CAMERA_ERROR_INVALID_PARAMETER;
2934 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2936 if (ret == CAMERA_ERROR_NONE)
2937 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
2939 LOGD("ret : 0x%x", ret);
2944 int camera_start_focusing(camera_h camera, bool continuous)
2946 int ret = CAMERA_ERROR_NONE;
2947 camera_cli_s *pc = (camera_cli_s *)camera;
2948 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
2949 camera_msg_param param;
2950 int is_continuous = (int)continuous;
2952 if (!pc || !pc->cb_info) {
2953 LOGE("NULL handle");
2954 return CAMERA_ERROR_INVALID_PARAMETER;
2959 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
2961 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2963 LOGD("ret : 0x%x", ret);
2968 int camera_cancel_focusing(camera_h camera)
2970 int ret = CAMERA_ERROR_NONE;
2971 camera_cli_s *pc = (camera_cli_s *)camera;
2972 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
2974 if (!pc || !pc->cb_info) {
2975 LOGE("NULL handle");
2976 return CAMERA_ERROR_INVALID_PARAMETER;
2979 LOGD("Enter, remote_handle : %x", pc->remote_handle);
2981 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2983 LOGD("ret : 0x%x", ret);
2988 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
2990 int ret = CAMERA_ERROR_NONE;
2992 camera_cli_s *pc = (camera_cli_s *)camera;
2993 camera_cb_info_s *cb_info = NULL;
2994 camera_state_e current_state = CAMERA_STATE_NONE;
2995 camera_msg_param param0;
2996 camera_msg_param param1;
2997 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
2999 if (!pc || !pc->cb_info) {
3000 LOGE("NULL handle");
3001 return CAMERA_ERROR_INVALID_PARAMETER;
3004 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
3005 LOGE("invalid type %d", type);
3006 return CAMERA_ERROR_INVALID_PARAMETER;
3009 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
3010 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
3011 return CAMERA_ERROR_INVALID_PARAMETER;
3014 cb_info = (camera_cb_info_s *)pc->cb_info;
3016 ret = camera_get_state(camera, ¤t_state);
3017 if (ret != CAMERA_ERROR_NONE) {
3018 LOGE("failed to get current state 0x%x", ret);
3022 if (current_state != CAMERA_STATE_CREATED) {
3023 LOGE("INVALID_STATE : current %d", current_state);
3024 return CAMERA_ERROR_INVALID_STATE;
3027 LOGD("Enter - type : %d, display : %p", type, display);
3029 if (type != CAMERA_DISPLAY_TYPE_NONE) {
3030 /* check display interface handle */
3031 if (!cb_info->dp_interface) {
3032 LOGE("display interface not supported");
3033 return CAMERA_ERROR_NOT_SUPPORTED;
3036 ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &parent_id);
3037 if (ret != MM_ERROR_NONE) {
3038 LOGE("[INVALID_OPERATION] set display failed[0x%x]", ret);
3039 return CAMERA_ERROR_INVALID_OPERATION;
3042 if (type == CAMERA_DISPLAY_TYPE_EVAS) {
3043 camera_flip_e flip = CAMERA_FLIP_NONE;
3044 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3045 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3052 camera_get_display_flip(camera, &flip);
3053 camera_get_display_mode(camera, &mode);
3054 camera_get_display_rotation(camera, &rotation);
3055 camera_is_display_visible(camera, &visible);
3056 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3058 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
3059 flip, mode, rotation, visible, x, y, width, height);
3061 ret = mm_display_interface_evas_set_flip(cb_info->dp_interface, flip);
3062 ret |= mm_display_interface_evas_set_mode(cb_info->dp_interface, mode);
3063 ret |= mm_display_interface_evas_set_rotation(cb_info->dp_interface, rotation);
3064 ret |= mm_display_interface_evas_set_visible(cb_info->dp_interface, visible);
3066 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
3067 ret |= mm_display_interface_evas_set_roi_area(cb_info->dp_interface, x, y, width, height);
3071 cb_info->parent_id = parent_id;
3073 CAMERA_MSG_PARAM_SET(param0, INT, type);
3074 CAMERA_MSG_PARAM_SET(param1, INT, parent_id);
3076 _camera_msg_send_param2_int(api, cb_info, &ret,
3077 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
3079 if (ret == CAMERA_ERROR_NONE) {
3080 pc->cb_info->dp_type = type;
3082 if (type == CAMERA_DISPLAY_TYPE_EVAS)
3083 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3090 int camera_set_preview_resolution(camera_h camera, int width, int height)
3092 int ret = CAMERA_ERROR_NONE;
3093 camera_state_e current_state = CAMERA_STATE_NONE;
3094 camera_cli_s *pc = (camera_cli_s *)camera;
3095 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3096 camera_msg_param param;
3099 if (!pc || !pc->cb_info) {
3100 LOGE("NULL handle");
3101 return CAMERA_ERROR_INVALID_PARAMETER;
3104 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3105 ret = camera_get_state(camera, ¤t_state);
3106 if (ret != CAMERA_ERROR_NONE) {
3107 LOGE("failed to get current state 0x%x", ret);
3111 if (current_state == CAMERA_STATE_PREVIEW) {
3112 ret = _camera_stop_evas_rendering(camera, true);
3113 if (ret != CAMERA_ERROR_NONE)
3118 value = (width << 16) | height;
3119 CAMERA_MSG_PARAM_SET(param, INT, value);
3121 LOGD("%dx%d -> 0x%x", width, height, value);
3123 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3125 LOGD("ret : 0x%x", ret);
3127 if (current_state == CAMERA_STATE_PREVIEW) {
3128 LOGW("restart evas rendering");
3129 _camera_start_evas_rendering(camera);
3136 int camera_set_capture_resolution(camera_h camera, int width, int height)
3138 int ret = CAMERA_ERROR_NONE;
3139 camera_cli_s *pc = (camera_cli_s *)camera;
3140 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3141 camera_msg_param param;
3144 if (!pc || !pc->cb_info) {
3145 LOGE("NULL handle");
3146 return CAMERA_ERROR_INVALID_PARAMETER;
3151 value = (width << 16) | height;
3152 CAMERA_MSG_PARAM_SET(param, INT, value);
3154 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3156 LOGD("ret : 0x%x", ret);
3162 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3164 int ret = CAMERA_ERROR_NONE;
3165 int set_format = (int)format;
3166 camera_cli_s *pc = (camera_cli_s *)camera;
3167 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3168 camera_msg_param param;
3170 if (!pc || !pc->cb_info) {
3171 LOGE("NULL handle");
3172 return CAMERA_ERROR_INVALID_PARAMETER;
3175 LOGD("Enter - format %d", set_format);
3177 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3179 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3181 LOGD("ret : 0x%x", ret);
3187 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3189 int ret = CAMERA_ERROR_NONE;
3190 int set_format = (int)format;
3191 camera_msg_param param;
3192 camera_cli_s *pc = (camera_cli_s *)camera;
3193 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3195 if (!pc || !pc->cb_info) {
3196 LOGE("NULL handle");
3197 return CAMERA_ERROR_INVALID_PARAMETER;
3200 LOGD("Enter - capture_format %d", set_format);
3202 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3204 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3206 if (ret == CAMERA_ERROR_NONE)
3207 pc->cb_info->preview_format = set_format;
3209 LOGD("ret : 0x%x", ret);
3215 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3217 int ret = CAMERA_ERROR_NONE;
3218 camera_cli_s *pc = (camera_cli_s *)camera;
3219 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3221 if (!pc || !pc->cb_info || !width || !height) {
3222 LOGE("NULL pointer %p %p %p", pc, width, height);
3223 return CAMERA_ERROR_INVALID_PARAMETER;
3228 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3230 if (ret == CAMERA_ERROR_NONE) {
3231 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3232 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3235 LOGD("ret : 0x%x", ret);
3241 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3243 int ret = CAMERA_ERROR_NONE;
3244 int set_rotation = (int)rotation;
3245 camera_cli_s *pc = (camera_cli_s *)camera;
3246 camera_msg_param param;
3248 if (!pc || !pc->cb_info) {
3249 LOGE("NULL handle");
3250 return CAMERA_ERROR_INVALID_PARAMETER;
3253 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3254 ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
3255 if (ret != MM_ERROR_NONE) {
3256 LOGE("failed to set rotation for evas surface 0x%x", ret);
3257 return CAMERA_ERROR_INVALID_OPERATION;
3261 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3263 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3269 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3271 int ret = CAMERA_ERROR_NONE;
3272 camera_cli_s *pc = (camera_cli_s *)camera;
3274 if (!pc || !pc->cb_info || !rotation) {
3275 LOGE("NULL pointer %p %p", pc, rotation);
3276 return CAMERA_ERROR_INVALID_PARAMETER;
3279 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3281 if (ret == CAMERA_ERROR_NONE)
3282 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3288 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3290 int ret = CAMERA_ERROR_NONE;
3291 int set_flip = (int)flip;
3292 camera_cli_s *pc = (camera_cli_s *)camera;
3293 camera_msg_param param;
3295 if (!pc || !pc->cb_info) {
3296 LOGE("NULL handle");
3297 return CAMERA_ERROR_INVALID_PARAMETER;
3300 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3301 ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
3302 if (ret != MM_ERROR_NONE) {
3303 LOGE("failed to set flip for evas surface 0x%x", ret);
3304 return CAMERA_ERROR_INVALID_OPERATION;
3308 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3310 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3316 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3318 int ret = CAMERA_ERROR_NONE;
3319 camera_cli_s *pc = (camera_cli_s *)camera;
3321 if (!pc || !pc->cb_info || !flip) {
3322 LOGE("NULL pointer %p %p", pc, flip);
3323 return CAMERA_ERROR_INVALID_PARAMETER;
3326 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3328 if (ret == CAMERA_ERROR_NONE)
3329 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3335 int camera_set_display_visible(camera_h camera, bool visible)
3337 int ret = CAMERA_ERROR_NONE;
3338 int set_visible = (int)visible;
3339 camera_cli_s *pc = (camera_cli_s *)camera;
3340 camera_msg_param param;
3342 if (!pc || !pc->cb_info) {
3343 LOGE("NULL handle");
3344 return CAMERA_ERROR_INVALID_PARAMETER;
3347 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3348 ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
3349 if (ret != MM_ERROR_NONE) {
3350 LOGE("failed to set visible for evas surface 0x%x", ret);
3351 return CAMERA_ERROR_INVALID_OPERATION;
3355 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3357 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3363 int camera_is_display_visible(camera_h camera, bool *visible)
3365 int ret = CAMERA_ERROR_NONE;
3366 camera_cli_s *pc = (camera_cli_s *)camera;
3368 if (!pc || !pc->cb_info || !visible) {
3369 LOGE("NULL pointer %p %p", pc, visible);
3370 return CAMERA_ERROR_INVALID_PARAMETER;
3373 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3375 if (ret == CAMERA_ERROR_NONE)
3376 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3382 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3384 int ret = CAMERA_ERROR_NONE;
3385 int set_mode = (int)mode;
3386 camera_cli_s *pc = (camera_cli_s *)camera;
3387 camera_msg_param param;
3389 if (!pc || !pc->cb_info) {
3390 LOGE("NULL handle");
3391 return CAMERA_ERROR_INVALID_PARAMETER;
3394 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3395 ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
3396 if (ret != MM_ERROR_NONE) {
3397 LOGE("failed to set geometry for evas surface 0x%x", ret);
3398 return CAMERA_ERROR_INVALID_OPERATION;
3402 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3404 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3410 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3412 int ret = CAMERA_ERROR_NONE;
3413 camera_cli_s *pc = (camera_cli_s *)camera;
3415 if (!pc || !pc->cb_info || !mode) {
3416 LOGE("NULL pointer %p %p", pc, mode);
3417 return CAMERA_ERROR_INVALID_PARAMETER;
3420 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3422 if (ret == CAMERA_ERROR_NONE)
3423 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3429 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3431 int ret = CAMERA_ERROR_NONE;
3432 int set_hint = (int)hint;
3433 camera_cli_s *pc = (camera_cli_s *)camera;
3434 camera_msg_param param;
3436 if (!pc || !pc->cb_info) {
3437 LOGE("NULL handle");
3438 return CAMERA_ERROR_INVALID_PARAMETER;
3441 LOGD("Enter - hint %d", set_hint);
3443 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3445 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3451 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3453 int ret = CAMERA_ERROR_NONE;
3454 camera_cli_s *pc = (camera_cli_s *)camera;
3455 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3457 if (!pc || !pc->cb_info || !hint) {
3458 LOGE("NULL pointer %p %p", pc, hint);
3459 return CAMERA_ERROR_INVALID_PARAMETER;
3462 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3464 if (ret == CAMERA_ERROR_NONE) {
3465 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3466 LOGD("display reuse hint %d", *hint);
3473 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3475 int ret = CAMERA_ERROR_NONE;
3476 camera_cli_s *pc = (camera_cli_s *)camera;
3477 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3479 if (!pc || !pc->cb_info || !width || !height) {
3480 LOGE("NULL pointer %p %p %p", pc, width, height);
3481 return CAMERA_ERROR_INVALID_PARAMETER;
3486 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3488 if (ret == CAMERA_ERROR_NONE) {
3489 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3490 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3493 LOGD("ret : 0x%x", ret);
3499 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3501 int ret = CAMERA_ERROR_NONE;
3502 camera_cli_s *pc = (camera_cli_s *)camera;
3503 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3505 if (!pc || !pc->cb_info || !format) {
3506 LOGE("NULL pointer %p %p", pc, format);
3507 return CAMERA_ERROR_INVALID_PARAMETER;
3512 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3514 if (ret == CAMERA_ERROR_NONE)
3515 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3517 LOGD("ret : 0x%x", ret);
3523 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3525 int ret = CAMERA_ERROR_NONE;
3526 camera_cli_s *pc = (camera_cli_s *)camera;
3527 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3529 if (!pc || !pc->cb_info || !format) {
3530 LOGE("NULL pointer %p %p", pc, format);
3531 return CAMERA_ERROR_INVALID_PARAMETER;
3536 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3538 if (ret == CAMERA_ERROR_NONE)
3539 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3541 LOGD("ret : 0x%x", ret);
3547 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3549 int ret = CAMERA_ERROR_NONE;
3550 camera_cli_s *pc = (camera_cli_s *)camera;
3551 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3553 if (!pc || !pc->cb_info || !facing_direction) {
3554 LOGE("NULL pointer %p %p", pc, facing_direction);
3555 return CAMERA_ERROR_INVALID_PARAMETER;
3560 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3562 if (ret == CAMERA_ERROR_NONE)
3563 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3565 LOGD("ret : 0x%x", ret);
3571 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3573 int ret = CAMERA_ERROR_NONE;
3574 camera_cli_s *pc = (camera_cli_s *)camera;
3575 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3577 if (!pc || !pc->cb_info || !callback) {
3578 LOGE("NULL pointer %p %p", pc, callback);
3579 return CAMERA_ERROR_INVALID_PARAMETER;
3584 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3586 if (ret == CAMERA_ERROR_NONE) {
3587 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3589 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3590 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3592 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3594 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3597 LOGD("ret : 0x%x", ret);
3603 int camera_unset_preview_cb(camera_h camera)
3605 int ret = CAMERA_ERROR_NONE;
3606 camera_cli_s *pc = (camera_cli_s *)camera;
3607 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3609 if (!pc || !pc->cb_info) {
3610 LOGE("NULL handle");
3611 return CAMERA_ERROR_INVALID_PARAMETER;
3616 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3618 if (ret == CAMERA_ERROR_NONE) {
3619 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3621 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3622 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3624 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3626 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3629 LOGD("ret : 0x%x", ret);
3635 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3637 int ret = CAMERA_ERROR_NONE;
3638 camera_cli_s *pc = (camera_cli_s *)camera;
3639 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3641 if (!pc || !pc->cb_info) {
3642 LOGE("NULL handle");
3643 return CAMERA_ERROR_INVALID_PARAMETER;
3646 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3647 LOGE("NOT SUPPORTED");
3648 return CAMERA_ERROR_NOT_SUPPORTED;
3651 if (callback == NULL) {
3652 LOGE("NULL callback");
3653 return CAMERA_ERROR_INVALID_PARAMETER;
3658 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3660 if (ret == CAMERA_ERROR_NONE) {
3661 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3663 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3664 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3666 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3669 LOGD("ret : 0x%x", ret);
3675 int camera_unset_media_packet_preview_cb(camera_h camera)
3677 int ret = CAMERA_ERROR_NONE;
3678 camera_cli_s *pc = (camera_cli_s *)camera;
3679 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3681 if (!pc || !pc->cb_info) {
3682 LOGE("NULL handle");
3683 return CAMERA_ERROR_INVALID_PARAMETER;
3688 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3690 if (ret == CAMERA_ERROR_NONE) {
3691 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3693 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3694 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3696 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3699 LOGD("ret : 0x%x", ret);
3705 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3707 int ret = CAMERA_ERROR_NONE;
3708 camera_cli_s *pc = (camera_cli_s *)camera;
3709 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3711 if (!pc || !pc->cb_info || !callback) {
3712 LOGE("NULL pointer %p %p", pc, callback);
3713 return CAMERA_ERROR_INVALID_PARAMETER;
3718 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3720 if (ret == CAMERA_ERROR_NONE) {
3721 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3723 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3724 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3726 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3729 LOGD("ret : 0x%x", ret);
3735 int camera_unset_state_changed_cb(camera_h camera)
3737 int ret = CAMERA_ERROR_NONE;
3738 camera_cli_s *pc = (camera_cli_s *)camera;
3739 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3741 if (!pc || !pc->cb_info) {
3742 LOGE("NULL handle");
3743 return CAMERA_ERROR_INVALID_PARAMETER;
3748 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3750 if (ret == CAMERA_ERROR_NONE) {
3751 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3753 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3754 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3756 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3759 LOGD("ret : 0x%x", ret);
3765 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3767 int ret = CAMERA_ERROR_NONE;
3768 camera_cli_s *pc = (camera_cli_s *)camera;
3769 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3771 if (!pc || !pc->cb_info || !callback) {
3772 LOGE("NULL pointer %p %p", pc, callback);
3773 return CAMERA_ERROR_INVALID_PARAMETER;
3778 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3780 if (ret == CAMERA_ERROR_NONE) {
3781 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3783 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3784 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3786 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3789 LOGD("ret : 0x%x", ret);
3795 int camera_unset_interrupted_cb(camera_h camera)
3797 int ret = CAMERA_ERROR_NONE;
3798 camera_cli_s *pc = (camera_cli_s *)camera;
3799 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3801 if (!pc || !pc->cb_info) {
3802 LOGE("NULL handle");
3803 return CAMERA_ERROR_INVALID_PARAMETER;
3808 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3810 if (ret == CAMERA_ERROR_NONE) {
3811 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3813 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3814 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3816 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3819 LOGD("ret : 0x%x", ret);
3825 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
3827 int ret = CAMERA_ERROR_NONE;
3828 camera_cli_s *pc = (camera_cli_s *)camera;
3829 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
3831 if (!pc || !pc->cb_info || !callback) {
3832 LOGE("NULL pointer %p %p", pc, callback);
3833 return CAMERA_ERROR_INVALID_PARAMETER;
3838 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3840 if (ret == CAMERA_ERROR_NONE) {
3841 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3843 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
3844 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
3846 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3849 LOGD("ret : 0x%x", ret);
3855 int camera_unset_interrupt_started_cb(camera_h camera)
3857 int ret = CAMERA_ERROR_NONE;
3858 camera_cli_s *pc = (camera_cli_s *)camera;
3859 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
3861 if (!pc || !pc->cb_info) {
3862 LOGE("NULL handle");
3863 return CAMERA_ERROR_INVALID_PARAMETER;
3868 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3870 if (ret == CAMERA_ERROR_NONE) {
3871 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3873 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3874 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3876 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3879 LOGD("ret : 0x%x", ret);
3885 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
3887 int ret = CAMERA_ERROR_NONE;
3888 camera_cli_s *pc = (camera_cli_s *)camera;
3889 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3891 if (!pc || !pc->cb_info || !callback) {
3892 LOGE("NULL pointer %p %p", pc, callback);
3893 return CAMERA_ERROR_INVALID_PARAMETER;
3898 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3900 if (ret == CAMERA_ERROR_NONE) {
3901 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3903 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3904 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3906 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3909 LOGD("ret : 0x%x", ret);
3915 int camera_unset_focus_changed_cb(camera_h camera)
3917 int ret = CAMERA_ERROR_NONE;
3918 camera_cli_s *pc = (camera_cli_s *)camera;
3919 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
3921 if (!pc || !pc->cb_info) {
3922 LOGE("NULL handle");
3923 return CAMERA_ERROR_INVALID_PARAMETER;
3928 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3930 if (ret == CAMERA_ERROR_NONE) {
3931 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3933 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3934 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3936 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3939 LOGD("ret : 0x%x", ret);
3945 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
3947 int ret = CAMERA_ERROR_NONE;
3948 camera_cli_s *pc = (camera_cli_s *)camera;
3949 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
3951 if (!pc || !pc->cb_info || !callback) {
3952 LOGE("NULL pointer %p %p", pc, callback);
3953 return CAMERA_ERROR_INVALID_PARAMETER;
3958 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3960 if (ret == CAMERA_ERROR_NONE) {
3961 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3963 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
3964 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
3966 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3969 LOGD("ret : 0x%x", ret);
3975 int camera_unset_error_cb(camera_h camera)
3977 int ret = CAMERA_ERROR_NONE;
3978 camera_cli_s *pc = (camera_cli_s *)camera;
3979 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
3981 if (!pc || !pc->cb_info) {
3982 LOGE("NULL handle");
3983 return CAMERA_ERROR_INVALID_PARAMETER;
3988 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3990 if (ret == CAMERA_ERROR_NONE) {
3991 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3993 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
3994 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
3996 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3999 LOGD("ret : 0x%x", ret);
4005 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4007 int ret = CAMERA_ERROR_NONE;
4008 camera_cli_s *pc = (camera_cli_s *)camera;
4009 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4011 if (!pc || !pc->cb_info || !foreach_cb) {
4012 LOGE("NULL pointer %p %p", pc, foreach_cb);
4013 return CAMERA_ERROR_INVALID_PARAMETER;
4018 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4019 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4021 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4023 LOGD("ret : 0x%x", ret);
4029 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4031 int ret = CAMERA_ERROR_NONE;
4032 camera_cli_s *pc = (camera_cli_s *)camera;
4033 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4035 if (!pc || !pc->cb_info || !foreach_cb) {
4036 LOGE("NULL pointer %p %p", pc, foreach_cb);
4037 return CAMERA_ERROR_INVALID_PARAMETER;
4042 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4043 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4045 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4047 LOGD("ret : 0x%x", ret);
4053 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4055 int ret = CAMERA_ERROR_NONE;
4056 camera_cli_s *pc = (camera_cli_s *)camera;
4057 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4059 if (!pc || !pc->cb_info || !foreach_cb) {
4060 LOGE("NULL pointer %p %p", pc, foreach_cb);
4061 return CAMERA_ERROR_INVALID_PARAMETER;
4066 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4067 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4069 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4071 LOGD("ret : 0x%x", ret);
4077 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4079 int ret = CAMERA_ERROR_NONE;
4080 camera_cli_s *pc = (camera_cli_s *)camera;
4081 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4083 if (!pc || !pc->cb_info || !foreach_cb) {
4084 LOGE("NULL pointer %p %p", pc, foreach_cb);
4085 return CAMERA_ERROR_INVALID_PARAMETER;
4090 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4091 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4093 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4095 LOGD("ret : 0x%x", ret);
4101 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4103 int ret = CAMERA_ERROR_NONE;
4104 camera_cli_s *pc = (camera_cli_s *)camera;
4105 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4107 if (!pc || !pc->cb_info || !width || !height) {
4108 LOGE("NULL pointer %p %p %p", pc, width, height);
4109 return CAMERA_ERROR_INVALID_PARAMETER;
4113 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4115 if (ret == CAMERA_ERROR_NONE) {
4116 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4117 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4120 LOGD("ret : 0x%x", ret);
4126 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4128 int ret = CAMERA_ERROR_NONE;
4129 camera_cli_s *pc = (camera_cli_s *)camera;
4130 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4132 if (!pc || !pc->cb_info || !angle) {
4133 LOGE("NULL pointer %p %p", pc, angle);
4134 return CAMERA_ERROR_INVALID_PARAMETER;
4139 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4141 if (ret == CAMERA_ERROR_NONE)
4142 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4144 LOGD("ret : 0x%x", ret);
4150 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4152 int ret = CAMERA_ERROR_NONE;
4153 camera_cli_s *pc = (camera_cli_s *)camera;
4154 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4155 camera_msg_param param;
4156 int set_mode = (int)mode;
4158 if (!pc || !pc->cb_info) {
4159 LOGE("NULL handle");
4160 return CAMERA_ERROR_INVALID_PARAMETER;
4165 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4167 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4169 LOGD("ret : 0x%x", ret);
4175 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4177 int ret = CAMERA_ERROR_NONE;
4178 camera_cli_s *pc = (camera_cli_s *)camera;
4179 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4181 if (!pc || !pc->cb_info || !mode) {
4182 LOGE("NULL pointer %p %p", pc, mode);
4183 return CAMERA_ERROR_INVALID_PARAMETER;
4188 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4190 if (ret == CAMERA_ERROR_NONE)
4191 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4193 LOGD("ret : 0x%x", ret);
4199 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4201 int ret = CAMERA_ERROR_NONE;
4202 camera_cli_s *pc = (camera_cli_s *)camera;
4203 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4205 if (!pc || !pc->cb_info || !foreach_cb) {
4206 LOGE("NULL pointer %p %p", pc, foreach_cb);
4207 return CAMERA_ERROR_INVALID_PARAMETER;
4212 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4213 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4215 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4217 LOGD("Finish, return :%x", ret);
4223 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4225 int ret = CAMERA_ERROR_NONE;
4226 camera_cli_s *pc = (camera_cli_s *)camera;
4227 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4228 camera_msg_param param;
4229 int set_fps = (int)fps;
4231 if (!pc || !pc->cb_info) {
4232 LOGE("NULL handle");
4233 return CAMERA_ERROR_INVALID_PARAMETER;
4238 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4240 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4242 LOGD("ret : 0x%x", ret);
4248 int camera_attr_set_image_quality(camera_h camera, int quality)
4250 int ret = CAMERA_ERROR_NONE;
4251 camera_cli_s *pc = (camera_cli_s *)camera;
4252 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4253 camera_msg_param param;
4255 if (!pc || !pc->cb_info) {
4256 LOGE("NULL handle");
4257 return CAMERA_ERROR_INVALID_PARAMETER;
4262 CAMERA_MSG_PARAM_SET(param, INT, quality);
4264 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4266 LOGD("ret : 0x%x", ret);
4272 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4274 int ret = CAMERA_ERROR_NONE;
4275 camera_cli_s *pc = (camera_cli_s *)camera;
4276 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4278 if (!pc || !pc->cb_info || !fps) {
4279 LOGE("NULL pointer %p %p", pc, fps);
4280 return CAMERA_ERROR_INVALID_PARAMETER;
4285 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4287 if (ret == CAMERA_ERROR_NONE)
4288 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4290 LOGD("ret : 0x%x", ret);
4296 int camera_attr_get_image_quality(camera_h camera, int *quality)
4298 int ret = CAMERA_ERROR_NONE;
4299 camera_cli_s *pc = (camera_cli_s *)camera;
4300 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4302 if (!pc || !pc->cb_info || !quality) {
4303 LOGE("NULL pointer %p %p", pc, quality);
4304 return CAMERA_ERROR_INVALID_PARAMETER;
4309 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4311 if (ret == CAMERA_ERROR_NONE)
4312 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4314 LOGD("ret : 0x%x", ret);
4320 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4322 int ret = CAMERA_ERROR_NONE;
4323 camera_cli_s *pc = (camera_cli_s *)camera;
4324 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4326 if (!pc || !pc->cb_info || !bitrate) {
4327 LOGE("NULL pointer %p %p", pc, bitrate);
4328 return CAMERA_ERROR_INVALID_PARAMETER;
4333 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4335 if (ret == CAMERA_ERROR_NONE)
4336 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4338 LOGD("ret : 0x%x", ret);
4344 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4346 int ret = CAMERA_ERROR_NONE;
4347 camera_cli_s *pc = (camera_cli_s *)camera;
4348 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4349 camera_msg_param param;
4350 int set_bitrate = bitrate;
4352 if (!pc || !pc->cb_info) {
4353 LOGE("NULL handle");
4354 return CAMERA_ERROR_INVALID_PARAMETER;
4359 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4361 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4363 LOGD("ret : 0x%x", ret);
4369 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4371 int ret = CAMERA_ERROR_NONE;
4372 camera_cli_s *pc = (camera_cli_s *)camera;
4373 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4375 if (!pc || !pc->cb_info || !interval) {
4376 LOGE("NULL pointer %p %p", pc, interval);
4377 return CAMERA_ERROR_INVALID_PARAMETER;
4382 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4384 if (ret == CAMERA_ERROR_NONE)
4385 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4387 LOGD("ret : 0x%x", ret);
4393 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4395 int ret = CAMERA_ERROR_NONE;
4396 camera_cli_s *pc = (camera_cli_s *)camera;
4397 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4398 camera_msg_param param;
4399 int set_gop_interval = interval;
4401 if (!pc || !pc->cb_info) {
4402 LOGE("NULL handle");
4403 return CAMERA_ERROR_INVALID_PARAMETER;
4408 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4410 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4412 LOGD("ret : 0x%x", ret);
4418 int camera_attr_set_zoom(camera_h camera, int zoom)
4420 int ret = CAMERA_ERROR_NONE;
4421 camera_cli_s *pc = (camera_cli_s *)camera;
4422 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4423 camera_msg_param param;
4425 if (!pc || !pc->cb_info) {
4426 LOGE("NULL handle");
4427 return CAMERA_ERROR_INVALID_PARAMETER;
4430 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4432 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4434 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4436 LOGD("ret : 0x%x", ret);
4442 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4444 int ret = CAMERA_ERROR_NONE;
4445 camera_cli_s *pc = (camera_cli_s *)camera;
4446 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4447 camera_msg_param param;
4448 int set_mode = (int)mode;
4450 if (!pc || !pc->cb_info) {
4451 LOGE("NULL handle");
4452 return CAMERA_ERROR_INVALID_PARAMETER;
4455 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4457 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4459 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4465 int camera_attr_set_af_area(camera_h camera, int x, int y)
4467 int ret = CAMERA_ERROR_NONE;
4468 camera_cli_s *pc = (camera_cli_s *)camera;
4469 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4470 camera_msg_param param;
4473 if (!pc || !pc->cb_info) {
4474 LOGE("NULL handle");
4475 return CAMERA_ERROR_INVALID_PARAMETER;
4478 LOGD("Enter - %d,%d", x, y);
4480 value = (x << 16) | y;
4481 CAMERA_MSG_PARAM_SET(param, INT, value);
4483 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4485 LOGD("ret : 0x%x", ret);
4491 int camera_attr_clear_af_area(camera_h camera)
4493 int ret = CAMERA_ERROR_NONE;
4494 camera_cli_s *pc = (camera_cli_s *)camera;
4495 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4497 if (!pc || !pc->cb_info) {
4498 LOGE("NULL handle");
4499 return CAMERA_ERROR_INVALID_PARAMETER;
4504 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4506 LOGD("ret : 0x%x", ret);
4512 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4514 int ret = CAMERA_ERROR_NONE;
4515 camera_cli_s *pc = (camera_cli_s *)camera;
4516 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4517 camera_msg_param param;
4518 int set_mode = (int)mode;
4520 if (!pc || !pc->cb_info) {
4521 LOGE("NULL handle");
4522 return CAMERA_ERROR_INVALID_PARAMETER;
4527 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4529 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4531 LOGD("ret : 0x%x", ret);
4537 int camera_attr_set_exposure(camera_h camera, int value)
4539 int ret = CAMERA_ERROR_NONE;
4540 camera_cli_s *pc = (camera_cli_s *)camera;
4541 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4542 camera_msg_param param;
4544 if (!pc || !pc->cb_info) {
4545 LOGE("NULL handle");
4546 return CAMERA_ERROR_INVALID_PARAMETER;
4551 CAMERA_MSG_PARAM_SET(param, INT, value);
4553 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4555 LOGD("ret : 0x%x", ret);
4561 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4563 int ret = CAMERA_ERROR_NONE;
4564 camera_cli_s *pc = (camera_cli_s *)camera;
4565 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4566 camera_msg_param param;
4567 int set_iso = (int)iso;
4569 if (!pc || !pc->cb_info) {
4570 LOGE("NULL handle");
4571 return CAMERA_ERROR_INVALID_PARAMETER;
4576 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4578 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4580 LOGD("ret : 0x%x", ret);
4586 int camera_attr_set_brightness(camera_h camera, int level)
4588 int ret = CAMERA_ERROR_NONE;
4589 camera_cli_s *pc = (camera_cli_s *)camera;
4590 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4591 camera_msg_param param;
4593 if (!pc || !pc->cb_info) {
4594 LOGE("NULL handle");
4595 return CAMERA_ERROR_INVALID_PARAMETER;
4600 CAMERA_MSG_PARAM_SET(param, INT, level);
4602 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4604 LOGD("ret : 0x%x", ret);
4610 int camera_attr_set_contrast(camera_h camera, int level)
4612 int ret = CAMERA_ERROR_NONE;
4613 camera_cli_s *pc = (camera_cli_s *)camera;
4614 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4615 camera_msg_param param;
4617 if (!pc || !pc->cb_info) {
4618 LOGE("NULL handle");
4619 return CAMERA_ERROR_INVALID_PARAMETER;
4624 CAMERA_MSG_PARAM_SET(param, INT, level);
4626 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4628 LOGD("ret : 0x%x", ret);
4634 int camera_attr_set_hue(camera_h camera, int level)
4636 int ret = CAMERA_ERROR_NONE;
4637 camera_cli_s *pc = (camera_cli_s *)camera;
4638 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HUE;
4639 camera_msg_param param;
4641 if (!pc || !pc->cb_info) {
4642 LOGE("NULL handle");
4643 return CAMERA_ERROR_INVALID_PARAMETER;
4648 CAMERA_MSG_PARAM_SET(param, INT, level);
4650 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4652 LOGD("ret : 0x%x", ret);
4658 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4660 int ret = CAMERA_ERROR_NONE;
4661 camera_cli_s *pc = (camera_cli_s *)camera;
4662 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4663 camera_msg_param param;
4664 int set_whitebalance = (int)wb;
4666 if (!pc || !pc->cb_info) {
4667 LOGE("NULL handle");
4668 return CAMERA_ERROR_INVALID_PARAMETER;
4673 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4675 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4677 LOGD("ret : 0x%x", ret);
4683 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4685 int ret = CAMERA_ERROR_NONE;
4686 camera_cli_s *pc = (camera_cli_s *)camera;
4687 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4688 camera_msg_param param;
4689 int set_effect = (int)effect;
4691 if (!pc || !pc->cb_info) {
4692 LOGE("NULL handle");
4693 return CAMERA_ERROR_INVALID_PARAMETER;
4698 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4700 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4702 LOGD("ret : 0x%x", ret);
4708 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4710 int ret = CAMERA_ERROR_NONE;
4711 camera_cli_s *pc = (camera_cli_s *)camera;
4712 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4713 camera_msg_param param;
4714 int set_mode = (int)mode;
4716 if (!pc || !pc->cb_info) {
4717 LOGE("NULL handle");
4718 return CAMERA_ERROR_INVALID_PARAMETER;
4723 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4725 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4727 LOGD("ret : 0x%x", ret);
4733 int camera_attr_enable_tag(camera_h camera, bool enable)
4735 int ret = CAMERA_ERROR_NONE;
4736 camera_cli_s *pc = (camera_cli_s *)camera;
4737 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4738 camera_msg_param param;
4739 int set_enable = (int)enable;
4741 if (!pc || !pc->cb_info) {
4742 LOGE("NULL handle");
4743 return CAMERA_ERROR_INVALID_PARAMETER;
4748 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4750 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4752 LOGD("ret : 0x%x", ret);
4758 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4760 int ret = CAMERA_ERROR_NONE;
4761 camera_cli_s *pc = (camera_cli_s *)camera;
4762 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4763 camera_msg_param param;
4765 if (!pc || !pc->cb_info || !description) {
4766 LOGE("NULL pointer %p %p", pc, description);
4767 return CAMERA_ERROR_INVALID_PARAMETER;
4772 CAMERA_MSG_PARAM_SET(param, STRING, description);
4774 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4776 LOGD("ret : 0x%x", ret);
4782 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4784 int ret = CAMERA_ERROR_NONE;
4785 camera_cli_s *pc = (camera_cli_s *)camera;
4786 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4787 camera_msg_param param;
4788 int set_orientation = (int)orientation;
4790 if (!pc || !pc->cb_info) {
4791 LOGE("NULL handle");
4792 return CAMERA_ERROR_INVALID_PARAMETER;
4797 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4799 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4801 LOGD("ret : 0x%x", ret);
4807 int camera_attr_set_tag_software(camera_h camera, const char *software)
4809 int ret = CAMERA_ERROR_NONE;
4810 camera_cli_s *pc = (camera_cli_s *)camera;
4811 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4812 camera_msg_param param;
4814 if (!pc || !pc->cb_info || !software) {
4815 LOGE("NULL pointer %p %p", pc, software);
4816 return CAMERA_ERROR_INVALID_PARAMETER;
4819 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4821 CAMERA_MSG_PARAM_SET(param, STRING, software);
4823 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4825 LOGD("ret : 0x%x", ret);
4831 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4833 int ret = CAMERA_ERROR_NONE;
4834 camera_cli_s *pc = (camera_cli_s *)camera;
4835 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4836 double set_geotag[3] = {latitude, longitude, altitude};
4841 if (!pc || !pc->cb_info) {
4842 LOGE("NULL handle");
4843 return CAMERA_ERROR_INVALID_PARAMETER;
4848 length = sizeof(set_geotag) / sizeof(int) + \
4849 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4851 msg = muse_core_msg_new(api,
4852 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4855 LOGE("msg creation failed: api %d", api);
4856 return CAMERA_ERROR_OUT_OF_MEMORY;
4859 if (pc->cb_info->is_server_connected) {
4860 __camera_update_api_waiting(pc->cb_info, api, 1);
4862 g_mutex_lock(&pc->cb_info->fd_lock);
4863 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
4864 g_mutex_unlock(&pc->cb_info->fd_lock);
4868 LOGE("message send failed");
4869 ret = CAMERA_ERROR_INVALID_OPERATION;
4871 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
4874 __camera_update_api_waiting(pc->cb_info, api, -1);
4876 muse_core_msg_free(msg);
4878 LOGD("ret : 0x%x", ret);
4884 int camera_attr_remove_geotag(camera_h camera)
4886 int ret = CAMERA_ERROR_NONE;
4887 camera_cli_s *pc = (camera_cli_s *)camera;
4888 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4890 if (!pc || !pc->cb_info) {
4891 LOGE("NULL handle");
4892 return CAMERA_ERROR_INVALID_PARAMETER;
4897 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4899 LOGD("ret : 0x%x", ret);
4905 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4907 int ret = CAMERA_ERROR_NONE;
4908 camera_cli_s *pc = (camera_cli_s *)camera;
4909 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
4910 camera_msg_param param;
4911 int set_mode = (int)mode;
4913 if (!pc || !pc->cb_info) {
4914 LOGE("NULL handle");
4915 return CAMERA_ERROR_INVALID_PARAMETER;
4920 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4922 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4924 LOGD("ret : 0x%x", ret);
4930 int camera_attr_get_zoom(camera_h camera, int *zoom)
4932 int ret = CAMERA_ERROR_NONE;
4933 camera_cli_s *pc = (camera_cli_s *)camera;
4934 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4936 if (!pc || !pc->cb_info || !zoom) {
4937 LOGE("NULL pointer %p %p", pc, zoom);
4938 return CAMERA_ERROR_INVALID_PARAMETER;
4943 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4945 if (ret == CAMERA_ERROR_NONE)
4946 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
4948 LOGD("ret : 0x%x", ret);
4954 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
4956 int ret = CAMERA_ERROR_NONE;
4957 camera_cli_s *pc = (camera_cli_s *)camera;
4958 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
4960 if (!pc || !pc->cb_info || !min || !max) {
4961 LOGE("NULL pointer %p %p %p", pc, min, max);
4962 return CAMERA_ERROR_INVALID_PARAMETER;
4967 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4969 if (ret == CAMERA_ERROR_NONE) {
4970 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
4971 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
4974 LOGD("ret : 0x%x", ret);
4980 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
4982 int ret = CAMERA_ERROR_NONE;
4983 camera_cli_s *pc = (camera_cli_s *)camera;
4984 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
4986 if (!pc || !pc->cb_info || !mode) {
4987 LOGE("NULL pointer %p %p", pc, mode);
4988 return CAMERA_ERROR_INVALID_PARAMETER;
4993 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4995 if (ret == CAMERA_ERROR_NONE)
4996 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
4998 LOGD("ret : 0x%x", ret);
5004 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5006 int ret = CAMERA_ERROR_NONE;
5007 camera_cli_s *pc = (camera_cli_s *)camera;
5008 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5010 if (!pc || !pc->cb_info || !mode) {
5011 LOGE("NULL pointer %p %p", pc, mode);
5012 return CAMERA_ERROR_INVALID_PARAMETER;
5017 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5019 if (ret == CAMERA_ERROR_NONE)
5020 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5022 LOGD("ret : 0x%x", ret);
5028 int camera_attr_get_exposure(camera_h camera, int *value)
5030 int ret = CAMERA_ERROR_NONE;
5031 camera_cli_s *pc = (camera_cli_s *)camera;
5032 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5034 if (!pc || !pc->cb_info || !value) {
5035 LOGE("NULL pointer %p %p", pc, value);
5036 return CAMERA_ERROR_INVALID_PARAMETER;
5041 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5043 if (ret == CAMERA_ERROR_NONE)
5044 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5046 LOGD("ret : 0x%x", ret);
5052 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5054 int ret = CAMERA_ERROR_NONE;
5055 camera_cli_s *pc = (camera_cli_s *)camera;
5056 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5058 if (!pc || !pc->cb_info || !min || !max) {
5059 LOGE("NULL pointer %p %p %p", pc, min, max);
5060 return CAMERA_ERROR_INVALID_PARAMETER;
5065 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5067 if (ret == CAMERA_ERROR_NONE) {
5068 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5069 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5072 LOGD("ret : 0x%x", ret);
5078 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5080 int ret = CAMERA_ERROR_NONE;
5081 camera_cli_s *pc = (camera_cli_s *)camera;
5082 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5084 if (!pc || !pc->cb_info || !iso) {
5085 LOGE("NULL pointer %p %p", pc, iso);
5086 return CAMERA_ERROR_INVALID_PARAMETER;
5091 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5093 if (ret == CAMERA_ERROR_NONE)
5094 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5096 LOGD("ret : 0x%x", ret);
5102 int camera_attr_get_brightness(camera_h camera, int *level)
5104 int ret = CAMERA_ERROR_NONE;
5105 camera_cli_s *pc = (camera_cli_s *)camera;
5106 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5108 if (!pc || !pc->cb_info || !level) {
5109 LOGE("NULL pointer %p %p", pc, level);
5110 return CAMERA_ERROR_INVALID_PARAMETER;
5115 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5117 if (ret == CAMERA_ERROR_NONE)
5118 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5120 LOGD("ret : 0x%x", ret);
5126 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5128 int ret = CAMERA_ERROR_NONE;
5129 camera_cli_s *pc = (camera_cli_s *)camera;
5130 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5132 if (!pc || !pc->cb_info || !min || !max) {
5133 LOGE("NULL pointer %p %p %p", pc, min, max);
5134 return CAMERA_ERROR_INVALID_PARAMETER;
5139 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5141 if (ret == CAMERA_ERROR_NONE) {
5142 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5143 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5146 LOGD("ret : 0x%x", ret);
5152 int camera_attr_get_contrast(camera_h camera, int *level)
5154 int ret = CAMERA_ERROR_NONE;
5155 camera_cli_s *pc = (camera_cli_s *)camera;
5156 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5158 if (!pc || !pc->cb_info || !level) {
5159 LOGE("NULL pointer %p %p", pc, level);
5160 return CAMERA_ERROR_INVALID_PARAMETER;
5165 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5167 if (ret == CAMERA_ERROR_NONE)
5168 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5170 LOGD("ret : 0x%x", ret);
5176 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5178 int ret = CAMERA_ERROR_NONE;
5179 camera_cli_s *pc = (camera_cli_s *)camera;
5180 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5182 if (!pc || !pc->cb_info || !min || !max) {
5183 LOGE("NULL pointer %p %p %p", pc, min, max);
5184 return CAMERA_ERROR_INVALID_PARAMETER;
5189 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5191 if (ret == CAMERA_ERROR_NONE) {
5192 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5193 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5194 LOGD("min %d, max %d", *min, *max);
5197 LOGD("ret : 0x%x", ret);
5203 int camera_attr_get_hue(camera_h camera, int *level)
5205 int ret = CAMERA_ERROR_NONE;
5206 camera_cli_s *pc = (camera_cli_s *)camera;
5207 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE;
5209 if (!pc || !pc->cb_info || !level) {
5210 LOGE("NULL pointer %p %p", pc, level);
5211 return CAMERA_ERROR_INVALID_PARAMETER;
5216 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5218 if (ret == CAMERA_ERROR_NONE)
5219 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HUE];
5221 LOGD("ret : 0x%x", ret);
5227 int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
5229 int ret = CAMERA_ERROR_NONE;
5230 camera_cli_s *pc = (camera_cli_s *)camera;
5231 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE_RANGE;
5233 if (!pc || !pc->cb_info || !min || !max) {
5234 LOGE("NULL pointer %p %p %p", pc, min, max);
5235 return CAMERA_ERROR_INVALID_PARAMETER;
5240 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5242 if (ret == CAMERA_ERROR_NONE) {
5243 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][0];
5244 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][1];
5245 LOGD("min %d, max %d", *min, *max);
5248 LOGD("ret : 0x%x", ret);
5254 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5256 int ret = CAMERA_ERROR_NONE;
5257 camera_cli_s *pc = (camera_cli_s *)camera;
5258 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5260 if (!pc || !pc->cb_info || !wb) {
5261 LOGE("NULL pointer %p %p", pc, wb);
5262 return CAMERA_ERROR_INVALID_PARAMETER;
5267 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5269 if (ret == CAMERA_ERROR_NONE)
5270 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5272 LOGD("ret : 0x%x", ret);
5278 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5280 int ret = CAMERA_ERROR_NONE;
5281 camera_cli_s *pc = (camera_cli_s *)camera;
5282 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5284 if (!pc || !pc->cb_info || !effect) {
5285 LOGE("NULL pointer %p %p", pc, effect);
5286 return CAMERA_ERROR_INVALID_PARAMETER;
5291 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5293 if (ret == CAMERA_ERROR_NONE)
5294 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5296 LOGD("ret : 0x%x", ret);
5302 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5304 int ret = CAMERA_ERROR_NONE;
5305 camera_cli_s *pc = (camera_cli_s *)camera;
5306 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5308 if (!pc || !pc->cb_info || !mode) {
5309 LOGE("NULL pointer %p %p", pc, mode);
5310 return CAMERA_ERROR_INVALID_PARAMETER;
5315 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5317 if (ret == CAMERA_ERROR_NONE)
5318 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5320 LOGD("ret : 0x%x", ret);
5326 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5328 int ret = CAMERA_ERROR_NONE;
5329 camera_cli_s *pc = (camera_cli_s *)camera;
5330 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5332 if (!pc || !pc->cb_info || !enable) {
5333 LOGE("NULL pointer %p %p", pc, enable);
5334 return CAMERA_ERROR_INVALID_PARAMETER;
5339 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5341 if (ret == CAMERA_ERROR_NONE)
5342 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5344 LOGD("ret : 0x%x", ret);
5350 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5352 int ret = CAMERA_ERROR_NONE;
5353 camera_cli_s *pc = (camera_cli_s *)camera;
5354 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5356 if (!pc || !pc->cb_info || !description) {
5357 LOGE("NULL pointer %p %p", pc, description);
5358 return CAMERA_ERROR_INVALID_PARAMETER;
5363 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5365 if (ret == CAMERA_ERROR_NONE)
5366 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5368 LOGD("ret : 0x%x", ret);
5374 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5376 int ret = CAMERA_ERROR_NONE;
5377 camera_cli_s *pc = (camera_cli_s *)camera;
5378 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5380 if (!pc || !pc->cb_info || !orientation) {
5381 LOGE("NULL pointer %p %p", pc, orientation);
5382 return CAMERA_ERROR_INVALID_PARAMETER;
5387 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5389 if (ret == CAMERA_ERROR_NONE)
5390 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5392 LOGD("ret : 0x%x", ret);
5398 int camera_attr_get_tag_software(camera_h camera, char **software)
5400 int ret = CAMERA_ERROR_NONE;
5401 camera_cli_s *pc = (camera_cli_s *)camera;
5402 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5404 if (!pc || !pc->cb_info || !software) {
5405 LOGE("NULL pointer %p %p", pc, software);
5406 return CAMERA_ERROR_INVALID_PARAMETER;
5411 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5413 if (ret == CAMERA_ERROR_NONE)
5414 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5416 LOGD("ret : 0x%x", ret);
5422 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5424 int ret = CAMERA_ERROR_NONE;
5425 camera_cli_s *pc = (camera_cli_s *)camera;
5426 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5428 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5429 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5430 return CAMERA_ERROR_INVALID_PARAMETER;
5435 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5437 if (ret == CAMERA_ERROR_NONE) {
5438 *latitude = pc->cb_info->get_geotag[0];
5439 *longitude = pc->cb_info->get_geotag[1];
5440 *altitude = pc->cb_info->get_geotag[2];
5443 LOGD("ret : 0x%x", ret);
5449 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5451 int ret = CAMERA_ERROR_NONE;
5452 camera_cli_s *pc = (camera_cli_s *)camera;
5453 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5455 if (!pc || !pc->cb_info || !mode) {
5456 LOGE("NULL pointer %p %p", pc, mode);
5457 return CAMERA_ERROR_INVALID_PARAMETER;
5462 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5464 if (ret == CAMERA_ERROR_NONE)
5465 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5467 LOGD("ret : 0x%x", ret);
5473 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5475 int ret = CAMERA_ERROR_NONE;
5476 int get_flash_state = 0;
5479 LOGE("NULL pointer");
5480 return CAMERA_ERROR_INVALID_PARAMETER;
5483 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5484 (int)device, "get_flash_state", &get_flash_state);
5486 if (ret == CAMERA_ERROR_NONE) {
5487 *state = (camera_flash_state_e)get_flash_state;
5488 LOGD("flash state %d", *state);
5490 LOGE("failed 0x%x", ret);
5497 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5499 int ret = CAMERA_ERROR_NONE;
5500 camera_cli_s *pc = (camera_cli_s *)camera;
5501 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5503 if (!pc || !pc->cb_info || !foreach_cb) {
5504 LOGE("NULL pointer %p %p", pc, foreach_cb);
5505 return CAMERA_ERROR_INVALID_PARAMETER;
5510 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5511 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5513 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5515 LOGD("ret : 0x%x", ret);
5521 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5523 int ret = CAMERA_ERROR_NONE;
5524 camera_cli_s *pc = (camera_cli_s *)camera;
5525 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5527 if (!pc || !pc->cb_info || !foreach_cb) {
5528 LOGE("NULL pointer %p %p", pc, foreach_cb);
5529 return CAMERA_ERROR_INVALID_PARAMETER;
5534 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5535 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5537 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5539 LOGD("ret : 0x%x", ret);
5545 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5547 int ret = CAMERA_ERROR_NONE;
5548 camera_cli_s *pc = (camera_cli_s *)camera;
5549 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5551 if (!pc || !pc->cb_info || !foreach_cb) {
5552 LOGE("NULL pointer %p %p", pc, foreach_cb);
5553 return CAMERA_ERROR_INVALID_PARAMETER;
5558 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5559 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5561 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5563 LOGD("ret : 0x%x", ret);
5569 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5571 int ret = CAMERA_ERROR_NONE;
5572 camera_cli_s *pc = (camera_cli_s *)camera;
5573 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5575 if (!pc || !pc->cb_info || !foreach_cb) {
5576 LOGE("NULL pointer %p %p", pc, foreach_cb);
5577 return CAMERA_ERROR_INVALID_PARAMETER;
5582 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5583 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5585 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5587 LOGD("ret : 0x%x", ret);
5593 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5595 int ret = CAMERA_ERROR_NONE;
5596 camera_cli_s *pc = (camera_cli_s *)camera;
5597 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5599 if (!pc || !pc->cb_info || !foreach_cb) {
5600 LOGE("NULL pointer %p %p", pc, foreach_cb);
5601 return CAMERA_ERROR_INVALID_PARAMETER;
5606 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5607 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5609 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5611 LOGD("ret : 0x%x", ret);
5617 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5619 int ret = CAMERA_ERROR_NONE;
5620 camera_cli_s *pc = (camera_cli_s *)camera;
5621 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5623 if (!pc || !pc->cb_info || !foreach_cb) {
5624 LOGE("NULL pointer %p %p", pc, foreach_cb);
5625 return CAMERA_ERROR_INVALID_PARAMETER;
5630 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5631 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5633 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5635 LOGD("ret : 0x%x", ret);
5641 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5643 int ret = CAMERA_ERROR_NONE;
5644 camera_cli_s *pc = (camera_cli_s *)camera;
5645 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5647 if (!pc || !pc->cb_info || !foreach_cb) {
5648 LOGE("NULL pointer %p %p", pc, foreach_cb);
5649 return CAMERA_ERROR_INVALID_PARAMETER;
5654 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5655 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5657 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5659 LOGD("ret : 0x%x", ret);
5665 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5667 int ret = CAMERA_ERROR_NONE;
5668 camera_cli_s *pc = (camera_cli_s *)camera;
5669 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5671 if (!pc || !pc->cb_info || !foreach_cb) {
5672 LOGE("NULL pointer %p %p", pc, foreach_cb);
5673 return CAMERA_ERROR_INVALID_PARAMETER;
5678 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5679 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5681 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5683 LOGD("Enter, handle :%x", pc->remote_handle);
5689 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)
5691 int ret = CAMERA_ERROR_NONE;
5692 camera_cli_s *pc = (camera_cli_s *)camera;
5693 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5694 camera_msg_param param;
5697 if (!pc || !pc->cb_info || !foreach_cb) {
5698 LOGE("NULL pointer %p %p", pc, foreach_cb);
5699 return CAMERA_ERROR_INVALID_PARAMETER;
5704 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5705 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5707 value = (width << 16) | height;
5708 CAMERA_MSG_PARAM_SET(param, INT, value);
5710 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5712 LOGD("ret : 0x%x", ret);
5718 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5720 int ret = CAMERA_ERROR_NONE;
5721 camera_cli_s *pc = (camera_cli_s *)camera;
5722 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5724 if (!pc || !pc->cb_info || !foreach_cb) {
5725 LOGE("NULL pointer %p %p", pc, foreach_cb);
5726 return CAMERA_ERROR_INVALID_PARAMETER;
5731 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5732 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5734 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5736 LOGD("ret : 0x%x", ret);
5742 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5744 int ret = CAMERA_ERROR_NONE;
5745 camera_cli_s *pc = (camera_cli_s *)camera;
5746 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5748 if (!pc || !pc->cb_info || !foreach_cb) {
5749 LOGE("NULL pointer %p %p", pc, foreach_cb);
5750 return CAMERA_ERROR_INVALID_PARAMETER;
5755 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5756 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5758 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5760 LOGD("ret : 0x%x", ret);
5766 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5768 int ret = CAMERA_ERROR_NONE;
5769 camera_cli_s *pc = (camera_cli_s *)camera;
5770 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5771 camera_msg_param param;
5772 int set_rotation = (int)rotation;
5774 if (!pc || !pc->cb_info) {
5775 LOGE("NULL handle");
5776 return CAMERA_ERROR_INVALID_PARAMETER;
5781 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5783 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5785 LOGD("ret : 0x%x", ret);
5791 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5793 int ret = CAMERA_ERROR_NONE;
5794 camera_cli_s *pc = (camera_cli_s *)camera;
5795 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5797 if (!pc || !pc->cb_info || !rotation) {
5798 LOGE("NULL pointer %p %p", pc, rotation);
5799 return CAMERA_ERROR_INVALID_PARAMETER;
5804 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5806 if (ret == CAMERA_ERROR_NONE)
5807 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5809 LOGD("ret : 0x%x", ret);
5815 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5817 int ret = CAMERA_ERROR_NONE;
5818 camera_cli_s *pc = (camera_cli_s *)camera;
5819 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5820 camera_msg_param param;
5821 int set_flip = (int)flip;
5823 if (!pc || !pc->cb_info) {
5824 LOGE("NULL handle");
5825 return CAMERA_ERROR_INVALID_PARAMETER;
5830 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5832 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5834 LOGD("ret : 0x%x", ret);
5840 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5842 int ret = CAMERA_ERROR_NONE;
5843 camera_cli_s *pc = (camera_cli_s *)camera;
5844 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5846 if (!pc || !pc->cb_info || !flip) {
5847 LOGE("NULL pointer %p %p", pc, flip);
5848 return CAMERA_ERROR_INVALID_PARAMETER;
5853 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5855 if (ret == CAMERA_ERROR_NONE)
5856 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5858 LOGD("ret : 0x%x", ret);
5863 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5865 int ret = CAMERA_ERROR_NONE;
5866 camera_cli_s *pc = (camera_cli_s *)camera;
5867 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5868 camera_msg_param param;
5869 int set_mode = (int)mode;
5871 if (!pc || !pc->cb_info) {
5872 LOGE("NULL handle");
5873 return CAMERA_ERROR_INVALID_PARAMETER;
5878 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5880 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5882 LOGD("ret : 0x%x", ret);
5888 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5890 int ret = CAMERA_ERROR_NONE;
5891 camera_cli_s *pc = (camera_cli_s *)camera;
5892 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5894 if (!pc || !pc->cb_info || !mode) {
5895 LOGE("NULL pointer %p %p", pc, mode);
5896 return CAMERA_ERROR_INVALID_PARAMETER;
5901 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5903 if (ret == CAMERA_ERROR_NONE)
5904 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
5906 LOGD("ret : 0x%x", ret);
5912 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5914 int ret = CAMERA_ERROR_NONE;
5915 camera_cli_s *pc = (camera_cli_s *)camera;
5916 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
5918 if (!pc || !pc->cb_info) {
5919 LOGE("NULL handle");
5920 return CAMERA_ERROR_INVALID_PARAMETER;
5925 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5928 LOGE("error is occurred 0x%x", ret);
5932 LOGD("ret : %d", ret);
5938 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5940 int ret = CAMERA_ERROR_NONE;
5941 camera_cli_s *pc = (camera_cli_s *)camera;
5942 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5944 if (!pc || !pc->cb_info) {
5945 LOGE("NULL handle");
5946 return CAMERA_ERROR_INVALID_PARAMETER;
5951 if (!camera_attr_is_supported_hdr_capture(camera)) {
5952 LOGE("HDR not supported");
5953 return CAMERA_ERROR_NOT_SUPPORTED;
5957 LOGE("NULL callback");
5958 return CAMERA_ERROR_INVALID_PARAMETER;
5961 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5963 if (ret == CAMERA_ERROR_NONE) {
5964 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5966 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5967 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5969 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5972 LOGD("ret : 0x%x", ret);
5978 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5980 int ret = CAMERA_ERROR_NONE;
5981 camera_cli_s *pc = (camera_cli_s *)camera;
5982 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5984 if (!pc || !pc->cb_info) {
5985 LOGE("NULL handle");
5986 return CAMERA_ERROR_INVALID_PARAMETER;
5991 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5993 if (ret == CAMERA_ERROR_NONE) {
5994 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5996 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5997 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5999 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6002 LOGD("ret : 0x%x", ret);
6008 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6010 int ret = CAMERA_ERROR_NONE;
6011 camera_cli_s *pc = (camera_cli_s *)camera;
6012 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
6013 camera_msg_param param;
6014 int set_enable = (int)enable;
6016 if (!pc || !pc->cb_info) {
6017 LOGE("NULL handle");
6018 return CAMERA_ERROR_INVALID_PARAMETER;
6023 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6025 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6027 LOGD("ret : 0x%x", ret);
6033 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6035 int ret = CAMERA_ERROR_NONE;
6036 camera_cli_s *pc = (camera_cli_s *)camera;
6037 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6039 if (!pc || !pc->cb_info || !enabled) {
6040 LOGE("NULL pointer %p %p", pc, enabled);
6041 return CAMERA_ERROR_INVALID_PARAMETER;
6046 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6048 if (ret == CAMERA_ERROR_NONE)
6049 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6051 LOGD("ret : 0x%x", ret);
6057 bool camera_attr_is_supported_anti_shake(camera_h camera)
6059 int ret = CAMERA_ERROR_NONE;
6060 camera_cli_s *pc = (camera_cli_s *)camera;
6061 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6063 if (!pc || !pc->cb_info) {
6064 LOGE("NULL handle");
6065 return CAMERA_ERROR_INVALID_PARAMETER;
6070 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6073 LOGE("error is occurred 0x%x", ret);
6077 LOGD("ret : %d", ret);
6083 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6085 int ret = CAMERA_ERROR_NONE;
6086 camera_cli_s *pc = (camera_cli_s *)camera;
6087 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6088 camera_msg_param param;
6089 int set_enable = (int)enable;
6091 if (!pc || !pc->cb_info) {
6092 LOGE("NULL handle");
6093 return CAMERA_ERROR_INVALID_PARAMETER;
6098 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6100 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6102 LOGD("ret : 0x%x", ret);
6108 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6110 int ret = CAMERA_ERROR_NONE;
6111 camera_cli_s *pc = (camera_cli_s *)camera;
6112 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6114 if (!pc || !pc->cb_info || !enabled) {
6115 LOGE("NULL pointer %p %p", pc, enabled);
6116 return CAMERA_ERROR_INVALID_PARAMETER;
6121 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6123 if (ret == CAMERA_ERROR_NONE)
6124 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6126 LOGD("ret : 0x%x", ret);
6132 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6134 int ret = CAMERA_ERROR_NONE;
6135 camera_cli_s *pc = (camera_cli_s *)camera;
6136 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6138 if (!pc || !pc->cb_info) {
6139 LOGE("NULL handle");
6140 return CAMERA_ERROR_INVALID_PARAMETER;
6145 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6148 LOGE("error is occurred 0x%x", ret);
6152 LOGD("ret : %d", ret);
6158 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6160 int ret = CAMERA_ERROR_NONE;
6161 camera_cli_s *pc = (camera_cli_s *)camera;
6162 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6163 camera_msg_param param;
6164 int set_enable = (int)enable;
6166 if (!pc || !pc->cb_info) {
6167 LOGE("NULL handle");
6168 return CAMERA_ERROR_INVALID_PARAMETER;
6173 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6175 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6177 LOGD("ret : 0x%x", ret);
6183 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6185 int ret = CAMERA_ERROR_NONE;
6186 camera_cli_s *pc = (camera_cli_s *)camera;
6187 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6189 if (!pc || !pc->cb_info || !enabled) {
6190 LOGE("NULL pointer %p %p", pc, enabled);
6191 return CAMERA_ERROR_INVALID_PARAMETER;
6196 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6198 if (ret == CAMERA_ERROR_NONE)
6199 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6201 LOGD("ret : 0x%x", ret);
6207 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6209 int ret = CAMERA_ERROR_NONE;
6210 camera_cli_s *pc = (camera_cli_s *)camera;
6211 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6213 if (!pc || !pc->cb_info) {
6214 LOGE("NULL handle");
6215 return CAMERA_ERROR_INVALID_PARAMETER;
6220 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6223 LOGE("error is occurred 0x%x", ret);
6227 LOGD("ret : %d", ret);
6233 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6235 int ret = CAMERA_ERROR_NONE;
6236 camera_cli_s *pc = (camera_cli_s *)camera;
6237 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6238 camera_msg_param param;
6239 int set_disable = (int)disable;
6241 if (!pc || !pc->cb_info) {
6242 LOGE("NULL handle");
6243 return CAMERA_ERROR_INVALID_PARAMETER;
6248 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6250 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6252 LOGD("ret : 0x%x", ret);
6258 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6260 int ret = CAMERA_ERROR_NONE;
6261 camera_cli_s *pc = (camera_cli_s *)camera;
6262 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6263 camera_msg_param param;
6264 int set_move_type = (int)move_type;
6267 if (!pc || !pc->cb_info) {
6268 LOGE("NULL handle");
6269 return CAMERA_ERROR_INVALID_PARAMETER;
6274 value = (set_move_type << 16) | pan_step;
6275 CAMERA_MSG_PARAM_SET(param, INT, value);
6277 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6279 LOGD("ret : 0x%x", ret);
6285 int camera_attr_get_pan(camera_h camera, int *pan_step)
6287 int ret = CAMERA_ERROR_NONE;
6288 camera_cli_s *pc = (camera_cli_s *)camera;
6289 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6291 if (!pc || !pc->cb_info || !pan_step) {
6292 LOGE("NULL pointer %p %p", pc, pan_step);
6293 return CAMERA_ERROR_INVALID_PARAMETER;
6298 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6300 if (ret == CAMERA_ERROR_NONE)
6301 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6303 LOGD("ret : 0x%x", ret);
6309 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6311 int ret = CAMERA_ERROR_NONE;
6312 camera_cli_s *pc = (camera_cli_s *)camera;
6313 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6315 if (!pc || !pc->cb_info || !min || !max) {
6316 LOGE("NULL pointer %p %p %p", pc, min, max);
6317 return CAMERA_ERROR_INVALID_PARAMETER;
6322 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6324 if (ret == CAMERA_ERROR_NONE) {
6325 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6326 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6329 LOGD("ret : 0x%x", ret);
6335 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6337 int ret = CAMERA_ERROR_NONE;
6338 camera_cli_s *pc = (camera_cli_s *)camera;
6339 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6340 camera_msg_param param;
6341 int set_move_type = (int)move_type;
6344 if (!pc || !pc->cb_info) {
6345 LOGE("NULL handle");
6346 return CAMERA_ERROR_INVALID_PARAMETER;
6351 value = (set_move_type << 16) | tilt_step;
6352 CAMERA_MSG_PARAM_SET(param, INT, value);
6354 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6356 LOGD("ret : 0x%x", ret);
6362 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6364 int ret = CAMERA_ERROR_NONE;
6365 camera_cli_s *pc = (camera_cli_s *)camera;
6366 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6368 if (!pc || !pc->cb_info || !tilt_step) {
6369 LOGE("NULL pointer %p %p", pc, tilt_step);
6370 return CAMERA_ERROR_INVALID_PARAMETER;
6375 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6377 if (ret == CAMERA_ERROR_NONE)
6378 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6380 LOGD("ret : 0x%x", ret);
6386 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6388 int ret = CAMERA_ERROR_NONE;
6389 camera_cli_s *pc = (camera_cli_s *)camera;
6390 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6392 if (!pc || !pc->cb_info || !min || !max) {
6393 LOGE("NULL pointer %p %p %p", pc, min, max);
6394 return CAMERA_ERROR_INVALID_PARAMETER;
6399 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6401 if (ret == CAMERA_ERROR_NONE) {
6402 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6403 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6406 LOGD("ret : 0x%x", ret);
6412 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6414 int ret = CAMERA_ERROR_NONE;
6415 camera_cli_s *pc = (camera_cli_s *)camera;
6416 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6417 camera_msg_param param;
6418 int set_ptz_type = (int)ptz_type;
6420 if (!pc || !pc->cb_info) {
6421 LOGE("NULL handle");
6422 return CAMERA_ERROR_INVALID_PARAMETER;
6427 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6429 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6431 LOGD("ret : 0x%x", ret);
6437 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6439 int ret = CAMERA_ERROR_NONE;
6440 camera_cli_s *pc = (camera_cli_s *)camera;
6441 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6443 if (!pc || !pc->cb_info || !foreach_cb) {
6444 LOGE("NULL pointer %p %p", pc, foreach_cb);
6445 return CAMERA_ERROR_INVALID_PARAMETER;
6450 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6451 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6453 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6455 LOGD("ret : 0x%x", ret);
6461 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6463 int ret = CAMERA_ERROR_NONE;
6464 camera_cli_s *pc = (camera_cli_s *)camera;
6465 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6466 int set_display_roi_area[4] = {x, y, width, height};
6471 if (!pc || !pc->cb_info) {
6472 LOGE("NULL handle");
6473 return CAMERA_ERROR_INVALID_PARAMETER;
6478 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6479 ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
6480 if (ret != MM_ERROR_NONE) {
6481 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6482 return CAMERA_ERROR_INVALID_OPERATION;
6486 length = sizeof(set_display_roi_area) / sizeof(int) + \
6487 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6489 msg = muse_core_msg_new(api,
6490 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6493 LOGE("msg creation failed: api %d", api);
6494 return CAMERA_ERROR_OUT_OF_MEMORY;
6497 if (pc->cb_info->is_server_connected) {
6498 __camera_update_api_waiting(pc->cb_info, api, 1);
6500 g_mutex_lock(&pc->cb_info->fd_lock);
6501 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
6502 g_mutex_unlock(&pc->cb_info->fd_lock);
6506 LOGE("message send failed");
6507 ret = CAMERA_ERROR_INVALID_OPERATION;
6509 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6512 __camera_update_api_waiting(pc->cb_info, api, -1);
6514 muse_core_msg_free(msg);
6516 LOGD("ret : 0x%x", ret);
6522 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6524 camera_cli_s *pc = (camera_cli_s *)camera;
6525 int ret = CAMERA_ERROR_NONE;
6526 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6528 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6529 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6530 return CAMERA_ERROR_INVALID_PARAMETER;
6535 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6537 if (ret == CAMERA_ERROR_NONE) {
6538 *x = pc->cb_info->get_display_roi_area[0];
6539 *y = pc->cb_info->get_display_roi_area[1];
6540 *width = pc->cb_info->get_display_roi_area[2];
6541 *height = pc->cb_info->get_display_roi_area[3];
6544 LOGD("ret : 0x%x", ret);
6550 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6552 int ret = CAMERA_ERROR_NONE;
6553 int get_device_state = 0;
6556 LOGE("NULL pointer");
6557 return CAMERA_ERROR_INVALID_PARAMETER;
6560 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6561 (int)device, "get_device_state", &get_device_state);
6563 if (ret == CAMERA_ERROR_NONE) {
6564 *state = (camera_device_state_e)get_device_state;
6565 LOGD("device state %d", *state);
6567 LOGE("failed 0x%x", ret);
6574 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6576 int ret = CAMERA_ERROR_NONE;
6577 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6578 camera_cb_info *info = NULL;
6580 if (!callback || !cb_id) {
6581 LOGE("invalid pointer %p %p", callback, cb_id);
6582 return CAMERA_ERROR_INVALID_PARAMETER;
6585 /* check camera support */
6586 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6587 if (ret != CAMERA_ERROR_NONE) {
6588 LOGE("get device state failed");
6592 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6594 info = g_new0(camera_cb_info, 1);
6596 LOGE("info failed");
6597 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6601 info->id = ++g_cam_dev_state_changed_cb_id;
6602 info->callback = (void *)callback;
6603 info->user_data = user_data;
6607 /* subscribe dbus signal for camera state change */
6608 if (!g_cam_dev_state_changed_cb_conn) {
6609 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6610 if (!g_cam_dev_state_changed_cb_conn) {
6611 LOGE("failed to get gdbus connection");
6612 ret = CAMERA_ERROR_INVALID_OPERATION;
6616 LOGD("subscribe signal %s - %s - %s",
6617 MM_CAMCORDER_DBUS_OBJECT,
6618 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6619 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6621 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6622 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6623 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6624 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6625 LOGE("failed to get gdbus connection");
6626 ret = CAMERA_ERROR_INVALID_OPERATION;
6630 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6633 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6635 LOGD("callback id %d", info->id);
6638 if (ret != CAMERA_ERROR_NONE) {
6644 if (g_cam_dev_state_changed_cb_conn) {
6645 g_object_unref(g_cam_dev_state_changed_cb_conn);
6646 g_cam_dev_state_changed_cb_conn = NULL;
6650 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6656 int camera_remove_device_state_changed_cb(int cb_id)
6658 int ret = CAMERA_ERROR_NONE;
6659 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6660 GList *tmp_list = NULL;
6661 camera_cb_info *info = NULL;
6663 /* check camera support */
6664 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6665 if (ret != CAMERA_ERROR_NONE) {
6666 LOGE("get device state failed");
6670 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6672 if (!g_cam_dev_state_changed_cb_list) {
6673 LOGE("there is no callback info");
6674 ret = CAMERA_ERROR_INVALID_OPERATION;
6678 tmp_list = g_cam_dev_state_changed_cb_list;
6681 info = tmp_list->data;
6682 tmp_list = tmp_list->next;
6689 if (info->id == cb_id) {
6690 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6695 if (!g_cam_dev_state_changed_cb_list) {
6696 /* no remained callback */
6697 if (g_cam_dev_state_changed_cb_conn) {
6698 /* unsubscribe signal */
6699 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6700 g_cam_dev_state_changed_cb_subscribe_id = 0;
6702 /* unref connection */
6703 g_object_unref(g_cam_dev_state_changed_cb_conn);
6704 g_cam_dev_state_changed_cb_conn = NULL;
6708 LOGD("id %d callback removed", cb_id);
6709 ret = CAMERA_ERROR_NONE;
6715 LOGE("id %d callback not found", cb_id);
6716 ret = CAMERA_ERROR_INVALID_PARAMETER;
6719 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);