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 CAMERA_MSG_PARAM_SET(param0, INT, type);
3072 CAMERA_MSG_PARAM_SET(param1, INT, parent_id);
3074 _camera_msg_send_param2_int(api, cb_info, &ret,
3075 ¶m0, ¶m1, CAMERA_CB_TIMEOUT);
3077 if (ret == CAMERA_ERROR_NONE) {
3078 pc->cb_info->dp_type = type;
3080 if (type == CAMERA_DISPLAY_TYPE_EVAS)
3081 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3088 int camera_set_preview_resolution(camera_h camera, int width, int height)
3090 int ret = CAMERA_ERROR_NONE;
3091 camera_state_e current_state = CAMERA_STATE_NONE;
3092 camera_cli_s *pc = (camera_cli_s *)camera;
3093 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3094 camera_msg_param param;
3097 if (!pc || !pc->cb_info) {
3098 LOGE("NULL handle");
3099 return CAMERA_ERROR_INVALID_PARAMETER;
3102 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3103 ret = camera_get_state(camera, ¤t_state);
3104 if (ret != CAMERA_ERROR_NONE) {
3105 LOGE("failed to get current state 0x%x", ret);
3109 if (current_state == CAMERA_STATE_PREVIEW) {
3110 ret = _camera_stop_evas_rendering(camera, true);
3111 if (ret != CAMERA_ERROR_NONE)
3116 value = (width << 16) | height;
3117 CAMERA_MSG_PARAM_SET(param, INT, value);
3119 LOGD("%dx%d -> 0x%x", width, height, value);
3121 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3123 LOGD("ret : 0x%x", ret);
3125 if (current_state == CAMERA_STATE_PREVIEW) {
3126 LOGW("restart evas rendering");
3127 _camera_start_evas_rendering(camera);
3134 int camera_set_capture_resolution(camera_h camera, int width, int height)
3136 int ret = CAMERA_ERROR_NONE;
3137 camera_cli_s *pc = (camera_cli_s *)camera;
3138 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3139 camera_msg_param param;
3142 if (!pc || !pc->cb_info) {
3143 LOGE("NULL handle");
3144 return CAMERA_ERROR_INVALID_PARAMETER;
3149 value = (width << 16) | height;
3150 CAMERA_MSG_PARAM_SET(param, INT, value);
3152 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3154 LOGD("ret : 0x%x", ret);
3160 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3162 int ret = CAMERA_ERROR_NONE;
3163 int set_format = (int)format;
3164 camera_cli_s *pc = (camera_cli_s *)camera;
3165 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3166 camera_msg_param param;
3168 if (!pc || !pc->cb_info) {
3169 LOGE("NULL handle");
3170 return CAMERA_ERROR_INVALID_PARAMETER;
3173 LOGD("Enter - format %d", set_format);
3175 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3177 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3179 LOGD("ret : 0x%x", ret);
3185 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3187 int ret = CAMERA_ERROR_NONE;
3188 int set_format = (int)format;
3189 camera_msg_param param;
3190 camera_cli_s *pc = (camera_cli_s *)camera;
3191 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3193 if (!pc || !pc->cb_info) {
3194 LOGE("NULL handle");
3195 return CAMERA_ERROR_INVALID_PARAMETER;
3198 LOGD("Enter - capture_format %d", set_format);
3200 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3202 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3204 if (ret == CAMERA_ERROR_NONE)
3205 pc->cb_info->preview_format = set_format;
3207 LOGD("ret : 0x%x", ret);
3213 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3215 int ret = CAMERA_ERROR_NONE;
3216 camera_cli_s *pc = (camera_cli_s *)camera;
3217 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3219 if (!pc || !pc->cb_info || !width || !height) {
3220 LOGE("NULL pointer %p %p %p", pc, width, height);
3221 return CAMERA_ERROR_INVALID_PARAMETER;
3226 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3228 if (ret == CAMERA_ERROR_NONE) {
3229 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3230 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3233 LOGD("ret : 0x%x", ret);
3239 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3241 int ret = CAMERA_ERROR_NONE;
3242 int set_rotation = (int)rotation;
3243 camera_cli_s *pc = (camera_cli_s *)camera;
3244 camera_msg_param param;
3246 if (!pc || !pc->cb_info) {
3247 LOGE("NULL handle");
3248 return CAMERA_ERROR_INVALID_PARAMETER;
3251 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3252 ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
3253 if (ret != MM_ERROR_NONE) {
3254 LOGE("failed to set rotation for evas surface 0x%x", ret);
3255 return CAMERA_ERROR_INVALID_OPERATION;
3259 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3261 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3267 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3269 int ret = CAMERA_ERROR_NONE;
3270 camera_cli_s *pc = (camera_cli_s *)camera;
3272 if (!pc || !pc->cb_info || !rotation) {
3273 LOGE("NULL pointer %p %p", pc, rotation);
3274 return CAMERA_ERROR_INVALID_PARAMETER;
3277 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3279 if (ret == CAMERA_ERROR_NONE)
3280 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3286 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3288 int ret = CAMERA_ERROR_NONE;
3289 int set_flip = (int)flip;
3290 camera_cli_s *pc = (camera_cli_s *)camera;
3291 camera_msg_param param;
3293 if (!pc || !pc->cb_info) {
3294 LOGE("NULL handle");
3295 return CAMERA_ERROR_INVALID_PARAMETER;
3298 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3299 ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
3300 if (ret != MM_ERROR_NONE) {
3301 LOGE("failed to set flip for evas surface 0x%x", ret);
3302 return CAMERA_ERROR_INVALID_OPERATION;
3306 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3308 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3314 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3316 int ret = CAMERA_ERROR_NONE;
3317 camera_cli_s *pc = (camera_cli_s *)camera;
3319 if (!pc || !pc->cb_info || !flip) {
3320 LOGE("NULL pointer %p %p", pc, flip);
3321 return CAMERA_ERROR_INVALID_PARAMETER;
3324 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3326 if (ret == CAMERA_ERROR_NONE)
3327 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3333 int camera_set_display_visible(camera_h camera, bool visible)
3335 int ret = CAMERA_ERROR_NONE;
3336 int set_visible = (int)visible;
3337 camera_cli_s *pc = (camera_cli_s *)camera;
3338 camera_msg_param param;
3340 if (!pc || !pc->cb_info) {
3341 LOGE("NULL handle");
3342 return CAMERA_ERROR_INVALID_PARAMETER;
3345 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3346 ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
3347 if (ret != MM_ERROR_NONE) {
3348 LOGE("failed to set visible for evas surface 0x%x", ret);
3349 return CAMERA_ERROR_INVALID_OPERATION;
3353 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3355 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3361 int camera_is_display_visible(camera_h camera, bool *visible)
3363 int ret = CAMERA_ERROR_NONE;
3364 camera_cli_s *pc = (camera_cli_s *)camera;
3366 if (!pc || !pc->cb_info || !visible) {
3367 LOGE("NULL pointer %p %p", pc, visible);
3368 return CAMERA_ERROR_INVALID_PARAMETER;
3371 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3373 if (ret == CAMERA_ERROR_NONE)
3374 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3380 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3382 int ret = CAMERA_ERROR_NONE;
3383 int set_mode = (int)mode;
3384 camera_cli_s *pc = (camera_cli_s *)camera;
3385 camera_msg_param param;
3387 if (!pc || !pc->cb_info) {
3388 LOGE("NULL handle");
3389 return CAMERA_ERROR_INVALID_PARAMETER;
3392 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3393 ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
3394 if (ret != MM_ERROR_NONE) {
3395 LOGE("failed to set geometry for evas surface 0x%x", ret);
3396 return CAMERA_ERROR_INVALID_OPERATION;
3400 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3402 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3408 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3410 int ret = CAMERA_ERROR_NONE;
3411 camera_cli_s *pc = (camera_cli_s *)camera;
3413 if (!pc || !pc->cb_info || !mode) {
3414 LOGE("NULL pointer %p %p", pc, mode);
3415 return CAMERA_ERROR_INVALID_PARAMETER;
3418 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3420 if (ret == CAMERA_ERROR_NONE)
3421 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3427 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3429 int ret = CAMERA_ERROR_NONE;
3430 int set_hint = (int)hint;
3431 camera_cli_s *pc = (camera_cli_s *)camera;
3432 camera_msg_param param;
3434 if (!pc || !pc->cb_info) {
3435 LOGE("NULL handle");
3436 return CAMERA_ERROR_INVALID_PARAMETER;
3439 LOGD("Enter - hint %d", set_hint);
3441 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3443 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3449 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3451 int ret = CAMERA_ERROR_NONE;
3452 camera_cli_s *pc = (camera_cli_s *)camera;
3453 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3455 if (!pc || !pc->cb_info || !hint) {
3456 LOGE("NULL pointer %p %p", pc, hint);
3457 return CAMERA_ERROR_INVALID_PARAMETER;
3460 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3462 if (ret == CAMERA_ERROR_NONE) {
3463 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3464 LOGD("display reuse hint %d", *hint);
3471 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3473 int ret = CAMERA_ERROR_NONE;
3474 camera_cli_s *pc = (camera_cli_s *)camera;
3475 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3477 if (!pc || !pc->cb_info || !width || !height) {
3478 LOGE("NULL pointer %p %p %p", pc, width, height);
3479 return CAMERA_ERROR_INVALID_PARAMETER;
3484 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3486 if (ret == CAMERA_ERROR_NONE) {
3487 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3488 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3491 LOGD("ret : 0x%x", ret);
3497 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3499 int ret = CAMERA_ERROR_NONE;
3500 camera_cli_s *pc = (camera_cli_s *)camera;
3501 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3503 if (!pc || !pc->cb_info || !format) {
3504 LOGE("NULL pointer %p %p", pc, format);
3505 return CAMERA_ERROR_INVALID_PARAMETER;
3510 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3512 if (ret == CAMERA_ERROR_NONE)
3513 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3515 LOGD("ret : 0x%x", ret);
3521 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3523 int ret = CAMERA_ERROR_NONE;
3524 camera_cli_s *pc = (camera_cli_s *)camera;
3525 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3527 if (!pc || !pc->cb_info || !format) {
3528 LOGE("NULL pointer %p %p", pc, format);
3529 return CAMERA_ERROR_INVALID_PARAMETER;
3534 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3536 if (ret == CAMERA_ERROR_NONE)
3537 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3539 LOGD("ret : 0x%x", ret);
3545 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3547 int ret = CAMERA_ERROR_NONE;
3548 camera_cli_s *pc = (camera_cli_s *)camera;
3549 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3551 if (!pc || !pc->cb_info || !facing_direction) {
3552 LOGE("NULL pointer %p %p", pc, facing_direction);
3553 return CAMERA_ERROR_INVALID_PARAMETER;
3558 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3560 if (ret == CAMERA_ERROR_NONE)
3561 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3563 LOGD("ret : 0x%x", ret);
3569 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3571 int ret = CAMERA_ERROR_NONE;
3572 camera_cli_s *pc = (camera_cli_s *)camera;
3573 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3575 if (!pc || !pc->cb_info || !callback) {
3576 LOGE("NULL pointer %p %p", pc, callback);
3577 return CAMERA_ERROR_INVALID_PARAMETER;
3582 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3584 if (ret == CAMERA_ERROR_NONE) {
3585 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3587 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3588 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3590 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3592 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3595 LOGD("ret : 0x%x", ret);
3601 int camera_unset_preview_cb(camera_h camera)
3603 int ret = CAMERA_ERROR_NONE;
3604 camera_cli_s *pc = (camera_cli_s *)camera;
3605 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3607 if (!pc || !pc->cb_info) {
3608 LOGE("NULL handle");
3609 return CAMERA_ERROR_INVALID_PARAMETER;
3614 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3616 if (ret == CAMERA_ERROR_NONE) {
3617 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3619 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3620 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3622 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3624 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3627 LOGD("ret : 0x%x", ret);
3633 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3635 int ret = CAMERA_ERROR_NONE;
3636 camera_cli_s *pc = (camera_cli_s *)camera;
3637 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3639 if (!pc || !pc->cb_info) {
3640 LOGE("NULL handle");
3641 return CAMERA_ERROR_INVALID_PARAMETER;
3644 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3645 LOGE("NOT SUPPORTED");
3646 return CAMERA_ERROR_NOT_SUPPORTED;
3649 if (callback == NULL) {
3650 LOGE("NULL callback");
3651 return CAMERA_ERROR_INVALID_PARAMETER;
3656 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3658 if (ret == CAMERA_ERROR_NONE) {
3659 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3661 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3662 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3664 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3667 LOGD("ret : 0x%x", ret);
3673 int camera_unset_media_packet_preview_cb(camera_h camera)
3675 int ret = CAMERA_ERROR_NONE;
3676 camera_cli_s *pc = (camera_cli_s *)camera;
3677 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3679 if (!pc || !pc->cb_info) {
3680 LOGE("NULL handle");
3681 return CAMERA_ERROR_INVALID_PARAMETER;
3686 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3688 if (ret == CAMERA_ERROR_NONE) {
3689 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3691 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3692 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3694 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3697 LOGD("ret : 0x%x", ret);
3703 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3705 int ret = CAMERA_ERROR_NONE;
3706 camera_cli_s *pc = (camera_cli_s *)camera;
3707 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3709 if (!pc || !pc->cb_info || !callback) {
3710 LOGE("NULL pointer %p %p", pc, callback);
3711 return CAMERA_ERROR_INVALID_PARAMETER;
3716 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3718 if (ret == CAMERA_ERROR_NONE) {
3719 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3721 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3722 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3724 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3727 LOGD("ret : 0x%x", ret);
3733 int camera_unset_state_changed_cb(camera_h camera)
3735 int ret = CAMERA_ERROR_NONE;
3736 camera_cli_s *pc = (camera_cli_s *)camera;
3737 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3739 if (!pc || !pc->cb_info) {
3740 LOGE("NULL handle");
3741 return CAMERA_ERROR_INVALID_PARAMETER;
3746 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3748 if (ret == CAMERA_ERROR_NONE) {
3749 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3751 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3752 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3754 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3757 LOGD("ret : 0x%x", ret);
3763 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3765 int ret = CAMERA_ERROR_NONE;
3766 camera_cli_s *pc = (camera_cli_s *)camera;
3767 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3769 if (!pc || !pc->cb_info || !callback) {
3770 LOGE("NULL pointer %p %p", pc, callback);
3771 return CAMERA_ERROR_INVALID_PARAMETER;
3776 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3778 if (ret == CAMERA_ERROR_NONE) {
3779 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3781 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3782 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3784 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3787 LOGD("ret : 0x%x", ret);
3793 int camera_unset_interrupted_cb(camera_h camera)
3795 int ret = CAMERA_ERROR_NONE;
3796 camera_cli_s *pc = (camera_cli_s *)camera;
3797 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3799 if (!pc || !pc->cb_info) {
3800 LOGE("NULL handle");
3801 return CAMERA_ERROR_INVALID_PARAMETER;
3806 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3808 if (ret == CAMERA_ERROR_NONE) {
3809 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3811 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3812 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3814 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3817 LOGD("ret : 0x%x", ret);
3823 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
3825 int ret = CAMERA_ERROR_NONE;
3826 camera_cli_s *pc = (camera_cli_s *)camera;
3827 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
3829 if (!pc || !pc->cb_info || !callback) {
3830 LOGE("NULL pointer %p %p", pc, callback);
3831 return CAMERA_ERROR_INVALID_PARAMETER;
3836 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3838 if (ret == CAMERA_ERROR_NONE) {
3839 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3841 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
3842 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
3844 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3847 LOGD("ret : 0x%x", ret);
3853 int camera_unset_interrupt_started_cb(camera_h camera)
3855 int ret = CAMERA_ERROR_NONE;
3856 camera_cli_s *pc = (camera_cli_s *)camera;
3857 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
3859 if (!pc || !pc->cb_info) {
3860 LOGE("NULL handle");
3861 return CAMERA_ERROR_INVALID_PARAMETER;
3866 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3868 if (ret == CAMERA_ERROR_NONE) {
3869 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3871 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3872 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3874 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3877 LOGD("ret : 0x%x", ret);
3883 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
3885 int ret = CAMERA_ERROR_NONE;
3886 camera_cli_s *pc = (camera_cli_s *)camera;
3887 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3889 if (!pc || !pc->cb_info || !callback) {
3890 LOGE("NULL pointer %p %p", pc, callback);
3891 return CAMERA_ERROR_INVALID_PARAMETER;
3896 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3898 if (ret == CAMERA_ERROR_NONE) {
3899 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3901 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3902 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3904 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3907 LOGD("ret : 0x%x", ret);
3913 int camera_unset_focus_changed_cb(camera_h camera)
3915 int ret = CAMERA_ERROR_NONE;
3916 camera_cli_s *pc = (camera_cli_s *)camera;
3917 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
3919 if (!pc || !pc->cb_info) {
3920 LOGE("NULL handle");
3921 return CAMERA_ERROR_INVALID_PARAMETER;
3926 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3928 if (ret == CAMERA_ERROR_NONE) {
3929 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3931 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3932 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3934 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3937 LOGD("ret : 0x%x", ret);
3943 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
3945 int ret = CAMERA_ERROR_NONE;
3946 camera_cli_s *pc = (camera_cli_s *)camera;
3947 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
3949 if (!pc || !pc->cb_info || !callback) {
3950 LOGE("NULL pointer %p %p", pc, callback);
3951 return CAMERA_ERROR_INVALID_PARAMETER;
3956 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3958 if (ret == CAMERA_ERROR_NONE) {
3959 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3961 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
3962 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
3964 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3967 LOGD("ret : 0x%x", ret);
3973 int camera_unset_error_cb(camera_h camera)
3975 int ret = CAMERA_ERROR_NONE;
3976 camera_cli_s *pc = (camera_cli_s *)camera;
3977 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
3979 if (!pc || !pc->cb_info) {
3980 LOGE("NULL handle");
3981 return CAMERA_ERROR_INVALID_PARAMETER;
3986 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3988 if (ret == CAMERA_ERROR_NONE) {
3989 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3991 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
3992 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
3994 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3997 LOGD("ret : 0x%x", ret);
4003 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
4005 int ret = CAMERA_ERROR_NONE;
4006 camera_cli_s *pc = (camera_cli_s *)camera;
4007 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
4009 if (!pc || !pc->cb_info || !foreach_cb) {
4010 LOGE("NULL pointer %p %p", pc, foreach_cb);
4011 return CAMERA_ERROR_INVALID_PARAMETER;
4016 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
4017 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4019 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4021 LOGD("ret : 0x%x", ret);
4027 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4029 int ret = CAMERA_ERROR_NONE;
4030 camera_cli_s *pc = (camera_cli_s *)camera;
4031 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4033 if (!pc || !pc->cb_info || !foreach_cb) {
4034 LOGE("NULL pointer %p %p", pc, foreach_cb);
4035 return CAMERA_ERROR_INVALID_PARAMETER;
4040 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4041 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4043 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4045 LOGD("ret : 0x%x", ret);
4051 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4053 int ret = CAMERA_ERROR_NONE;
4054 camera_cli_s *pc = (camera_cli_s *)camera;
4055 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4057 if (!pc || !pc->cb_info || !foreach_cb) {
4058 LOGE("NULL pointer %p %p", pc, foreach_cb);
4059 return CAMERA_ERROR_INVALID_PARAMETER;
4064 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4065 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4067 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4069 LOGD("ret : 0x%x", ret);
4075 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4077 int ret = CAMERA_ERROR_NONE;
4078 camera_cli_s *pc = (camera_cli_s *)camera;
4079 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4081 if (!pc || !pc->cb_info || !foreach_cb) {
4082 LOGE("NULL pointer %p %p", pc, foreach_cb);
4083 return CAMERA_ERROR_INVALID_PARAMETER;
4088 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4089 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4091 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4093 LOGD("ret : 0x%x", ret);
4099 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4101 int ret = CAMERA_ERROR_NONE;
4102 camera_cli_s *pc = (camera_cli_s *)camera;
4103 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4105 if (!pc || !pc->cb_info || !width || !height) {
4106 LOGE("NULL pointer %p %p %p", pc, width, height);
4107 return CAMERA_ERROR_INVALID_PARAMETER;
4111 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4113 if (ret == CAMERA_ERROR_NONE) {
4114 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4115 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4118 LOGD("ret : 0x%x", ret);
4124 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4126 int ret = CAMERA_ERROR_NONE;
4127 camera_cli_s *pc = (camera_cli_s *)camera;
4128 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4130 if (!pc || !pc->cb_info || !angle) {
4131 LOGE("NULL pointer %p %p", pc, angle);
4132 return CAMERA_ERROR_INVALID_PARAMETER;
4137 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4139 if (ret == CAMERA_ERROR_NONE)
4140 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4142 LOGD("ret : 0x%x", ret);
4148 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4150 int ret = CAMERA_ERROR_NONE;
4151 camera_cli_s *pc = (camera_cli_s *)camera;
4152 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4153 camera_msg_param param;
4154 int set_mode = (int)mode;
4156 if (!pc || !pc->cb_info) {
4157 LOGE("NULL handle");
4158 return CAMERA_ERROR_INVALID_PARAMETER;
4163 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4165 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4167 LOGD("ret : 0x%x", ret);
4173 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4175 int ret = CAMERA_ERROR_NONE;
4176 camera_cli_s *pc = (camera_cli_s *)camera;
4177 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4179 if (!pc || !pc->cb_info || !mode) {
4180 LOGE("NULL pointer %p %p", pc, mode);
4181 return CAMERA_ERROR_INVALID_PARAMETER;
4186 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4188 if (ret == CAMERA_ERROR_NONE)
4189 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4191 LOGD("ret : 0x%x", ret);
4197 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4199 int ret = CAMERA_ERROR_NONE;
4200 camera_cli_s *pc = (camera_cli_s *)camera;
4201 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4203 if (!pc || !pc->cb_info || !foreach_cb) {
4204 LOGE("NULL pointer %p %p", pc, foreach_cb);
4205 return CAMERA_ERROR_INVALID_PARAMETER;
4210 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4211 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4213 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4215 LOGD("Finish, return :%x", ret);
4221 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4223 int ret = CAMERA_ERROR_NONE;
4224 camera_cli_s *pc = (camera_cli_s *)camera;
4225 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4226 camera_msg_param param;
4227 int set_fps = (int)fps;
4229 if (!pc || !pc->cb_info) {
4230 LOGE("NULL handle");
4231 return CAMERA_ERROR_INVALID_PARAMETER;
4236 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4238 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4240 LOGD("ret : 0x%x", ret);
4246 int camera_attr_set_image_quality(camera_h camera, int quality)
4248 int ret = CAMERA_ERROR_NONE;
4249 camera_cli_s *pc = (camera_cli_s *)camera;
4250 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4251 camera_msg_param param;
4253 if (!pc || !pc->cb_info) {
4254 LOGE("NULL handle");
4255 return CAMERA_ERROR_INVALID_PARAMETER;
4260 CAMERA_MSG_PARAM_SET(param, INT, quality);
4262 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4264 LOGD("ret : 0x%x", ret);
4270 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4272 int ret = CAMERA_ERROR_NONE;
4273 camera_cli_s *pc = (camera_cli_s *)camera;
4274 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4276 if (!pc || !pc->cb_info || !fps) {
4277 LOGE("NULL pointer %p %p", pc, fps);
4278 return CAMERA_ERROR_INVALID_PARAMETER;
4283 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4285 if (ret == CAMERA_ERROR_NONE)
4286 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4288 LOGD("ret : 0x%x", ret);
4294 int camera_attr_get_image_quality(camera_h camera, int *quality)
4296 int ret = CAMERA_ERROR_NONE;
4297 camera_cli_s *pc = (camera_cli_s *)camera;
4298 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4300 if (!pc || !pc->cb_info || !quality) {
4301 LOGE("NULL pointer %p %p", pc, quality);
4302 return CAMERA_ERROR_INVALID_PARAMETER;
4307 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4309 if (ret == CAMERA_ERROR_NONE)
4310 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4312 LOGD("ret : 0x%x", ret);
4318 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4320 int ret = CAMERA_ERROR_NONE;
4321 camera_cli_s *pc = (camera_cli_s *)camera;
4322 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4324 if (!pc || !pc->cb_info || !bitrate) {
4325 LOGE("NULL pointer %p %p", pc, bitrate);
4326 return CAMERA_ERROR_INVALID_PARAMETER;
4331 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4333 if (ret == CAMERA_ERROR_NONE)
4334 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4336 LOGD("ret : 0x%x", ret);
4342 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4344 int ret = CAMERA_ERROR_NONE;
4345 camera_cli_s *pc = (camera_cli_s *)camera;
4346 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4347 camera_msg_param param;
4348 int set_bitrate = bitrate;
4350 if (!pc || !pc->cb_info) {
4351 LOGE("NULL handle");
4352 return CAMERA_ERROR_INVALID_PARAMETER;
4357 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4359 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4361 LOGD("ret : 0x%x", ret);
4367 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4369 int ret = CAMERA_ERROR_NONE;
4370 camera_cli_s *pc = (camera_cli_s *)camera;
4371 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4373 if (!pc || !pc->cb_info || !interval) {
4374 LOGE("NULL pointer %p %p", pc, interval);
4375 return CAMERA_ERROR_INVALID_PARAMETER;
4380 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4382 if (ret == CAMERA_ERROR_NONE)
4383 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4385 LOGD("ret : 0x%x", ret);
4391 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4393 int ret = CAMERA_ERROR_NONE;
4394 camera_cli_s *pc = (camera_cli_s *)camera;
4395 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4396 camera_msg_param param;
4397 int set_gop_interval = interval;
4399 if (!pc || !pc->cb_info) {
4400 LOGE("NULL handle");
4401 return CAMERA_ERROR_INVALID_PARAMETER;
4406 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4408 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4410 LOGD("ret : 0x%x", ret);
4416 int camera_attr_set_zoom(camera_h camera, int zoom)
4418 int ret = CAMERA_ERROR_NONE;
4419 camera_cli_s *pc = (camera_cli_s *)camera;
4420 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4421 camera_msg_param param;
4423 if (!pc || !pc->cb_info) {
4424 LOGE("NULL handle");
4425 return CAMERA_ERROR_INVALID_PARAMETER;
4428 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4430 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4432 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4434 LOGD("ret : 0x%x", ret);
4440 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4442 int ret = CAMERA_ERROR_NONE;
4443 camera_cli_s *pc = (camera_cli_s *)camera;
4444 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4445 camera_msg_param param;
4446 int set_mode = (int)mode;
4448 if (!pc || !pc->cb_info) {
4449 LOGE("NULL handle");
4450 return CAMERA_ERROR_INVALID_PARAMETER;
4453 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4455 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4457 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4463 int camera_attr_set_af_area(camera_h camera, int x, int y)
4465 int ret = CAMERA_ERROR_NONE;
4466 camera_cli_s *pc = (camera_cli_s *)camera;
4467 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4468 camera_msg_param param;
4471 if (!pc || !pc->cb_info) {
4472 LOGE("NULL handle");
4473 return CAMERA_ERROR_INVALID_PARAMETER;
4476 LOGD("Enter - %d,%d", x, y);
4478 value = (x << 16) | y;
4479 CAMERA_MSG_PARAM_SET(param, INT, value);
4481 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4483 LOGD("ret : 0x%x", ret);
4489 int camera_attr_clear_af_area(camera_h camera)
4491 int ret = CAMERA_ERROR_NONE;
4492 camera_cli_s *pc = (camera_cli_s *)camera;
4493 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4495 if (!pc || !pc->cb_info) {
4496 LOGE("NULL handle");
4497 return CAMERA_ERROR_INVALID_PARAMETER;
4502 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4504 LOGD("ret : 0x%x", ret);
4510 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4512 int ret = CAMERA_ERROR_NONE;
4513 camera_cli_s *pc = (camera_cli_s *)camera;
4514 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4515 camera_msg_param param;
4516 int set_mode = (int)mode;
4518 if (!pc || !pc->cb_info) {
4519 LOGE("NULL handle");
4520 return CAMERA_ERROR_INVALID_PARAMETER;
4525 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4527 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4529 LOGD("ret : 0x%x", ret);
4535 int camera_attr_set_exposure(camera_h camera, int value)
4537 int ret = CAMERA_ERROR_NONE;
4538 camera_cli_s *pc = (camera_cli_s *)camera;
4539 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4540 camera_msg_param param;
4542 if (!pc || !pc->cb_info) {
4543 LOGE("NULL handle");
4544 return CAMERA_ERROR_INVALID_PARAMETER;
4549 CAMERA_MSG_PARAM_SET(param, INT, value);
4551 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4553 LOGD("ret : 0x%x", ret);
4559 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4561 int ret = CAMERA_ERROR_NONE;
4562 camera_cli_s *pc = (camera_cli_s *)camera;
4563 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4564 camera_msg_param param;
4565 int set_iso = (int)iso;
4567 if (!pc || !pc->cb_info) {
4568 LOGE("NULL handle");
4569 return CAMERA_ERROR_INVALID_PARAMETER;
4574 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4576 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4578 LOGD("ret : 0x%x", ret);
4584 int camera_attr_set_brightness(camera_h camera, int level)
4586 int ret = CAMERA_ERROR_NONE;
4587 camera_cli_s *pc = (camera_cli_s *)camera;
4588 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4589 camera_msg_param param;
4591 if (!pc || !pc->cb_info) {
4592 LOGE("NULL handle");
4593 return CAMERA_ERROR_INVALID_PARAMETER;
4598 CAMERA_MSG_PARAM_SET(param, INT, level);
4600 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4602 LOGD("ret : 0x%x", ret);
4608 int camera_attr_set_contrast(camera_h camera, int level)
4610 int ret = CAMERA_ERROR_NONE;
4611 camera_cli_s *pc = (camera_cli_s *)camera;
4612 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4613 camera_msg_param param;
4615 if (!pc || !pc->cb_info) {
4616 LOGE("NULL handle");
4617 return CAMERA_ERROR_INVALID_PARAMETER;
4622 CAMERA_MSG_PARAM_SET(param, INT, level);
4624 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4626 LOGD("ret : 0x%x", ret);
4632 int camera_attr_set_hue(camera_h camera, int level)
4634 int ret = CAMERA_ERROR_NONE;
4635 camera_cli_s *pc = (camera_cli_s *)camera;
4636 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HUE;
4637 camera_msg_param param;
4639 if (!pc || !pc->cb_info) {
4640 LOGE("NULL handle");
4641 return CAMERA_ERROR_INVALID_PARAMETER;
4646 CAMERA_MSG_PARAM_SET(param, INT, level);
4648 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4650 LOGD("ret : 0x%x", ret);
4656 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4658 int ret = CAMERA_ERROR_NONE;
4659 camera_cli_s *pc = (camera_cli_s *)camera;
4660 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4661 camera_msg_param param;
4662 int set_whitebalance = (int)wb;
4664 if (!pc || !pc->cb_info) {
4665 LOGE("NULL handle");
4666 return CAMERA_ERROR_INVALID_PARAMETER;
4671 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4673 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4675 LOGD("ret : 0x%x", ret);
4681 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4683 int ret = CAMERA_ERROR_NONE;
4684 camera_cli_s *pc = (camera_cli_s *)camera;
4685 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4686 camera_msg_param param;
4687 int set_effect = (int)effect;
4689 if (!pc || !pc->cb_info) {
4690 LOGE("NULL handle");
4691 return CAMERA_ERROR_INVALID_PARAMETER;
4696 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4698 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4700 LOGD("ret : 0x%x", ret);
4706 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4708 int ret = CAMERA_ERROR_NONE;
4709 camera_cli_s *pc = (camera_cli_s *)camera;
4710 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4711 camera_msg_param param;
4712 int set_mode = (int)mode;
4714 if (!pc || !pc->cb_info) {
4715 LOGE("NULL handle");
4716 return CAMERA_ERROR_INVALID_PARAMETER;
4721 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4723 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4725 LOGD("ret : 0x%x", ret);
4731 int camera_attr_enable_tag(camera_h camera, bool enable)
4733 int ret = CAMERA_ERROR_NONE;
4734 camera_cli_s *pc = (camera_cli_s *)camera;
4735 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4736 camera_msg_param param;
4737 int set_enable = (int)enable;
4739 if (!pc || !pc->cb_info) {
4740 LOGE("NULL handle");
4741 return CAMERA_ERROR_INVALID_PARAMETER;
4746 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4748 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4750 LOGD("ret : 0x%x", ret);
4756 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4758 int ret = CAMERA_ERROR_NONE;
4759 camera_cli_s *pc = (camera_cli_s *)camera;
4760 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4761 camera_msg_param param;
4763 if (!pc || !pc->cb_info || !description) {
4764 LOGE("NULL pointer %p %p", pc, description);
4765 return CAMERA_ERROR_INVALID_PARAMETER;
4770 CAMERA_MSG_PARAM_SET(param, STRING, description);
4772 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4774 LOGD("ret : 0x%x", ret);
4780 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4782 int ret = CAMERA_ERROR_NONE;
4783 camera_cli_s *pc = (camera_cli_s *)camera;
4784 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4785 camera_msg_param param;
4786 int set_orientation = (int)orientation;
4788 if (!pc || !pc->cb_info) {
4789 LOGE("NULL handle");
4790 return CAMERA_ERROR_INVALID_PARAMETER;
4795 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4797 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4799 LOGD("ret : 0x%x", ret);
4805 int camera_attr_set_tag_software(camera_h camera, const char *software)
4807 int ret = CAMERA_ERROR_NONE;
4808 camera_cli_s *pc = (camera_cli_s *)camera;
4809 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4810 camera_msg_param param;
4812 if (!pc || !pc->cb_info || !software) {
4813 LOGE("NULL pointer %p %p", pc, software);
4814 return CAMERA_ERROR_INVALID_PARAMETER;
4817 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4819 CAMERA_MSG_PARAM_SET(param, STRING, software);
4821 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4823 LOGD("ret : 0x%x", ret);
4829 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4831 int ret = CAMERA_ERROR_NONE;
4832 camera_cli_s *pc = (camera_cli_s *)camera;
4833 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4834 double set_geotag[3] = {latitude, longitude, altitude};
4839 if (!pc || !pc->cb_info) {
4840 LOGE("NULL handle");
4841 return CAMERA_ERROR_INVALID_PARAMETER;
4846 length = sizeof(set_geotag) / sizeof(int) + \
4847 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4849 msg = muse_core_msg_new(api,
4850 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4853 LOGE("msg creation failed: api %d", api);
4854 return CAMERA_ERROR_OUT_OF_MEMORY;
4857 if (pc->cb_info->is_server_connected) {
4858 __camera_update_api_waiting(pc->cb_info, api, 1);
4860 g_mutex_lock(&pc->cb_info->fd_lock);
4861 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
4862 g_mutex_unlock(&pc->cb_info->fd_lock);
4866 LOGE("message send failed");
4867 ret = CAMERA_ERROR_INVALID_OPERATION;
4869 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
4872 __camera_update_api_waiting(pc->cb_info, api, -1);
4874 muse_core_msg_free(msg);
4876 LOGD("ret : 0x%x", ret);
4882 int camera_attr_remove_geotag(camera_h camera)
4884 int ret = CAMERA_ERROR_NONE;
4885 camera_cli_s *pc = (camera_cli_s *)camera;
4886 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4888 if (!pc || !pc->cb_info) {
4889 LOGE("NULL handle");
4890 return CAMERA_ERROR_INVALID_PARAMETER;
4895 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4897 LOGD("ret : 0x%x", ret);
4903 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4905 int ret = CAMERA_ERROR_NONE;
4906 camera_cli_s *pc = (camera_cli_s *)camera;
4907 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
4908 camera_msg_param param;
4909 int set_mode = (int)mode;
4911 if (!pc || !pc->cb_info) {
4912 LOGE("NULL handle");
4913 return CAMERA_ERROR_INVALID_PARAMETER;
4918 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4920 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4922 LOGD("ret : 0x%x", ret);
4928 int camera_attr_get_zoom(camera_h camera, int *zoom)
4930 int ret = CAMERA_ERROR_NONE;
4931 camera_cli_s *pc = (camera_cli_s *)camera;
4932 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4934 if (!pc || !pc->cb_info || !zoom) {
4935 LOGE("NULL pointer %p %p", pc, zoom);
4936 return CAMERA_ERROR_INVALID_PARAMETER;
4941 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4943 if (ret == CAMERA_ERROR_NONE)
4944 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
4946 LOGD("ret : 0x%x", ret);
4952 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
4954 int ret = CAMERA_ERROR_NONE;
4955 camera_cli_s *pc = (camera_cli_s *)camera;
4956 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
4958 if (!pc || !pc->cb_info || !min || !max) {
4959 LOGE("NULL pointer %p %p %p", pc, min, max);
4960 return CAMERA_ERROR_INVALID_PARAMETER;
4965 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4967 if (ret == CAMERA_ERROR_NONE) {
4968 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
4969 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
4972 LOGD("ret : 0x%x", ret);
4978 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
4980 int ret = CAMERA_ERROR_NONE;
4981 camera_cli_s *pc = (camera_cli_s *)camera;
4982 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
4984 if (!pc || !pc->cb_info || !mode) {
4985 LOGE("NULL pointer %p %p", pc, mode);
4986 return CAMERA_ERROR_INVALID_PARAMETER;
4991 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4993 if (ret == CAMERA_ERROR_NONE)
4994 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
4996 LOGD("ret : 0x%x", ret);
5002 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
5004 int ret = CAMERA_ERROR_NONE;
5005 camera_cli_s *pc = (camera_cli_s *)camera;
5006 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
5008 if (!pc || !pc->cb_info || !mode) {
5009 LOGE("NULL pointer %p %p", pc, mode);
5010 return CAMERA_ERROR_INVALID_PARAMETER;
5015 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5017 if (ret == CAMERA_ERROR_NONE)
5018 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5020 LOGD("ret : 0x%x", ret);
5026 int camera_attr_get_exposure(camera_h camera, int *value)
5028 int ret = CAMERA_ERROR_NONE;
5029 camera_cli_s *pc = (camera_cli_s *)camera;
5030 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5032 if (!pc || !pc->cb_info || !value) {
5033 LOGE("NULL pointer %p %p", pc, value);
5034 return CAMERA_ERROR_INVALID_PARAMETER;
5039 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5041 if (ret == CAMERA_ERROR_NONE)
5042 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5044 LOGD("ret : 0x%x", ret);
5050 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5052 int ret = CAMERA_ERROR_NONE;
5053 camera_cli_s *pc = (camera_cli_s *)camera;
5054 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5056 if (!pc || !pc->cb_info || !min || !max) {
5057 LOGE("NULL pointer %p %p %p", pc, min, max);
5058 return CAMERA_ERROR_INVALID_PARAMETER;
5063 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5065 if (ret == CAMERA_ERROR_NONE) {
5066 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5067 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5070 LOGD("ret : 0x%x", ret);
5076 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5078 int ret = CAMERA_ERROR_NONE;
5079 camera_cli_s *pc = (camera_cli_s *)camera;
5080 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5082 if (!pc || !pc->cb_info || !iso) {
5083 LOGE("NULL pointer %p %p", pc, iso);
5084 return CAMERA_ERROR_INVALID_PARAMETER;
5089 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5091 if (ret == CAMERA_ERROR_NONE)
5092 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5094 LOGD("ret : 0x%x", ret);
5100 int camera_attr_get_brightness(camera_h camera, int *level)
5102 int ret = CAMERA_ERROR_NONE;
5103 camera_cli_s *pc = (camera_cli_s *)camera;
5104 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5106 if (!pc || !pc->cb_info || !level) {
5107 LOGE("NULL pointer %p %p", pc, level);
5108 return CAMERA_ERROR_INVALID_PARAMETER;
5113 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5115 if (ret == CAMERA_ERROR_NONE)
5116 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5118 LOGD("ret : 0x%x", ret);
5124 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5126 int ret = CAMERA_ERROR_NONE;
5127 camera_cli_s *pc = (camera_cli_s *)camera;
5128 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5130 if (!pc || !pc->cb_info || !min || !max) {
5131 LOGE("NULL pointer %p %p %p", pc, min, max);
5132 return CAMERA_ERROR_INVALID_PARAMETER;
5137 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5139 if (ret == CAMERA_ERROR_NONE) {
5140 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5141 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5144 LOGD("ret : 0x%x", ret);
5150 int camera_attr_get_contrast(camera_h camera, int *level)
5152 int ret = CAMERA_ERROR_NONE;
5153 camera_cli_s *pc = (camera_cli_s *)camera;
5154 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5156 if (!pc || !pc->cb_info || !level) {
5157 LOGE("NULL pointer %p %p", pc, level);
5158 return CAMERA_ERROR_INVALID_PARAMETER;
5163 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5165 if (ret == CAMERA_ERROR_NONE)
5166 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5168 LOGD("ret : 0x%x", ret);
5174 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5176 int ret = CAMERA_ERROR_NONE;
5177 camera_cli_s *pc = (camera_cli_s *)camera;
5178 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5180 if (!pc || !pc->cb_info || !min || !max) {
5181 LOGE("NULL pointer %p %p %p", pc, min, max);
5182 return CAMERA_ERROR_INVALID_PARAMETER;
5187 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5189 if (ret == CAMERA_ERROR_NONE) {
5190 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5191 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5192 LOGD("min %d, max %d", *min, *max);
5195 LOGD("ret : 0x%x", ret);
5201 int camera_attr_get_hue(camera_h camera, int *level)
5203 int ret = CAMERA_ERROR_NONE;
5204 camera_cli_s *pc = (camera_cli_s *)camera;
5205 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE;
5207 if (!pc || !pc->cb_info || !level) {
5208 LOGE("NULL pointer %p %p", pc, level);
5209 return CAMERA_ERROR_INVALID_PARAMETER;
5214 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5216 if (ret == CAMERA_ERROR_NONE)
5217 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HUE];
5219 LOGD("ret : 0x%x", ret);
5225 int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
5227 int ret = CAMERA_ERROR_NONE;
5228 camera_cli_s *pc = (camera_cli_s *)camera;
5229 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE_RANGE;
5231 if (!pc || !pc->cb_info || !min || !max) {
5232 LOGE("NULL pointer %p %p %p", pc, min, max);
5233 return CAMERA_ERROR_INVALID_PARAMETER;
5238 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5240 if (ret == CAMERA_ERROR_NONE) {
5241 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][0];
5242 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][1];
5243 LOGD("min %d, max %d", *min, *max);
5246 LOGD("ret : 0x%x", ret);
5252 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5254 int ret = CAMERA_ERROR_NONE;
5255 camera_cli_s *pc = (camera_cli_s *)camera;
5256 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5258 if (!pc || !pc->cb_info || !wb) {
5259 LOGE("NULL pointer %p %p", pc, wb);
5260 return CAMERA_ERROR_INVALID_PARAMETER;
5265 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5267 if (ret == CAMERA_ERROR_NONE)
5268 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5270 LOGD("ret : 0x%x", ret);
5276 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5278 int ret = CAMERA_ERROR_NONE;
5279 camera_cli_s *pc = (camera_cli_s *)camera;
5280 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5282 if (!pc || !pc->cb_info || !effect) {
5283 LOGE("NULL pointer %p %p", pc, effect);
5284 return CAMERA_ERROR_INVALID_PARAMETER;
5289 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5291 if (ret == CAMERA_ERROR_NONE)
5292 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5294 LOGD("ret : 0x%x", ret);
5300 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5302 int ret = CAMERA_ERROR_NONE;
5303 camera_cli_s *pc = (camera_cli_s *)camera;
5304 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5306 if (!pc || !pc->cb_info || !mode) {
5307 LOGE("NULL pointer %p %p", pc, mode);
5308 return CAMERA_ERROR_INVALID_PARAMETER;
5313 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5315 if (ret == CAMERA_ERROR_NONE)
5316 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5318 LOGD("ret : 0x%x", ret);
5324 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5326 int ret = CAMERA_ERROR_NONE;
5327 camera_cli_s *pc = (camera_cli_s *)camera;
5328 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5330 if (!pc || !pc->cb_info || !enable) {
5331 LOGE("NULL pointer %p %p", pc, enable);
5332 return CAMERA_ERROR_INVALID_PARAMETER;
5337 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5339 if (ret == CAMERA_ERROR_NONE)
5340 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5342 LOGD("ret : 0x%x", ret);
5348 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5350 int ret = CAMERA_ERROR_NONE;
5351 camera_cli_s *pc = (camera_cli_s *)camera;
5352 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5354 if (!pc || !pc->cb_info || !description) {
5355 LOGE("NULL pointer %p %p", pc, description);
5356 return CAMERA_ERROR_INVALID_PARAMETER;
5361 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5363 if (ret == CAMERA_ERROR_NONE)
5364 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5366 LOGD("ret : 0x%x", ret);
5372 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5374 int ret = CAMERA_ERROR_NONE;
5375 camera_cli_s *pc = (camera_cli_s *)camera;
5376 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5378 if (!pc || !pc->cb_info || !orientation) {
5379 LOGE("NULL pointer %p %p", pc, orientation);
5380 return CAMERA_ERROR_INVALID_PARAMETER;
5385 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5387 if (ret == CAMERA_ERROR_NONE)
5388 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5390 LOGD("ret : 0x%x", ret);
5396 int camera_attr_get_tag_software(camera_h camera, char **software)
5398 int ret = CAMERA_ERROR_NONE;
5399 camera_cli_s *pc = (camera_cli_s *)camera;
5400 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5402 if (!pc || !pc->cb_info || !software) {
5403 LOGE("NULL pointer %p %p", pc, software);
5404 return CAMERA_ERROR_INVALID_PARAMETER;
5409 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5411 if (ret == CAMERA_ERROR_NONE)
5412 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5414 LOGD("ret : 0x%x", ret);
5420 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5422 int ret = CAMERA_ERROR_NONE;
5423 camera_cli_s *pc = (camera_cli_s *)camera;
5424 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5426 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5427 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5428 return CAMERA_ERROR_INVALID_PARAMETER;
5433 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5435 if (ret == CAMERA_ERROR_NONE) {
5436 *latitude = pc->cb_info->get_geotag[0];
5437 *longitude = pc->cb_info->get_geotag[1];
5438 *altitude = pc->cb_info->get_geotag[2];
5441 LOGD("ret : 0x%x", ret);
5447 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5449 int ret = CAMERA_ERROR_NONE;
5450 camera_cli_s *pc = (camera_cli_s *)camera;
5451 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5453 if (!pc || !pc->cb_info || !mode) {
5454 LOGE("NULL pointer %p %p", pc, mode);
5455 return CAMERA_ERROR_INVALID_PARAMETER;
5460 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5462 if (ret == CAMERA_ERROR_NONE)
5463 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5465 LOGD("ret : 0x%x", ret);
5471 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5473 int ret = CAMERA_ERROR_NONE;
5474 int get_flash_state = 0;
5477 LOGE("NULL pointer");
5478 return CAMERA_ERROR_INVALID_PARAMETER;
5481 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5482 (int)device, "get_flash_state", &get_flash_state);
5484 if (ret == CAMERA_ERROR_NONE) {
5485 *state = (camera_flash_state_e)get_flash_state;
5486 LOGD("flash state %d", *state);
5488 LOGE("failed 0x%x", ret);
5495 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5497 int ret = CAMERA_ERROR_NONE;
5498 camera_cli_s *pc = (camera_cli_s *)camera;
5499 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5501 if (!pc || !pc->cb_info || !foreach_cb) {
5502 LOGE("NULL pointer %p %p", pc, foreach_cb);
5503 return CAMERA_ERROR_INVALID_PARAMETER;
5508 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5509 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5511 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5513 LOGD("ret : 0x%x", ret);
5519 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5521 int ret = CAMERA_ERROR_NONE;
5522 camera_cli_s *pc = (camera_cli_s *)camera;
5523 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5525 if (!pc || !pc->cb_info || !foreach_cb) {
5526 LOGE("NULL pointer %p %p", pc, foreach_cb);
5527 return CAMERA_ERROR_INVALID_PARAMETER;
5532 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5533 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5535 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5537 LOGD("ret : 0x%x", ret);
5543 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5545 int ret = CAMERA_ERROR_NONE;
5546 camera_cli_s *pc = (camera_cli_s *)camera;
5547 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5549 if (!pc || !pc->cb_info || !foreach_cb) {
5550 LOGE("NULL pointer %p %p", pc, foreach_cb);
5551 return CAMERA_ERROR_INVALID_PARAMETER;
5556 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5557 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5559 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5561 LOGD("ret : 0x%x", ret);
5567 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5569 int ret = CAMERA_ERROR_NONE;
5570 camera_cli_s *pc = (camera_cli_s *)camera;
5571 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5573 if (!pc || !pc->cb_info || !foreach_cb) {
5574 LOGE("NULL pointer %p %p", pc, foreach_cb);
5575 return CAMERA_ERROR_INVALID_PARAMETER;
5580 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5581 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5583 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5585 LOGD("ret : 0x%x", ret);
5591 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5593 int ret = CAMERA_ERROR_NONE;
5594 camera_cli_s *pc = (camera_cli_s *)camera;
5595 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5597 if (!pc || !pc->cb_info || !foreach_cb) {
5598 LOGE("NULL pointer %p %p", pc, foreach_cb);
5599 return CAMERA_ERROR_INVALID_PARAMETER;
5604 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5605 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5607 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5609 LOGD("ret : 0x%x", ret);
5615 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5617 int ret = CAMERA_ERROR_NONE;
5618 camera_cli_s *pc = (camera_cli_s *)camera;
5619 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5621 if (!pc || !pc->cb_info || !foreach_cb) {
5622 LOGE("NULL pointer %p %p", pc, foreach_cb);
5623 return CAMERA_ERROR_INVALID_PARAMETER;
5628 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5629 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5631 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5633 LOGD("ret : 0x%x", ret);
5639 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5641 int ret = CAMERA_ERROR_NONE;
5642 camera_cli_s *pc = (camera_cli_s *)camera;
5643 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5645 if (!pc || !pc->cb_info || !foreach_cb) {
5646 LOGE("NULL pointer %p %p", pc, foreach_cb);
5647 return CAMERA_ERROR_INVALID_PARAMETER;
5652 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5653 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5655 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5657 LOGD("ret : 0x%x", ret);
5663 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5665 int ret = CAMERA_ERROR_NONE;
5666 camera_cli_s *pc = (camera_cli_s *)camera;
5667 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5669 if (!pc || !pc->cb_info || !foreach_cb) {
5670 LOGE("NULL pointer %p %p", pc, foreach_cb);
5671 return CAMERA_ERROR_INVALID_PARAMETER;
5676 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5677 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5679 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5681 LOGD("Enter, handle :%x", pc->remote_handle);
5687 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)
5689 int ret = CAMERA_ERROR_NONE;
5690 camera_cli_s *pc = (camera_cli_s *)camera;
5691 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5692 camera_msg_param param;
5695 if (!pc || !pc->cb_info || !foreach_cb) {
5696 LOGE("NULL pointer %p %p", pc, foreach_cb);
5697 return CAMERA_ERROR_INVALID_PARAMETER;
5702 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5703 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5705 value = (width << 16) | height;
5706 CAMERA_MSG_PARAM_SET(param, INT, value);
5708 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5710 LOGD("ret : 0x%x", ret);
5716 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5718 int ret = CAMERA_ERROR_NONE;
5719 camera_cli_s *pc = (camera_cli_s *)camera;
5720 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5722 if (!pc || !pc->cb_info || !foreach_cb) {
5723 LOGE("NULL pointer %p %p", pc, foreach_cb);
5724 return CAMERA_ERROR_INVALID_PARAMETER;
5729 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5730 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5732 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5734 LOGD("ret : 0x%x", ret);
5740 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5742 int ret = CAMERA_ERROR_NONE;
5743 camera_cli_s *pc = (camera_cli_s *)camera;
5744 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5746 if (!pc || !pc->cb_info || !foreach_cb) {
5747 LOGE("NULL pointer %p %p", pc, foreach_cb);
5748 return CAMERA_ERROR_INVALID_PARAMETER;
5753 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5754 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5756 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5758 LOGD("ret : 0x%x", ret);
5764 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5766 int ret = CAMERA_ERROR_NONE;
5767 camera_cli_s *pc = (camera_cli_s *)camera;
5768 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5769 camera_msg_param param;
5770 int set_rotation = (int)rotation;
5772 if (!pc || !pc->cb_info) {
5773 LOGE("NULL handle");
5774 return CAMERA_ERROR_INVALID_PARAMETER;
5779 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5781 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5783 LOGD("ret : 0x%x", ret);
5789 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5791 int ret = CAMERA_ERROR_NONE;
5792 camera_cli_s *pc = (camera_cli_s *)camera;
5793 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5795 if (!pc || !pc->cb_info || !rotation) {
5796 LOGE("NULL pointer %p %p", pc, rotation);
5797 return CAMERA_ERROR_INVALID_PARAMETER;
5802 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5804 if (ret == CAMERA_ERROR_NONE)
5805 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5807 LOGD("ret : 0x%x", ret);
5813 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5815 int ret = CAMERA_ERROR_NONE;
5816 camera_cli_s *pc = (camera_cli_s *)camera;
5817 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5818 camera_msg_param param;
5819 int set_flip = (int)flip;
5821 if (!pc || !pc->cb_info) {
5822 LOGE("NULL handle");
5823 return CAMERA_ERROR_INVALID_PARAMETER;
5828 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5830 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5832 LOGD("ret : 0x%x", ret);
5838 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5840 int ret = CAMERA_ERROR_NONE;
5841 camera_cli_s *pc = (camera_cli_s *)camera;
5842 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5844 if (!pc || !pc->cb_info || !flip) {
5845 LOGE("NULL pointer %p %p", pc, flip);
5846 return CAMERA_ERROR_INVALID_PARAMETER;
5851 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5853 if (ret == CAMERA_ERROR_NONE)
5854 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5856 LOGD("ret : 0x%x", ret);
5861 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5863 int ret = CAMERA_ERROR_NONE;
5864 camera_cli_s *pc = (camera_cli_s *)camera;
5865 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5866 camera_msg_param param;
5867 int set_mode = (int)mode;
5869 if (!pc || !pc->cb_info) {
5870 LOGE("NULL handle");
5871 return CAMERA_ERROR_INVALID_PARAMETER;
5876 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5878 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5880 LOGD("ret : 0x%x", ret);
5886 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5888 int ret = CAMERA_ERROR_NONE;
5889 camera_cli_s *pc = (camera_cli_s *)camera;
5890 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5892 if (!pc || !pc->cb_info || !mode) {
5893 LOGE("NULL pointer %p %p", pc, mode);
5894 return CAMERA_ERROR_INVALID_PARAMETER;
5899 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5901 if (ret == CAMERA_ERROR_NONE)
5902 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
5904 LOGD("ret : 0x%x", ret);
5910 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5912 int ret = CAMERA_ERROR_NONE;
5913 camera_cli_s *pc = (camera_cli_s *)camera;
5914 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
5916 if (!pc || !pc->cb_info) {
5917 LOGE("NULL handle");
5918 return CAMERA_ERROR_INVALID_PARAMETER;
5923 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5926 LOGE("error is occurred 0x%x", ret);
5930 LOGD("ret : %d", ret);
5936 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5938 int ret = CAMERA_ERROR_NONE;
5939 camera_cli_s *pc = (camera_cli_s *)camera;
5940 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5942 if (!pc || !pc->cb_info) {
5943 LOGE("NULL handle");
5944 return CAMERA_ERROR_INVALID_PARAMETER;
5949 if (!camera_attr_is_supported_hdr_capture(camera)) {
5950 LOGE("HDR not supported");
5951 return CAMERA_ERROR_NOT_SUPPORTED;
5955 LOGE("NULL callback");
5956 return CAMERA_ERROR_INVALID_PARAMETER;
5959 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5961 if (ret == CAMERA_ERROR_NONE) {
5962 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5964 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5965 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5967 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5970 LOGD("ret : 0x%x", ret);
5976 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5978 int ret = CAMERA_ERROR_NONE;
5979 camera_cli_s *pc = (camera_cli_s *)camera;
5980 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5982 if (!pc || !pc->cb_info) {
5983 LOGE("NULL handle");
5984 return CAMERA_ERROR_INVALID_PARAMETER;
5989 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5991 if (ret == CAMERA_ERROR_NONE) {
5992 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5994 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5995 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5997 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
6000 LOGD("ret : 0x%x", ret);
6006 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
6008 int ret = CAMERA_ERROR_NONE;
6009 camera_cli_s *pc = (camera_cli_s *)camera;
6010 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
6011 camera_msg_param param;
6012 int set_enable = (int)enable;
6014 if (!pc || !pc->cb_info) {
6015 LOGE("NULL handle");
6016 return CAMERA_ERROR_INVALID_PARAMETER;
6021 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6023 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6025 LOGD("ret : 0x%x", ret);
6031 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6033 int ret = CAMERA_ERROR_NONE;
6034 camera_cli_s *pc = (camera_cli_s *)camera;
6035 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6037 if (!pc || !pc->cb_info || !enabled) {
6038 LOGE("NULL pointer %p %p", pc, enabled);
6039 return CAMERA_ERROR_INVALID_PARAMETER;
6044 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6046 if (ret == CAMERA_ERROR_NONE)
6047 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6049 LOGD("ret : 0x%x", ret);
6055 bool camera_attr_is_supported_anti_shake(camera_h camera)
6057 int ret = CAMERA_ERROR_NONE;
6058 camera_cli_s *pc = (camera_cli_s *)camera;
6059 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6061 if (!pc || !pc->cb_info) {
6062 LOGE("NULL handle");
6063 return CAMERA_ERROR_INVALID_PARAMETER;
6068 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6071 LOGE("error is occurred 0x%x", ret);
6075 LOGD("ret : %d", ret);
6081 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6083 int ret = CAMERA_ERROR_NONE;
6084 camera_cli_s *pc = (camera_cli_s *)camera;
6085 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6086 camera_msg_param param;
6087 int set_enable = (int)enable;
6089 if (!pc || !pc->cb_info) {
6090 LOGE("NULL handle");
6091 return CAMERA_ERROR_INVALID_PARAMETER;
6096 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6098 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6100 LOGD("ret : 0x%x", ret);
6106 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6108 int ret = CAMERA_ERROR_NONE;
6109 camera_cli_s *pc = (camera_cli_s *)camera;
6110 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6112 if (!pc || !pc->cb_info || !enabled) {
6113 LOGE("NULL pointer %p %p", pc, enabled);
6114 return CAMERA_ERROR_INVALID_PARAMETER;
6119 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6121 if (ret == CAMERA_ERROR_NONE)
6122 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6124 LOGD("ret : 0x%x", ret);
6130 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6132 int ret = CAMERA_ERROR_NONE;
6133 camera_cli_s *pc = (camera_cli_s *)camera;
6134 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6136 if (!pc || !pc->cb_info) {
6137 LOGE("NULL handle");
6138 return CAMERA_ERROR_INVALID_PARAMETER;
6143 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6146 LOGE("error is occurred 0x%x", ret);
6150 LOGD("ret : %d", ret);
6156 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6158 int ret = CAMERA_ERROR_NONE;
6159 camera_cli_s *pc = (camera_cli_s *)camera;
6160 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6161 camera_msg_param param;
6162 int set_enable = (int)enable;
6164 if (!pc || !pc->cb_info) {
6165 LOGE("NULL handle");
6166 return CAMERA_ERROR_INVALID_PARAMETER;
6171 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6173 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6175 LOGD("ret : 0x%x", ret);
6181 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6183 int ret = CAMERA_ERROR_NONE;
6184 camera_cli_s *pc = (camera_cli_s *)camera;
6185 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6187 if (!pc || !pc->cb_info || !enabled) {
6188 LOGE("NULL pointer %p %p", pc, enabled);
6189 return CAMERA_ERROR_INVALID_PARAMETER;
6194 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6196 if (ret == CAMERA_ERROR_NONE)
6197 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6199 LOGD("ret : 0x%x", ret);
6205 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6207 int ret = CAMERA_ERROR_NONE;
6208 camera_cli_s *pc = (camera_cli_s *)camera;
6209 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6211 if (!pc || !pc->cb_info) {
6212 LOGE("NULL handle");
6213 return CAMERA_ERROR_INVALID_PARAMETER;
6218 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6221 LOGE("error is occurred 0x%x", ret);
6225 LOGD("ret : %d", ret);
6231 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6233 int ret = CAMERA_ERROR_NONE;
6234 camera_cli_s *pc = (camera_cli_s *)camera;
6235 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6236 camera_msg_param param;
6237 int set_disable = (int)disable;
6239 if (!pc || !pc->cb_info) {
6240 LOGE("NULL handle");
6241 return CAMERA_ERROR_INVALID_PARAMETER;
6246 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6248 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6250 LOGD("ret : 0x%x", ret);
6256 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6258 int ret = CAMERA_ERROR_NONE;
6259 camera_cli_s *pc = (camera_cli_s *)camera;
6260 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6261 camera_msg_param param;
6262 int set_move_type = (int)move_type;
6265 if (!pc || !pc->cb_info) {
6266 LOGE("NULL handle");
6267 return CAMERA_ERROR_INVALID_PARAMETER;
6272 value = (set_move_type << 16) | pan_step;
6273 CAMERA_MSG_PARAM_SET(param, INT, value);
6275 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6277 LOGD("ret : 0x%x", ret);
6283 int camera_attr_get_pan(camera_h camera, int *pan_step)
6285 int ret = CAMERA_ERROR_NONE;
6286 camera_cli_s *pc = (camera_cli_s *)camera;
6287 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6289 if (!pc || !pc->cb_info || !pan_step) {
6290 LOGE("NULL pointer %p %p", pc, pan_step);
6291 return CAMERA_ERROR_INVALID_PARAMETER;
6296 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6298 if (ret == CAMERA_ERROR_NONE)
6299 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6301 LOGD("ret : 0x%x", ret);
6307 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6309 int ret = CAMERA_ERROR_NONE;
6310 camera_cli_s *pc = (camera_cli_s *)camera;
6311 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6313 if (!pc || !pc->cb_info || !min || !max) {
6314 LOGE("NULL pointer %p %p %p", pc, min, max);
6315 return CAMERA_ERROR_INVALID_PARAMETER;
6320 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6322 if (ret == CAMERA_ERROR_NONE) {
6323 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6324 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6327 LOGD("ret : 0x%x", ret);
6333 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6335 int ret = CAMERA_ERROR_NONE;
6336 camera_cli_s *pc = (camera_cli_s *)camera;
6337 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6338 camera_msg_param param;
6339 int set_move_type = (int)move_type;
6342 if (!pc || !pc->cb_info) {
6343 LOGE("NULL handle");
6344 return CAMERA_ERROR_INVALID_PARAMETER;
6349 value = (set_move_type << 16) | tilt_step;
6350 CAMERA_MSG_PARAM_SET(param, INT, value);
6352 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6354 LOGD("ret : 0x%x", ret);
6360 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6362 int ret = CAMERA_ERROR_NONE;
6363 camera_cli_s *pc = (camera_cli_s *)camera;
6364 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6366 if (!pc || !pc->cb_info || !tilt_step) {
6367 LOGE("NULL pointer %p %p", pc, tilt_step);
6368 return CAMERA_ERROR_INVALID_PARAMETER;
6373 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6375 if (ret == CAMERA_ERROR_NONE)
6376 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6378 LOGD("ret : 0x%x", ret);
6384 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6386 int ret = CAMERA_ERROR_NONE;
6387 camera_cli_s *pc = (camera_cli_s *)camera;
6388 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6390 if (!pc || !pc->cb_info || !min || !max) {
6391 LOGE("NULL pointer %p %p %p", pc, min, max);
6392 return CAMERA_ERROR_INVALID_PARAMETER;
6397 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6399 if (ret == CAMERA_ERROR_NONE) {
6400 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6401 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6404 LOGD("ret : 0x%x", ret);
6410 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6412 int ret = CAMERA_ERROR_NONE;
6413 camera_cli_s *pc = (camera_cli_s *)camera;
6414 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6415 camera_msg_param param;
6416 int set_ptz_type = (int)ptz_type;
6418 if (!pc || !pc->cb_info) {
6419 LOGE("NULL handle");
6420 return CAMERA_ERROR_INVALID_PARAMETER;
6425 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6427 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6429 LOGD("ret : 0x%x", ret);
6435 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6437 int ret = CAMERA_ERROR_NONE;
6438 camera_cli_s *pc = (camera_cli_s *)camera;
6439 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6441 if (!pc || !pc->cb_info || !foreach_cb) {
6442 LOGE("NULL pointer %p %p", pc, foreach_cb);
6443 return CAMERA_ERROR_INVALID_PARAMETER;
6448 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6449 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6451 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6453 LOGD("ret : 0x%x", ret);
6459 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6461 int ret = CAMERA_ERROR_NONE;
6462 camera_cli_s *pc = (camera_cli_s *)camera;
6463 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6464 int set_display_roi_area[4] = {x, y, width, height};
6469 if (!pc || !pc->cb_info) {
6470 LOGE("NULL handle");
6471 return CAMERA_ERROR_INVALID_PARAMETER;
6476 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6477 ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
6478 if (ret != MM_ERROR_NONE) {
6479 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6480 return CAMERA_ERROR_INVALID_OPERATION;
6484 length = sizeof(set_display_roi_area) / sizeof(int) + \
6485 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6487 msg = muse_core_msg_new(api,
6488 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6491 LOGE("msg creation failed: api %d", api);
6492 return CAMERA_ERROR_OUT_OF_MEMORY;
6495 if (pc->cb_info->is_server_connected) {
6496 __camera_update_api_waiting(pc->cb_info, api, 1);
6498 g_mutex_lock(&pc->cb_info->fd_lock);
6499 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
6500 g_mutex_unlock(&pc->cb_info->fd_lock);
6504 LOGE("message send failed");
6505 ret = CAMERA_ERROR_INVALID_OPERATION;
6507 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6510 __camera_update_api_waiting(pc->cb_info, api, -1);
6512 muse_core_msg_free(msg);
6514 LOGD("ret : 0x%x", ret);
6520 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6522 camera_cli_s *pc = (camera_cli_s *)camera;
6523 int ret = CAMERA_ERROR_NONE;
6524 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6526 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6527 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6528 return CAMERA_ERROR_INVALID_PARAMETER;
6533 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6535 if (ret == CAMERA_ERROR_NONE) {
6536 *x = pc->cb_info->get_display_roi_area[0];
6537 *y = pc->cb_info->get_display_roi_area[1];
6538 *width = pc->cb_info->get_display_roi_area[2];
6539 *height = pc->cb_info->get_display_roi_area[3];
6542 LOGD("ret : 0x%x", ret);
6548 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6550 int ret = CAMERA_ERROR_NONE;
6551 int get_device_state = 0;
6554 LOGE("NULL pointer");
6555 return CAMERA_ERROR_INVALID_PARAMETER;
6558 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6559 (int)device, "get_device_state", &get_device_state);
6561 if (ret == CAMERA_ERROR_NONE) {
6562 *state = (camera_device_state_e)get_device_state;
6563 LOGD("device state %d", *state);
6565 LOGE("failed 0x%x", ret);
6572 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6574 int ret = CAMERA_ERROR_NONE;
6575 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6576 camera_cb_info *info = NULL;
6578 if (!callback || !cb_id) {
6579 LOGE("invalid pointer %p %p", callback, cb_id);
6580 return CAMERA_ERROR_INVALID_PARAMETER;
6583 /* check camera support */
6584 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6585 if (ret != CAMERA_ERROR_NONE) {
6586 LOGE("get device state failed");
6590 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6592 info = g_new0(camera_cb_info, 1);
6594 LOGE("info failed");
6595 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6599 info->id = ++g_cam_dev_state_changed_cb_id;
6600 info->callback = (void *)callback;
6601 info->user_data = user_data;
6605 /* subscribe dbus signal for camera state change */
6606 if (!g_cam_dev_state_changed_cb_conn) {
6607 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6608 if (!g_cam_dev_state_changed_cb_conn) {
6609 LOGE("failed to get gdbus connection");
6610 ret = CAMERA_ERROR_INVALID_OPERATION;
6614 LOGD("subscribe signal %s - %s - %s",
6615 MM_CAMCORDER_DBUS_OBJECT,
6616 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6617 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6619 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6620 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6621 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6622 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6623 LOGE("failed to get gdbus connection");
6624 ret = CAMERA_ERROR_INVALID_OPERATION;
6628 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6631 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6633 LOGD("callback id %d", info->id);
6636 if (ret != CAMERA_ERROR_NONE) {
6642 if (g_cam_dev_state_changed_cb_conn) {
6643 g_object_unref(g_cam_dev_state_changed_cb_conn);
6644 g_cam_dev_state_changed_cb_conn = NULL;
6648 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6654 int camera_remove_device_state_changed_cb(int cb_id)
6656 int ret = CAMERA_ERROR_NONE;
6657 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6658 GList *tmp_list = NULL;
6659 camera_cb_info *info = NULL;
6661 /* check camera support */
6662 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6663 if (ret != CAMERA_ERROR_NONE) {
6664 LOGE("get device state failed");
6668 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6670 if (!g_cam_dev_state_changed_cb_list) {
6671 LOGE("there is no callback info");
6672 ret = CAMERA_ERROR_INVALID_OPERATION;
6676 tmp_list = g_cam_dev_state_changed_cb_list;
6679 info = tmp_list->data;
6680 tmp_list = tmp_list->next;
6687 if (info->id == cb_id) {
6688 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6693 if (!g_cam_dev_state_changed_cb_list) {
6694 /* no remained callback */
6695 if (g_cam_dev_state_changed_cb_conn) {
6696 /* unsubscribe signal */
6697 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6698 g_cam_dev_state_changed_cb_subscribe_id = 0;
6700 /* unref connection */
6701 g_object_unref(g_cam_dev_state_changed_cb_conn);
6702 g_cam_dev_state_changed_cb_conn = NULL;
6706 LOGD("id %d callback removed", cb_id);
6707 ret = CAMERA_ERROR_NONE;
6713 LOGE("id %d callback not found", cb_id);
6714 ret = CAMERA_ERROR_INVALID_PARAMETER;
6717 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);