2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
24 #include <muse_camera.h>
25 #include <muse_camera_msg.h>
26 #include <camera_private.h>
27 #include <muse_core.h>
28 #include <muse_client.h>
30 #include <tbm_surface_internal.h>
36 #define LOG_TAG "TIZEN_N_CAMERA"
38 /* for device changed callback */
39 static GMutex g_cam_dev_state_changed_cb_lock;
40 static GList *g_cam_dev_state_changed_cb_list;
41 static int g_cam_dev_state_changed_cb_id;
42 static GDBusConnection *g_cam_dev_state_changed_cb_conn;
43 static guint g_cam_dev_state_changed_cb_subscribe_id;
45 static void _camera_msg_send(int api, camera_cb_info_s *cb_info,
46 int *ret, int timeout);
47 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
48 int *ret, camera_msg_param *param, int timeout);
49 static int _camera_import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle);
50 static void _camera_release_imported_bo(tbm_bo *bo);
51 static void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_key,
52 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame);
53 static int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
54 camera_media_packet_data *mp_data, media_packet_h *packet);
55 static int _camera_media_packet_data_create(int tbm_key, int num_buffer_key, tbm_bo bo,
56 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data);
57 static void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info);
60 static void __camera_update_api_waiting(camera_cb_info_s *cb_info, int api, int value)
63 api < 0 || api >= MUSE_CAMERA_API_MAX) {
64 LOGE("invalid param %p %d", cb_info, api);
68 g_mutex_lock(&(cb_info->api_mutex[api]));
69 cb_info->api_waiting[api] += value;
70 g_mutex_unlock(&(cb_info->api_mutex[api]));
72 /*LOGD("api %d, value %d, waiting %d",
73 api, value, cb_info->api_waiting[api]);*/
79 static void __camera_device_state_changed_cb(GDBusConnection *connection,
80 const gchar *sender_name, const gchar *object_path, const gchar *interface_name,
81 const gchar *signal_name, GVariant *param, gpointer user_data)
84 camera_device_e device = CAMERA_DEVICE_CAMERA0;
85 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
86 GList *tmp_list = NULL;
87 camera_cb_info *info = NULL;
89 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
91 if (!g_cam_dev_state_changed_cb_list || !param) {
92 LOGW("no callback or NULL param %p", param);
96 /* get device and state */
97 g_variant_get(param, "(i)", &value);
100 state = 0x0000ffff & value;
102 LOGD("device %d, state %d", device, state);
104 tmp_list = g_cam_dev_state_changed_cb_list;
107 info = (camera_cb_info *)tmp_list->data;
110 if (info->callback) {
111 LOGD("start id[%d] callback", info->id);
112 ((camera_device_state_changed_cb)info->callback)(device, state, info->user_data);
113 LOGD("returned id[%d] callback", info->id);
115 LOGW("NULL callback for id %d", info->id);
119 tmp_list = tmp_list->next;
123 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
129 static void __camera_event_handler_preview(camera_cb_info_s *cb_info, char *recv_msg)
133 int num_buffer_key = 0;
134 int buffer_key[BUFFER_MAX_PLANE_NUM] = {0, };
137 unsigned char *buf_pos = NULL;
138 camera_msg_param param;
141 tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
142 tbm_bo_handle bo_handle = {.ptr = NULL};
143 tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
144 tbm_bo data_bo = NULL;
145 tbm_bo_handle data_bo_handle = {.ptr = NULL};
147 camera_preview_data_s frame;
148 camera_stream_data_s *stream = NULL;
149 camera_media_packet_data *mp_data = NULL;
150 media_packet_h pkt = NULL;
151 media_packet_h pkt_evas = NULL;
153 if (!cb_info || !recv_msg) {
154 LOGE("invalid param %p %p", cb_info, recv_msg);
158 muse_camera_msg_get(tbm_key, recv_msg);
159 muse_camera_msg_get(num_buffer_key, recv_msg);
160 muse_camera_msg_get_array(buffer_key, recv_msg);
161 muse_camera_msg_get(data_key, recv_msg);
163 memset(&frame, 0x0, sizeof(camera_preview_data_s));
166 LOGE("invalid key %d", tbm_key);
170 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
172 if (num_buffer_key < 0 || num_buffer_key > BUFFER_MAX_PLANE_NUM) {
173 LOGE("invalid num buffer key %d", num_buffer_key);
174 goto _PREVIEW_CB_HANDLER_DONE;
178 /* import tbm data_bo and get virtual address */
179 if (!_camera_import_tbm_key(cb_info->bufmgr, data_key, &data_bo, &data_bo_handle)) {
180 LOGE("failed to import data key %d", data_key);
181 goto _PREVIEW_CB_HANDLER_DONE;
185 /* import tbm bo and get virtual address */
186 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
187 LOGE("failed to import key %d", tbm_key);
188 goto _PREVIEW_CB_HANDLER_DONE;
191 buf_pos = (unsigned char *)bo_handle.ptr;
193 /* get stream info */
194 stream = (camera_stream_data_s *)buf_pos;
196 for (i = 0 ; i < num_buffer_key ; i++) {
197 /* import buffer bo and get virtual address */
198 if (!_camera_import_tbm_key(cb_info->bufmgr, buffer_key[i], &buffer_bo[i], &buffer_bo_handle[i])) {
199 LOGE("failed to import buffer key %d", buffer_key[i]);
200 goto _PREVIEW_CB_HANDLER_DONE;
204 /* call preview callback */
205 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
206 _camera_preview_frame_create(stream, num_buffer_key, buffer_bo_handle, &data_bo_handle, &frame);
208 ((camera_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW])(&frame,
209 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
212 if (CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS)) {
213 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
215 if (ret == CAMERA_ERROR_NONE) {
216 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt_evas);
217 if (ret != CAMERA_ERROR_NONE) {
218 LOGE("create pkt for evas failed");
219 _camera_media_packet_data_release(mp_data, cb_info);
225 /* call media packet callback */
226 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
227 ret = _camera_media_packet_data_create(tbm_key, num_buffer_key, bo, buffer_bo, data_bo, &mp_data);
229 if (ret == CAMERA_ERROR_NONE) {
230 ret = _camera_media_packet_create(cb_info, stream, mp_data, &pkt);
232 if (ret == CAMERA_ERROR_NONE) {
233 ((camera_media_packet_preview_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW])(pkt,
234 cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
236 _camera_media_packet_data_release(mp_data, cb_info);
242 /* call evas renderer */
244 if (cb_info->run_evas_render) {
245 mm_display_interface_evas_render(cb_info->dp_interface, pkt_evas);
247 LOGW("evas renderer is stopped, skip this buffer...");
248 media_packet_destroy(pkt_evas);
253 /* send message for preview callback return */
254 if (!CHECK_PREVIEW_CB(cb_info, PREVIEW_CB_TYPE_EVAS))
255 _camera_msg_send(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info, NULL, 0);
257 _PREVIEW_CB_HANDLER_DONE:
258 if (mp_data == NULL) {
259 /* release imported bo */
260 for (i = 0 ; i < num_buffer_key && i < BUFFER_MAX_PLANE_NUM ; i++)
261 _camera_release_imported_bo(&buffer_bo[i]);
263 /* unmap and unref tbm bo */
264 _camera_release_imported_bo(&data_bo);
265 _camera_release_imported_bo(&bo);
268 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
270 /*LOGD("return buffer Done");*/
277 static void __camera_event_handler_capture(camera_cb_info_s *cb_info, char *recv_msg)
280 int tbm_key_main = 0;
281 int tbm_key_post = 0;
282 int tbm_key_thumb = 0;
283 unsigned char *buf_pos = NULL;
285 camera_msg_param param;
286 camera_image_data_s *rImage = NULL;
287 camera_image_data_s *rPostview = NULL;
288 camera_image_data_s *rThumbnail = NULL;
290 tbm_bo bo_main = NULL;
291 tbm_bo bo_post = NULL;
292 tbm_bo bo_thumb = NULL;
293 tbm_bo_handle bo_main_handle = {.ptr = NULL};
294 tbm_bo_handle bo_post_handle = {.ptr = NULL};
295 tbm_bo_handle bo_thumb_handle = {.ptr = NULL};
297 if (!cb_info || !recv_msg) {
298 LOGE("invalid param %p %p", cb_info, recv_msg);
302 muse_camera_msg_get(tbm_key_main, recv_msg);
303 muse_camera_msg_get(tbm_key_post, recv_msg);
304 muse_camera_msg_get(tbm_key_thumb, recv_msg);
307 LOGD("camera capture callback came in. tbm_key_main %d, tbm_key_post %d, tbm_key_thumb %d",
308 tbm_key_main, tbm_key_post, tbm_key_thumb);
311 if (tbm_key_main <= 0) {
312 LOGE("invalid key %d", tbm_key_main);
313 goto _CAPTURE_CB_HANDLER_DONE;
316 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] == NULL) {
317 LOGW("NULL callback");
318 goto _CAPTURE_CB_HANDLER_DONE;
321 /* import tbm bo and get virtual address */
322 if (!_camera_import_tbm_key(cb_info->bufmgr, tbm_key_main, &bo_main, &bo_main_handle)) {
323 LOGE("failed to import key [%d] for main", tbm_key_main);
324 goto _CAPTURE_CB_HANDLER_DONE;
327 buf_pos = (unsigned char *)bo_main_handle.ptr;
328 rImage = (camera_image_data_s *)buf_pos;
329 rImage->data = buf_pos + sizeof(camera_image_data_s);
330 if (rImage->exif && rImage->exif_size > 0) {
331 rImage->exif = rImage->data + rImage->size;
334 rImage->exif_size = 0;
337 LOGD("image info %dx%d, size %d, EXIF info %p, size %d",
338 rImage->width, rImage->height, rImage->size, rImage->exif, rImage->exif_size);
340 if (tbm_key_post > 0) {
341 /* import tbm bo and get virtual address */
342 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key_post, &bo_post, &bo_post_handle)) {
343 buf_pos = (unsigned char *)bo_post_handle.ptr;
344 rPostview = (camera_image_data_s *)buf_pos;
345 LOGD("rPostview->size : %d", rPostview->size);
346 rPostview->data = buf_pos + sizeof(camera_image_data_s);
348 LOGE("failed to import key [%d] for postview", tbm_key_post);
352 if (tbm_key_thumb > 0) {
353 /* import tbm bo and get virtual address */
354 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key_thumb, &bo_thumb, &bo_thumb_handle)) {
355 buf_pos = (unsigned char *)bo_thumb_handle.ptr;
356 rThumbnail = (camera_image_data_s *)buf_pos;
357 LOGD("rThumbnail->size : %d", rThumbnail->size);
358 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
360 LOGE("failed to import key [%d] for thumbnail", tbm_key_thumb);
364 ((camera_capturing_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE])(rImage,
365 rPostview, rThumbnail, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE]);
367 _CAPTURE_CB_HANDLER_DONE:
369 if (tbm_key_main > 0) {
370 _camera_release_imported_bo(&bo_main);
372 tbm_key = tbm_key_main;
373 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
375 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
378 if (tbm_key_post > 0) {
379 _camera_release_imported_bo(&bo_post);
381 tbm_key = tbm_key_post;
382 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
384 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
387 if (tbm_key_thumb > 0) {
388 _camera_release_imported_bo(&bo_thumb);
390 tbm_key = tbm_key_thumb;
391 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
393 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
396 LOGD("return buffer done");
402 static void __camera_event_handler_face_detection(camera_cb_info_s *cb_info, char *recv_msg)
406 camera_detected_face_s *faces = NULL;
407 camera_msg_param param;
410 tbm_bo_handle bo_handle = {.ptr = NULL};
412 if (!cb_info || !recv_msg) {
413 LOGE("invalid param %p %p", cb_info, recv_msg);
417 muse_camera_msg_get(count, recv_msg);
418 muse_camera_msg_get(tbm_key, recv_msg);
420 if (count >= 0 && cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]) {
421 LOGD("FACE_DETECTION - count %d, tbm_key %d", count, tbm_key);
425 if (_camera_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
427 faces = bo_handle.ptr;
431 ((camera_face_detected_cb)cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION])(faces,
432 count, cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
435 _camera_release_imported_bo(&bo);
437 LOGW("skip face detection message [count %d, key %d, cb %p",
438 count, tbm_key, cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
443 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
444 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
445 /*LOGD("return buffer done");*/
452 static int _camera_import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle)
454 tbm_bo tmp_bo = NULL;
455 tbm_bo_handle tmp_bo_handle = {NULL, };
457 if (!bufmgr || !bo || !bo_handle || !tbm_key) {
458 LOGE("invalid parameter - %p %p %p, key %d",
459 bufmgr, bo, bo_handle, tbm_key);
463 tmp_bo = tbm_bo_import(bufmgr, tbm_key);
464 if (tmp_bo == NULL) {
465 LOGE("import failed - key %d", tbm_key);
469 tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
470 if (tmp_bo_handle.ptr == NULL) {
471 LOGE("map failed %p", tmp_bo);
472 tbm_bo_unref(tmp_bo);
477 tbm_bo_unmap(tmp_bo);
479 /* set bo and bo_handle */
481 *bo_handle = tmp_bo_handle;
486 static void _camera_release_imported_bo(tbm_bo *bo)
499 static int _camera_client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
501 int ret = CAMERA_ERROR_NONE;
504 /*LOGD("Enter api : %d", api);*/
506 if (!cb_info->is_server_connected) {
507 LOGE("server is disconnected");
508 return CAMERA_ERROR_SERVICE_DISCONNECTED;
511 g_mutex_lock(&(cb_info->api_mutex[api]));
513 if (cb_info->api_activating[api] == 0) {
514 if (time_out == CAMERA_CB_NO_TIMEOUT) {
515 LOGW("wait for api %d", api);
516 g_cond_wait(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]));
517 ret = cb_info->api_ret[api];
518 cb_info->api_activating[api] = 0;
519 LOGW("api %d returned 0x%x", api, ret);
521 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
522 if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
523 ret = cb_info->api_ret[api];
524 cb_info->api_activating[api] = 0;
525 /*LOGD("return value : 0x%x", ret);*/
527 ret = CAMERA_ERROR_INVALID_OPERATION;
528 LOGE("api %d was TIMED OUT!", api);
532 ret = cb_info->api_ret[api];
533 cb_info->api_activating[api] = 0;
535 /*LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);*/
538 g_mutex_unlock(&(cb_info->api_mutex[api]));
540 if (ret != CAMERA_ERROR_NONE)
541 LOGE("api %d : error 0x%x", api, ret);
547 static void _camera_msg_send(int api, camera_cb_info_s *cb_info,
548 int *ret, int timeout)
554 LOGE("NULL info - api %d", api);
557 *ret = CAMERA_ERROR_INVALID_PARAMETER;
562 msg = muse_core_msg_new(api, NULL);
564 LOGE("msg failed: api %d", api);
567 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
572 /*LOGD("send msg %s", msg);*/
574 if (cb_info->is_server_connected) {
575 __camera_update_api_waiting(cb_info, api, 1);
577 g_mutex_lock(&cb_info->fd_lock);
578 send_ret = muse_core_msg_send(cb_info->fd, msg);
579 g_mutex_unlock(&cb_info->fd_lock);
583 LOGE("msg send failed");
585 *ret = CAMERA_ERROR_INVALID_OPERATION;
588 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
591 __camera_update_api_waiting(cb_info, api, -1);
593 muse_core_msg_free(msg);
599 static void _camera_msg_send_param1(int api, camera_cb_info_s *cb_info,
600 int *ret, camera_msg_param *param, int timeout)
605 if (!cb_info || !param) {
606 LOGE("invalid pointer : api %d - %p %p", api, cb_info, param);
609 *ret = CAMERA_ERROR_INVALID_PARAMETER;
614 /*LOGD("type %d, name %s", param->type, param->name);*/
616 switch (param->type) {
618 msg = muse_core_msg_new(api,
619 param->type, param->name, param->value.value_INT,
622 case MUSE_TYPE_STRING:
623 msg = muse_core_msg_new(api,
624 param->type, param->name, param->value.value_STRING,
628 LOGE("unknown type %d", param->type);
633 LOGE("msg failed: api %d", api);
636 *ret = CAMERA_ERROR_OUT_OF_MEMORY;
641 /*LOGD("send msg %s", msg);*/
643 if (cb_info->is_server_connected) {
644 __camera_update_api_waiting(cb_info, api, 1);
646 g_mutex_lock(&cb_info->fd_lock);
647 send_ret = muse_core_msg_send(cb_info->fd, msg);
648 g_mutex_unlock(&cb_info->fd_lock);
652 LOGE("msg send failed");
655 *ret = CAMERA_ERROR_INVALID_OPERATION;
658 *ret = _camera_client_wait_for_cb_return(api, cb_info, timeout);
661 __camera_update_api_waiting(cb_info, api, -1);
663 muse_core_msg_free(msg);
669 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
671 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
672 in_format >= MM_PIXEL_FORMAT_NUM ||
673 out_format == NULL) {
674 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
675 return CAMERA_ERROR_INVALID_PARAMETER;
679 case MM_PIXEL_FORMAT_NV12:
680 case MM_PIXEL_FORMAT_NV12T:
681 *out_format = TBM_FORMAT_NV12;
684 case MM_PIXEL_FORMAT_NV16:
685 *out_format = TBM_FORMAT_NV16;
687 case MM_PIXEL_FORMAT_NV21:
688 *out_format = TBM_FORMAT_NV21;
690 case MM_PIXEL_FORMAT_YUYV:
691 *out_format = TBM_FORMAT_YUYV;
693 case MM_PIXEL_FORMAT_UYVY:
694 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
695 *out_format = TBM_FORMAT_UYVY;
697 case MM_PIXEL_FORMAT_422P:
698 *out_format = TBM_FORMAT_YUV422;
700 case MM_PIXEL_FORMAT_I420:
701 *out_format = TBM_FORMAT_YUV420;
703 case MM_PIXEL_FORMAT_YV12:
704 *out_format = TBM_FORMAT_YVU420;
706 case MM_PIXEL_FORMAT_RGB565:
707 *out_format = TBM_FORMAT_RGB565;
709 case MM_PIXEL_FORMAT_RGB888:
710 *out_format = TBM_FORMAT_RGB888;
712 case MM_PIXEL_FORMAT_RGBA:
713 *out_format = TBM_FORMAT_RGBA8888;
715 case MM_PIXEL_FORMAT_ARGB:
716 *out_format = TBM_FORMAT_ARGB8888;
719 LOGE("invalid in_format %d", in_format);
720 return CAMERA_ERROR_INVALID_PARAMETER;
724 return CAMERA_ERROR_NONE;
728 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
730 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
731 in_format >= MM_PIXEL_FORMAT_NUM ||
733 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
734 return CAMERA_ERROR_INVALID_PARAMETER;
738 case MM_PIXEL_FORMAT_NV12:
739 case MM_PIXEL_FORMAT_NV12T:
740 *mimetype = MEDIA_FORMAT_NV12;
743 case MM_PIXEL_FORMAT_NV16:
744 *mimetype = MEDIA_FORMAT_NV16;
746 case MM_PIXEL_FORMAT_NV21:
747 *mimetype = MEDIA_FORMAT_NV21;
749 case MM_PIXEL_FORMAT_YUYV:
750 *mimetype = MEDIA_FORMAT_YUYV;
752 case MM_PIXEL_FORMAT_UYVY:
753 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
754 *mimetype = MEDIA_FORMAT_UYVY;
756 case MM_PIXEL_FORMAT_422P:
757 *mimetype = MEDIA_FORMAT_422P;
759 case MM_PIXEL_FORMAT_I420:
760 *mimetype = MEDIA_FORMAT_I420;
762 case MM_PIXEL_FORMAT_YV12:
763 *mimetype = MEDIA_FORMAT_YV12;
765 case MM_PIXEL_FORMAT_RGB565:
766 *mimetype = MEDIA_FORMAT_RGB565;
768 case MM_PIXEL_FORMAT_RGB888:
769 *mimetype = MEDIA_FORMAT_RGB888;
771 case MM_PIXEL_FORMAT_RGBA:
772 *mimetype = MEDIA_FORMAT_RGBA;
774 case MM_PIXEL_FORMAT_ARGB:
775 *mimetype = MEDIA_FORMAT_ARGB;
778 LOGE("invalid in_format %d", in_format);
779 return CAMERA_ERROR_INVALID_PARAMETER;
783 return CAMERA_ERROR_NONE;
786 static void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_key,
787 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame)
790 unsigned char *buf_pos = NULL;
792 if (stream == NULL || buffer_bo_handle == NULL || frame == NULL) {
793 LOGE("invalid parameter - stream:%p, buffer_bo_handle:%p", stream, buffer_bo_handle);
798 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
799 frame->format = MM_PIXEL_FORMAT_UYVY;
801 frame->format = stream->format;
803 frame->width = stream->width;
804 frame->height = stream->height;
805 frame->timestamp = stream->timestamp;
806 frame->num_of_planes = stream->num_planes;
808 if (num_buffer_key == 0) {
811 if (!data_bo_handle || !data_bo_handle->ptr) {
812 LOGE("NULL pointer");
816 buf_pos = data_bo_handle->ptr;
818 if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) {
819 frame->data.encoded_plane.data = buf_pos;
820 frame->data.encoded_plane.size = stream->data.encoded.length_data;
821 total_size = stream->data.encoded.length_data;
823 switch (stream->num_planes) {
825 frame->data.single_plane.yuv = buf_pos;
826 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
827 total_size = stream->data.yuv420.length_yuv;
830 frame->data.double_plane.y = buf_pos;
831 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
832 buf_pos += stream->data.yuv420sp.length_y;
833 frame->data.double_plane.uv = buf_pos;
834 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
835 total_size = stream->data.yuv420sp.length_y + \
836 stream->data.yuv420sp.length_uv;
839 frame->data.triple_plane.y = buf_pos;
840 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
841 buf_pos += stream->data.yuv420p.length_y;
842 frame->data.triple_plane.u = buf_pos;
843 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
844 buf_pos += stream->data.yuv420p.length_u;
845 frame->data.triple_plane.v = buf_pos;
846 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
847 total_size = stream->data.yuv420p.length_y + \
848 stream->data.yuv420p.length_u + \
849 stream->data.yuv420p.length_v;
858 switch (stream->num_planes) {
861 frame->data.single_plane.yuv = buffer_bo_handle[0].ptr;
862 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
863 total_size = stream->data.yuv420.length_yuv;
867 frame->data.double_plane.y = buffer_bo_handle[0].ptr;
868 if (stream->num_planes == (unsigned int)num_buffer_key)
869 frame->data.double_plane.uv = buffer_bo_handle[1].ptr;
871 frame->data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
872 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
873 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
874 total_size = stream->data.yuv420sp.length_y + \
875 stream->data.yuv420sp.length_uv;
879 frame->data.triple_plane.y = buffer_bo_handle[0].ptr;
880 if (stream->num_planes == (unsigned int)num_buffer_key) {
881 frame->data.triple_plane.u = buffer_bo_handle[1].ptr;
882 frame->data.triple_plane.v = buffer_bo_handle[2].ptr;
884 frame->data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y;
885 frame->data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u;
887 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
888 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
889 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
890 total_size = stream->data.yuv420p.length_y + \
891 stream->data.yuv420p.length_u + \
892 stream->data.yuv420p.length_v;
901 LOGD("format %d, %dx%d, size %d plane num %d",
902 frame.format, frame.width, frame.height, total_size, frame.num_of_planes);
908 static int _camera_media_packet_data_create(int tbm_key, int num_buffer_key, tbm_bo bo,
909 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
912 int ret = CAMERA_ERROR_NONE;
913 camera_media_packet_data *tmp_mp_data = NULL;
915 if (*mp_data == NULL) {
916 tmp_mp_data = g_new0(camera_media_packet_data, 1);
918 tmp_mp_data->tbm_key = tbm_key;
919 tmp_mp_data->num_buffer_key = num_buffer_key;
920 tmp_mp_data->bo = bo;
921 tmp_mp_data->data_bo = data_bo;
922 tmp_mp_data->ref_cnt++;
924 for (i = 0 ; i < num_buffer_key ; i++)
925 tmp_mp_data->buffer_bo[i] = buffer_bo[i];
927 *mp_data = tmp_mp_data;
928 /*LOGD("mp_data %p", tmp_mp_data);*/
930 ret = CAMERA_ERROR_OUT_OF_MEMORY;
931 LOGE("failed to alloc media packet data");
934 ((camera_media_packet_data *)*mp_data)->ref_cnt++;
940 static void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
944 camera_msg_param param;
946 if (!mp_data || !cb_info) {
947 LOGE("NULL pointer %p %p", mp_data, cb_info);
951 if (mp_data->ref_cnt > 1) {
953 LOGD("ref count %d", mp_data->ref_cnt);
955 /* release imported bo */
956 for (i = 0 ; i < mp_data->num_buffer_key ; i++) {
957 tbm_bo_unref(mp_data->buffer_bo[i]);
958 mp_data->buffer_bo[i] = NULL;
962 _camera_release_imported_bo(&mp_data->bo);
963 _camera_release_imported_bo(&mp_data->data_bo);
966 tbm_key = mp_data->tbm_key;
968 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
970 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
979 static int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
980 camera_media_packet_data *mp_data, media_packet_h *packet)
982 media_packet_h pkt = NULL;
983 bool make_pkt_fmt = false;
984 tbm_surface_h tsurf = NULL;
985 tbm_surface_info_s tsurf_info;
986 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
987 uint32_t bo_format = 0;
990 int num_buffer_key = 0;
991 tbm_bo *buffer_bo = NULL;
993 if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) {
994 LOGE("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p",
995 cb_info, stream, mp_data, packet);
996 return CAMERA_ERROR_INVALID_PARAMETER;
999 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
1000 buffer_bo = mp_data->buffer_bo;
1001 num_buffer_key = mp_data->num_buffer_key;
1003 /* create tbm surface */
1004 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
1005 tsurf_info.planes[i].stride = stream->stride[i];
1007 /* get tbm surface format */
1008 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
1009 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
1011 if (ret == CAMERA_ERROR_NONE) {
1012 tsurf_info.width = stream->width;
1013 tsurf_info.height = stream->height;
1014 tsurf_info.format = bo_format;
1015 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
1016 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
1018 if (num_buffer_key > 0) {
1019 switch (bo_format) {
1020 case TBM_FORMAT_NV12:
1021 case TBM_FORMAT_NV21:
1022 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1023 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1024 tsurf_info.planes[0].offset = 0;
1025 if (num_buffer_key == 1)
1026 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1027 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1030 case TBM_FORMAT_YUV420:
1031 case TBM_FORMAT_YVU420:
1032 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1033 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1034 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
1035 tsurf_info.planes[0].offset = 0;
1036 if (num_buffer_key == 1) {
1037 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1038 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1040 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1042 case TBM_FORMAT_UYVY:
1043 case TBM_FORMAT_YUYV:
1044 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
1045 tsurf_info.planes[0].offset = 0;
1046 tsurf_info.size = tsurf_info.planes[0].size;
1053 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_key);
1054 } else if (mp_data->data_bo) {
1056 switch (bo_format) {
1057 case TBM_FORMAT_NV12:
1058 case TBM_FORMAT_NV21:
1059 tsurf_info.planes[0].size = stream->width * stream->height;
1060 tsurf_info.planes[1].size = (tsurf_info.planes[0].size) >> 1;
1061 tsurf_info.planes[0].offset = 0;
1062 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1063 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1065 case TBM_FORMAT_YUV420:
1066 case TBM_FORMAT_YVU420:
1067 tsurf_info.planes[0].size = stream->width * stream->height;
1068 tsurf_info.planes[1].size = (stream->width >> 1) * (stream->height >> 1);
1069 tsurf_info.planes[2].size = tsurf_info.planes[1].size;
1070 tsurf_info.planes[0].offset = 0;
1071 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1072 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1073 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1075 case TBM_FORMAT_UYVY:
1076 case TBM_FORMAT_YUYV:
1077 tsurf_info.planes[0].size = (stream->width * stream->height) << 1;
1078 tsurf_info.planes[0].offset = 0;
1079 tsurf_info.size = tsurf_info.planes[0].size;
1085 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1);
1088 /*LOGD("tbm surface %p", tsurf);*/
1092 /* check media packet format */
1093 if (cb_info->pkt_fmt) {
1094 int pkt_fmt_width = 0;
1095 int pkt_fmt_height = 0;
1096 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
1098 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
1099 if (pkt_fmt_mimetype != mimetype ||
1100 pkt_fmt_width != stream->width ||
1101 pkt_fmt_height != stream->height) {
1102 LOGW("change fmt: current 0x%x, %dx%d",
1103 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
1104 media_format_unref(cb_info->pkt_fmt);
1105 cb_info->pkt_fmt = NULL;
1106 make_pkt_fmt = true;
1109 make_pkt_fmt = true;
1112 /* create packet format */
1114 LOGW("make new pkt_fmt - 0x%x, %dx%d", mimetype, stream->width, stream->height);
1115 ret = media_format_create(&cb_info->pkt_fmt);
1116 if (ret == MEDIA_FORMAT_ERROR_NONE) {
1117 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
1118 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
1119 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
1120 LOGW("media_format_set : 0x%x", ret);
1122 LOGW("media_format_create failed 0x%x", ret);
1126 /* create media packet */
1127 ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt,
1128 tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
1129 (void *)cb_info, &pkt);
1130 if (ret != MEDIA_PACKET_ERROR_NONE) {
1131 LOGE("media_packet_create failed 0x%x", ret);
1132 tbm_surface_destroy(tsurf);
1136 LOGE("tbm surface failed. %dx%d, format %d, num_buffer_key %d, data_bo %p",
1137 stream->width, stream->height, stream->format, num_buffer_key, mp_data->data_bo);
1141 /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
1142 /* set media packet data */
1143 ret = media_packet_set_extra(pkt, (void *)mp_data);
1144 if (ret != MEDIA_PACKET_ERROR_NONE) {
1145 LOGE("media_packet_set_extra failed");
1147 _camera_media_packet_data_release(mp_data, cb_info);
1150 media_packet_destroy(pkt);
1153 /* set timestamp : msec -> nsec */
1154 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
1155 LOGW("media_packet_set_pts failed");
1164 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
1167 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1168 camera_media_packet_data *mp_data = NULL;
1169 tbm_surface_h tsurf = NULL;
1171 if (!pkt || !cb_info) {
1172 LOGE("NULL pointer %p %p", pkt, cb_info);
1173 return MEDIA_PACKET_FINALIZE;
1176 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1177 if (ret != MEDIA_PACKET_ERROR_NONE) {
1178 LOGE("media_packet_get_extra failed 0x%x", ret);
1179 return MEDIA_PACKET_FINALIZE;
1182 /*LOGD("mp_data %p", mp_data);*/
1184 g_mutex_lock(&cb_info->mp_data_mutex);
1186 _camera_media_packet_data_release(mp_data, cb_info);
1189 g_mutex_unlock(&cb_info->mp_data_mutex);
1191 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1192 if (ret != MEDIA_PACKET_ERROR_NONE)
1193 LOGE("get tbm_surface failed 0x%x", ret);
1196 tbm_surface_destroy(tsurf);
1200 return MEDIA_PACKET_FINALIZE;
1203 static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event)
1208 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1209 LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event);
1213 /*LOGD("get camera msg %s, event %d", recv_msg, event);*/
1215 g_mutex_lock(&cb_info->user_cb_mutex[event]);
1217 if (cb_info->user_cb[event] == NULL) {
1218 if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
1219 event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
1220 event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
1221 event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1222 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1223 LOGW("NULL callback for event %d, return here", event);
1227 /* return buffer message should be sent for some events.
1228 - MUSE_CAMERA_EVENT_TYPE_PREVIEW
1229 - MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW
1230 - MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION
1231 - MUSE_CAMERA_EVENT_TYPE_CAPTURE
1236 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1242 muse_camera_msg_get(previous, recv_msg);
1243 muse_camera_msg_get(current, recv_msg);
1244 muse_camera_msg_get(by_policy, recv_msg);
1246 LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
1247 previous, current, by_policy);
1249 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1250 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1253 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1257 muse_camera_msg_get(state, recv_msg);
1259 LOGD("FOCUS state - %d", state);
1261 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1264 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1265 LOGD("CAPTURE_COMPLETED");
1266 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1268 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1269 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1270 __camera_event_handler_preview(cb_info, recv_msg);
1273 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1277 muse_camera_msg_get(percent, recv_msg);
1279 LOGD("HDR progress - %d %%", percent);
1281 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1284 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1290 muse_camera_msg_get(policy, recv_msg);
1291 muse_camera_msg_get(previous, recv_msg);
1292 muse_camera_msg_get(current, recv_msg);
1294 LOGW("INTERRUPTED - policy %d, state %d -> %d", policy, previous, current);
1296 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1297 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1300 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1305 muse_camera_msg_get(policy, recv_msg);
1306 muse_camera_msg_get(state, recv_msg);
1308 LOGW("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1310 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1311 (camera_state_e)state, cb_info->user_data[event]);
1314 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1315 __camera_event_handler_face_detection(cb_info, recv_msg);
1317 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1320 int current_state = 0;
1322 muse_camera_msg_get(error, recv_msg);
1323 muse_camera_msg_get(current_state, recv_msg);
1325 LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
1327 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1328 (camera_state_e)current_state, cb_info->user_data[event]);
1332 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1334 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1335 muse_camera_msg_get(param1, recv_msg);
1336 muse_camera_msg_get(param2, recv_msg);
1338 /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/
1340 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1341 cb_info->user_cb[event] = NULL;
1342 cb_info->user_data[event] = NULL;
1343 LOGW("stop foreach callback for event %d", event);
1346 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1348 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1350 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1352 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1354 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1356 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1358 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1360 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1362 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1364 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1366 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1368 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1370 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1373 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1375 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1376 muse_camera_msg_get(param1, recv_msg);
1378 /*LOGD("event %d SUPPORTED %d ", event, param1);*/
1380 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1381 cb_info->user_cb[event] = NULL;
1382 cb_info->user_data[event] = NULL;
1383 LOGW("stop foreach callback for event %d", event);
1387 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1388 __camera_event_handler_capture(cb_info, recv_msg);
1391 LOGW("unhandled event %d", event);
1395 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1400 static bool _camera_idle_event_callback(void *data)
1402 camera_cb_info_s *cb_info = NULL;
1403 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1405 if (cam_idle_event == NULL) {
1406 LOGE("cam_idle_event is NULL");
1411 g_mutex_lock(&cam_idle_event->event_mutex);
1413 cb_info = cam_idle_event->cb_info;
1414 if (cb_info == NULL) {
1415 LOGW("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1416 goto IDLE_EVENT_CALLBACK_DONE;
1419 /* remove event from list */
1420 g_mutex_lock(&cb_info->idle_event_mutex);
1422 if (cb_info->idle_event_list)
1423 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1425 /*LOGD("remove camera idle event %p, %p", cam_idle_event, cb_info->idle_event_list);*/
1426 g_mutex_unlock(&cb_info->idle_event_mutex);
1429 _camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
1431 /* send signal for waiting thread */
1432 g_cond_signal(&cb_info->idle_event_cond);
1434 IDLE_EVENT_CALLBACK_DONE:
1435 /* unlock and release event */
1436 g_mutex_unlock(&cam_idle_event->event_mutex);
1437 g_mutex_clear(&cam_idle_event->event_mutex);
1439 g_free(cam_idle_event);
1440 cam_idle_event = NULL;
1445 static void *_camera_msg_handler_func(gpointer data)
1449 camera_message_s *cam_msg = NULL;
1450 camera_idle_event_s *cam_idle_event = NULL;
1451 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1452 camera_cb_info_s *cb_info = NULL;
1454 if (!handler_info || !handler_info->cb_info) {
1455 LOGE("NULL handler %p", handler_info);
1459 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1460 type = handler_info->type;
1462 LOGD("t:%d start", type);
1464 g_mutex_lock(&handler_info->mutex);
1466 while (g_atomic_int_get(&handler_info->running)) {
1467 if (g_queue_is_empty(handler_info->queue)) {
1468 /*LOGD("t:%d signal wait...", type);*/
1469 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1470 /*LOGD("t:%d signal received", type);*/
1472 if (g_atomic_int_get(&handler_info->running) == 0) {
1473 LOGD("t:%d stop event thread", type);
1478 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1480 g_mutex_unlock(&handler_info->mutex);
1482 if (cam_msg == NULL) {
1483 LOGE("t:%d NULL message", type);
1484 g_mutex_lock(&handler_info->mutex);
1490 if (api < MUSE_CAMERA_API_MAX) {
1493 g_mutex_lock(&cb_info->api_mutex[api]);
1495 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1496 if (cb_info->api_waiting[api] > 0) {
1497 cb_info->api_ret[api] = ret;
1498 cb_info->api_activating[api] = 1;
1500 /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
1502 g_cond_signal(&cb_info->api_cond[api]);
1504 LOGW("no waiting for this api [%d]", api);
1507 LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1510 g_mutex_unlock(&cb_info->api_mutex[api]);
1511 } else if (api == MUSE_CAMERA_CB_EVENT) {
1512 switch (cam_msg->event_class) {
1513 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1514 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event);
1516 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1517 cam_idle_event = g_new0(camera_idle_event_s, 1);
1518 if (cam_idle_event == NULL) {
1519 LOGE("t:%d cam_idle_event alloc failed", type);
1523 cam_idle_event->event = cam_msg->event;
1524 cam_idle_event->cb_info = cb_info;
1525 g_mutex_init(&cam_idle_event->event_mutex);
1526 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg) - 1);
1528 /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, cam_msg->event, cam_idle_event);*/
1530 g_mutex_lock(&cb_info->idle_event_mutex);
1531 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1532 g_mutex_unlock(&cb_info->idle_event_mutex);
1534 g_idle_add_full(G_PRIORITY_DEFAULT,
1535 (GSourceFunc)_camera_idle_event_callback,
1536 (gpointer)cam_idle_event,
1540 LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
1544 LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1550 g_mutex_lock(&handler_info->mutex);
1553 /* remove remained event */
1554 while (!g_queue_is_empty(handler_info->queue)) {
1555 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1557 LOGD("t:%d remove camera message %p", type, cam_msg);
1561 LOGW("t:%d NULL camera message", type);
1565 g_mutex_unlock(&handler_info->mutex);
1567 LOGD("t:%d return", type);
1573 static void _camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1575 camera_idle_event_s *cam_idle_event = NULL;
1577 gint64 end_time = 0;
1579 if (cb_info == NULL) {
1580 LOGE("cb_info is NULL");
1584 g_mutex_lock(&cb_info->idle_event_mutex);
1586 if (cb_info->idle_event_list == NULL) {
1587 LOGD("No remained idle event");
1588 g_mutex_unlock(&cb_info->idle_event_mutex);
1592 list = cb_info->idle_event_list;
1595 cam_idle_event = list->data;
1596 list = g_list_next(list);
1598 if (!cam_idle_event) {
1599 LOGW("Fail to remove idle event. The event is NULL");
1603 if (g_idle_remove_by_data(cam_idle_event)) {
1604 LOGW("remove idle event %p done", cam_idle_event);
1606 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1608 g_mutex_clear(&cam_idle_event->event_mutex);
1609 g_free(cam_idle_event);
1610 cam_idle_event = NULL;
1615 LOGW("remove idle event %p failed", cam_idle_event);
1617 if (!g_mutex_trylock(&cam_idle_event->event_mutex)) {
1618 LOGW("lock failed, %p event is calling now", cam_idle_event);
1620 end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
1622 if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
1623 LOGW("signal received");
1630 LOGW("set NULL cb_info for event %p %d, it will be freed on idle callback",
1631 cam_idle_event, cam_idle_event->event);
1633 cam_idle_event->cb_info = NULL;
1635 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1637 g_mutex_unlock(&cam_idle_event->event_mutex);
1640 g_list_free(cb_info->idle_event_list);
1641 cb_info->idle_event_list = NULL;
1643 g_mutex_unlock(&cb_info->idle_event_mutex);
1649 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg)
1651 camera_message_s *cam_msg = NULL;
1653 if (!cb_info || !msg) {
1654 LOGE("NULL pointer %p %p", cb_info, msg);
1658 cam_msg = g_new0(camera_message_s, 1);
1660 LOGE("failed to alloc cam_msg for [%s]", msg);
1665 cam_msg->event = event;
1666 cam_msg->event_class = event_class;
1668 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1670 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1672 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1673 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1674 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1675 g_cond_signal(&cb_info->preview_cb_info.cond);
1676 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1677 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1678 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1679 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1680 g_cond_signal(&cb_info->capture_cb_info.cond);
1681 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1683 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1684 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1685 g_cond_signal(&cb_info->msg_handler_info.cond);
1686 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1695 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg)
1697 int ret = CAMERA_ERROR_NONE;
1701 int event_class = -1;
1705 if (!cb_info || !msg) {
1706 LOGE("invalid ptr %p %p", cb_info, msg);
1710 /*LOGD("msg [%s]", msg);*/
1712 if (!muse_camera_msg_get(api, msg)) {
1713 LOGE("failed to get camera api");
1717 if (api == MUSE_CAMERA_CB_EVENT) {
1718 if (!muse_camera_msg_get(event, msg) ||
1719 !muse_camera_msg_get(event_class, msg)) {
1720 LOGE("failed to get camera event or event_class [%s]", msg);
1724 if (!muse_camera_msg_get(api_class, msg)) {
1725 LOGE("failed to get camera api_class [%s]", msg);
1730 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1731 if (api >= MUSE_CAMERA_API_MAX) {
1732 LOGE("invalid api %d", api);
1736 if (!muse_camera_msg_get(ret, msg)) {
1737 LOGE("failed to get camera ret");
1741 g_mutex_lock(&cb_info->api_mutex[api]);
1744 case MUSE_CAMERA_API_CREATE:
1745 if (ret != CAMERA_ERROR_NONE) {
1746 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1747 LOGE("camera create error 0x%x. close client cb handler", ret);
1750 case MUSE_CAMERA_API_DESTROY:
1751 if (ret == CAMERA_ERROR_NONE) {
1752 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1753 LOGD("camera destroy done. close client cb handler");
1757 muse_camera_msg_get(get_type, msg);
1758 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1759 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1760 muse_camera_msg_get(get_index, msg);
1763 case MUSE_CAMERA_GET_TYPE_INT:
1764 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
1766 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1767 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
1768 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
1770 case MUSE_CAMERA_GET_TYPE_ARRAY:
1771 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
1772 muse_core_msg_deserialize("get_value",
1773 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
1774 LOGD("get display roi %d,%d,%dx%d",
1775 cb_info->get_display_roi_area[0],
1776 cb_info->get_display_roi_area[1],
1777 cb_info->get_display_roi_area[2],
1778 cb_info->get_display_roi_area[3]);
1780 muse_core_msg_deserialize("get_value",
1781 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
1782 LOGD("get geotag %lf, %lf, %lf",
1783 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
1786 case MUSE_CAMERA_GET_TYPE_STRING:
1787 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
1790 LOGW("unknown type %d", get_type);
1797 if (cb_info->api_waiting[api] > 0) {
1798 cb_info->api_ret[api] = ret;
1799 cb_info->api_activating[api] = 1;
1801 g_cond_signal(&cb_info->api_cond[api]);
1803 LOGW("no waiting for this api [%d]", api);
1806 g_mutex_unlock(&cb_info->api_mutex[api]);
1807 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
1808 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg);
1810 LOGW("unknown camera api %d, class %d", api, api_class);
1817 static void *_camera_msg_recv_func(gpointer data)
1819 int recv_length = 0;
1820 int single_length = 0;
1821 int remained_length = 0;
1822 char *recv_msg = NULL;
1823 char *single_msg = NULL;
1824 char *remained_msg = NULL;
1828 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
1831 LOGE("cb_info NULL");
1835 LOGD("start - fd : %d", cb_info->fd);
1837 single_msg = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
1839 LOGE("single_msg malloc failed");
1843 recv_msg = cb_info->recv_msg;
1845 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
1846 recv_length = muse_core_msg_recv(cb_info->fd, recv_msg);
1847 if (recv_length <= 0) {
1848 cb_info->is_server_connected = FALSE;
1849 LOGE("receive msg failed - server disconnected");
1857 /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
1859 /* Need to split the combined entering msgs */
1860 for (cur_pos = 0 ; cur_pos < recv_length ; cur_pos++) {
1861 if (recv_msg[cur_pos] == '}') {
1862 single_length = cur_pos - prev_pos + 1;
1864 if (single_length < MUSE_CAMERA_MSG_MAX_LENGTH) {
1865 /* check remained msg */
1866 if (remained_length > 0) {
1868 strncpy(single_msg, remained_msg, remained_length);
1869 strncpy(single_msg + remained_length, recv_msg + prev_pos, single_length);
1870 single_msg[remained_length + single_length] = '\0';
1873 remained_msg = NULL;
1875 strncpy(single_msg, recv_msg + prev_pos, single_length);
1876 single_msg[single_length] = '\0';
1877 LOGE("lost msg [%s], skip...", single_msg);
1880 remained_length = 0;
1882 strncpy(single_msg, recv_msg + prev_pos, single_length);
1883 single_msg[single_length] = '\0';
1886 if (single_msg[0] == '{') {
1888 /*LOGD("splitted msg : [%s], Index : %d", single_msg, num_msg);*/
1889 /* process each message */
1890 __camera_process_msg(cb_info, single_msg);
1892 LOGE("invalid msg [%s]", single_msg);
1895 LOGE("too long message [len %d] skip...", single_length);
1898 prev_pos = cur_pos + 1;
1902 /* check incompleted message */
1903 if (recv_msg[recv_length - 1] != '}') {
1904 remained_length = recv_length - prev_pos;
1906 LOGW("incompleted message [len %d]", remained_length);
1910 remained_msg = NULL;
1913 remained_msg = (char *)malloc(remained_length + 1);
1915 strncpy(remained_msg, recv_msg + prev_pos, remained_length);
1916 remained_msg[remained_length] = '\0';
1918 LOGE("failed to alloc for remained msg");
1921 remained_length = 0;
1925 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
1927 if (!cb_info->is_server_connected) {
1928 char *error_msg = NULL;
1930 if (cb_info->fd < 0) {
1931 LOGE("fd is closed in client side");
1932 goto CB_HANDLER_EXIT;
1935 /* send error msg for server disconnection */
1936 error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
1937 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
1938 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
1942 LOGE("error_msg failed");
1943 goto CB_HANDLER_EXIT;
1946 __camera_add_msg_to_queue(cb_info,
1947 MUSE_CAMERA_CB_EVENT,
1948 MUSE_CAMERA_EVENT_TYPE_ERROR,
1949 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
1952 muse_core_msg_free(error_msg);
1955 LOGE("add error msg for service disconnection done");
1966 remained_msg = NULL;
1973 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
1974 int type, const char *thread_name, camera_cb_info_s *cb_info)
1976 if (!handler_info || !thread_name || !cb_info) {
1977 LOGE("t:%d NULL %p %p %p",
1978 type, handler_info, thread_name, cb_info);
1984 handler_info->type = type;
1985 handler_info->queue = g_queue_new();
1986 if (handler_info->queue == NULL) {
1987 LOGE("t:%d queue failed", type);
1991 g_mutex_init(&handler_info->mutex);
1992 g_cond_init(&handler_info->cond);
1994 handler_info->cb_info = (void *)cb_info;
1995 g_atomic_int_set(&handler_info->running, 1);
1997 handler_info->thread = g_thread_try_new(thread_name,
1998 _camera_msg_handler_func, (gpointer)handler_info, NULL);
1999 if (handler_info->thread == NULL) {
2000 LOGE("t:%d thread failed", type);
2002 g_mutex_clear(&handler_info->mutex);
2003 g_cond_clear(&handler_info->cond);
2004 g_queue_free(handler_info->queue);
2005 handler_info->queue = NULL;
2010 LOGD("t:%d done", type);
2016 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2020 if (!handler_info) {
2021 LOGE("NULL handler");
2025 if (!handler_info->thread) {
2026 LOGW("thread is not created");
2030 type = handler_info->type;
2032 LOGD("t:%d thread %p", type, handler_info->thread);
2034 g_mutex_lock(&handler_info->mutex);
2035 g_atomic_int_set(&handler_info->running, 0);
2036 g_cond_signal(&handler_info->cond);
2037 g_mutex_unlock(&handler_info->mutex);
2039 g_thread_join(handler_info->thread);
2040 handler_info->thread = NULL;
2042 g_mutex_clear(&handler_info->mutex);
2043 g_cond_clear(&handler_info->cond);
2044 g_queue_free(handler_info->queue);
2045 handler_info->queue = NULL;
2047 LOGD("t:%d done", type);
2053 static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
2055 camera_cb_info_s *cb_info = NULL;
2058 g_return_val_if_fail(sockfd > 0, NULL);
2060 cb_info = g_new0(camera_cb_info_s, 1);
2061 if (cb_info == NULL) {
2062 LOGE("cb_info failed");
2066 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2068 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2069 g_mutex_init(&cb_info->api_mutex[i]);
2070 g_cond_init(&cb_info->api_cond[i]);
2073 g_mutex_init(&cb_info->fd_lock);
2074 g_mutex_init(&cb_info->idle_event_mutex);
2075 g_cond_init(&cb_info->idle_event_cond);
2076 g_mutex_init(&cb_info->mp_data_mutex);
2078 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2079 g_mutex_init(&cb_info->user_cb_mutex[i]);
2081 /* message handler thread */
2082 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2083 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2084 LOGE("msg_handler_info failed");
2088 /* message handler thread for preview callback */
2089 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2090 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2091 LOGE("preview_cb_info failed");
2095 /* message handler thread for capture callback */
2096 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2097 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2098 LOGE("capture_cb_info failed");
2102 cb_info->fd = sockfd;
2103 cb_info->preview_cb_flag = 0;
2105 /* message receive thread */
2106 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2107 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2108 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2109 if (cb_info->msg_recv_thread == NULL) {
2110 LOGE("message receive thread creation failed");
2114 cb_info->is_server_connected = TRUE;
2120 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2121 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2122 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2124 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2125 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2127 g_mutex_clear(&cb_info->fd_lock);
2128 g_mutex_clear(&cb_info->idle_event_mutex);
2129 g_cond_clear(&cb_info->idle_event_cond);
2130 g_mutex_clear(&cb_info->mp_data_mutex);
2132 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2133 g_mutex_clear(&cb_info->api_mutex[i]);
2134 g_cond_clear(&cb_info->api_cond[i]);
2145 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2149 g_return_if_fail(cb_info != NULL);
2151 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2153 g_thread_join(cb_info->msg_recv_thread);
2154 cb_info->msg_recv_thread = NULL;
2156 LOGD("msg_recv thread removed");
2158 /* destroy msg handler threads */
2159 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2160 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2161 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2163 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2164 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2166 g_mutex_clear(&cb_info->fd_lock);
2167 g_mutex_clear(&cb_info->idle_event_mutex);
2168 g_cond_clear(&cb_info->idle_event_cond);
2169 g_mutex_clear(&cb_info->mp_data_mutex);
2171 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2172 g_mutex_clear(&cb_info->api_mutex[i]);
2173 g_cond_clear(&cb_info->api_cond[i]);
2176 if (cb_info->fd > -1) {
2177 muse_client_close(cb_info->fd);
2181 if (cb_info->bufmgr) {
2182 tbm_bufmgr_deinit(cb_info->bufmgr);
2183 cb_info->bufmgr = NULL;
2185 if (cb_info->pkt_fmt) {
2186 media_format_unref(cb_info->pkt_fmt);
2187 cb_info->pkt_fmt = NULL;
2190 if (cb_info->dp_interface) {
2191 mm_display_interface_deinit(cb_info->dp_interface);
2192 cb_info->dp_interface = NULL;
2195 cb_info->preview_cb_flag = 0;
2204 int _camera_start_evas_rendering(camera_h camera)
2206 camera_cli_s *pc = (camera_cli_s *)camera;
2208 if (!pc || !pc->cb_info) {
2209 LOGE("NULL handle");
2210 return CAMERA_ERROR_INVALID_PARAMETER;
2215 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2216 LOGE("EVAS surface is not set");
2217 return CAMERA_ERROR_NONE;
2220 /* set evas render flag as RUN */
2221 pc->cb_info->run_evas_render = true;
2223 return CAMERA_ERROR_NONE;
2227 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2229 int ret = CAMERA_ERROR_NONE;
2230 camera_cli_s *pc = (camera_cli_s *)camera;
2232 if (!pc || !pc->cb_info) {
2233 LOGE("NULL handle");
2234 return CAMERA_ERROR_INVALID_PARAMETER;
2237 LOGD("stop - keep screen %d", keep_screen);
2239 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2240 LOGE("EVAS surface is not set");
2241 return CAMERA_ERROR_NONE;
2244 /* set evas render flag as STOP and release buffers */
2245 pc->cb_info->run_evas_render = false;
2247 ret = mm_display_interface_evas_flush(pc->cb_info->dp_interface, keep_screen);
2248 if (ret == MM_ERROR_NONE) {
2249 ret = CAMERA_ERROR_NONE;
2251 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2252 ret = CAMERA_ERROR_INVALID_OPERATION;
2259 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2261 int ret = CAMERA_ERROR_NONE;
2264 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2266 /* create muse connection */
2267 if (!key || !value) {
2268 LOGE("NULL pointer");
2269 return CAMERA_ERROR_INVALID_PARAMETER;
2272 sock_fd = muse_client_new();
2274 LOGE("muse_client_new failed");
2275 return CAMERA_ERROR_INVALID_OPERATION;
2278 msg = muse_core_msg_new(api,
2279 MUSE_TYPE_INT, "module", MUSE_CAMERA,
2280 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2284 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2288 ret = muse_core_msg_send(sock_fd, msg);
2290 muse_core_msg_free(msg);
2294 LOGE("send msg failed");
2295 ret = CAMERA_ERROR_INVALID_OPERATION;
2299 ret = muse_core_msg_recv(sock_fd, recv_msg);
2301 LOGE("recv msg failed %d", errno);
2302 ret = CAMERA_ERROR_INVALID_OPERATION;
2306 if (!muse_camera_msg_get(ret, recv_msg)) {
2307 LOGE("failed to get return value from msg [%s]", recv_msg);
2308 ret = CAMERA_ERROR_INVALID_OPERATION;
2312 if (ret == CAMERA_ERROR_NONE)
2313 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2315 LOGD("api %d - value %d", api, *value);
2319 muse_client_close(sock_fd);
2327 int camera_create(camera_device_e device, camera_h *camera)
2330 char *send_msg = NULL;
2332 int ret = CAMERA_ERROR_NONE;
2334 camera_cli_s *pc = NULL;
2335 tbm_bufmgr bufmgr = NULL;
2337 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2338 muse_core_api_module_e muse_module = MUSE_CAMERA;
2339 int device_type = (int)device;
2342 LOGE("NULL pointer");
2343 return CAMERA_ERROR_INVALID_PARAMETER;
2346 sock_fd = muse_client_new();
2348 LOGE("muse_client_new failed - returned fd %d", sock_fd);
2349 ret = CAMERA_ERROR_INVALID_OPERATION;
2355 send_msg = muse_core_msg_new(api,
2356 MUSE_TYPE_INT, "module", muse_module,
2357 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2358 MUSE_TYPE_INT, "pid", pid,
2363 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2367 send_ret = muse_core_msg_send(sock_fd, send_msg);
2369 muse_core_msg_free(send_msg);
2373 LOGE("send msg failed %d", errno);
2374 ret = CAMERA_ERROR_INVALID_OPERATION;
2378 pc = g_new0(camera_cli_s, 1);
2380 LOGE("camera_cli_s alloc failed");
2381 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2385 bufmgr = tbm_bufmgr_init(-1);
2386 if (bufmgr == NULL) {
2387 LOGE("get tbm bufmgr failed");
2388 ret = CAMERA_ERROR_INVALID_OPERATION;
2392 pc->cb_info = _camera_client_callback_new(sock_fd);
2393 if (pc->cb_info == NULL) {
2394 LOGE("cb_info alloc failed");
2395 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2401 LOGD("cb info : %d", pc->cb_info->fd);
2403 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2405 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2407 if (ret == CAMERA_ERROR_NONE) {
2408 intptr_t handle = 0;
2409 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2411 LOGE("Receiving Handle Failed!!");
2412 ret = CAMERA_ERROR_INVALID_OPERATION;
2416 pc->remote_handle = handle;
2417 pc->cb_info->bufmgr = bufmgr;
2419 ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL);
2420 if (ret != CAMERA_ERROR_NONE) {
2421 LOGE("init display failed 0x%x", ret);
2425 LOGD("camera create 0x%x", pc->remote_handle);
2426 *camera = (camera_h)pc;
2435 tbm_bufmgr_deinit(bufmgr);
2440 muse_client_close(sock_fd);
2446 int temp_fd = pc->cb_info->fd;
2448 /* pc->cb_info->fd should be closed,
2449 because g_thread_join for msg_recv_thread is not returned
2450 in _camera_client_callback_destroy. */
2452 pc->cb_info->fd = -1;
2453 muse_client_close(temp_fd);
2456 _camera_client_callback_destroy(pc->cb_info);
2463 LOGE("camera create error : 0x%x", ret);
2470 int camera_change_device(camera_h camera, camera_device_e device)
2473 int ret = CAMERA_ERROR_NONE;
2474 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2475 camera_cli_s *pc = (camera_cli_s *)camera;
2476 camera_msg_param param;
2478 if (!pc || !pc->cb_info) {
2479 LOGE("NULL handle");
2480 return CAMERA_ERROR_INVALID_PARAMETER;
2483 CAMERA_MSG_PARAM_SET(param, INT, device);
2485 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2487 if (ret == CAMERA_ERROR_NONE) {
2488 /* reset callback and user data */
2489 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2490 pc->cb_info->user_cb[i] = NULL;
2491 pc->cb_info->user_data[i] = NULL;
2493 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
2500 int camera_destroy(camera_h camera)
2502 int ret = CAMERA_ERROR_NONE;
2503 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2504 camera_cli_s *pc = (camera_cli_s *)camera;
2506 if (!pc || !pc->cb_info) {
2507 LOGE("NULL handle");
2508 return CAMERA_ERROR_INVALID_PARAMETER;
2513 if (pc->cb_info->is_server_connected)
2514 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2516 LOGW("server disconnected. release resource without send message.");
2518 if (ret == CAMERA_ERROR_NONE) {
2519 _camera_deactivate_idle_event_all(pc->cb_info);
2520 _camera_client_callback_destroy(pc->cb_info);
2527 LOGD("ret : 0x%x", ret);
2532 int camera_start_preview(camera_h camera)
2534 int ret = CAMERA_ERROR_NONE;
2535 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2536 camera_cli_s *pc = (camera_cli_s *)camera;
2538 if (!pc || !pc->cb_info) {
2539 LOGE("NULL handle");
2540 return CAMERA_ERROR_INVALID_PARAMETER;
2545 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2546 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2547 ret = _camera_start_evas_rendering(camera);
2548 if (ret != CAMERA_ERROR_NONE) {
2549 LOGE("stop preview because of error");
2550 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, pc->cb_info, NULL, 0);
2554 LOGD("ret : 0x%x", ret);
2560 int camera_stop_preview(camera_h camera)
2562 int ret = CAMERA_ERROR_NONE;
2563 camera_cli_s *pc = (camera_cli_s *)camera;
2564 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2565 camera_state_e current_state = CAMERA_STATE_NONE;
2567 if (!pc || !pc->cb_info) {
2568 LOGE("NULL handle");
2569 return CAMERA_ERROR_INVALID_PARAMETER;
2575 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2576 ret = camera_get_state(camera, ¤t_state);
2577 if (ret != CAMERA_ERROR_NONE) {
2578 LOGE("failed to get current state 0x%x", ret);
2582 if (current_state == CAMERA_STATE_PREVIEW) {
2583 ret = _camera_stop_evas_rendering(camera, false);
2584 if (ret != CAMERA_ERROR_NONE)
2589 /* send stop preview message */
2590 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2592 if (ret != CAMERA_ERROR_NONE &&
2593 current_state == CAMERA_STATE_PREVIEW) {
2594 LOGW("restart evas rendering");
2595 _camera_start_evas_rendering(camera);
2598 LOGD("ret : 0x%x", ret);
2604 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2606 int ret = CAMERA_ERROR_NONE;
2607 camera_cli_s *pc = (camera_cli_s *)camera;
2608 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2610 if (!pc || !pc->cb_info) {
2611 LOGE("NULL handle");
2612 return CAMERA_ERROR_INVALID_PARAMETER;
2617 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2618 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2620 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2621 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2623 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2625 LOGD("ret : 0x%x", ret);
2631 bool camera_is_supported_continuous_capture(camera_h camera)
2633 int ret = CAMERA_ERROR_NONE;
2634 camera_cli_s *pc = (camera_cli_s *)camera;
2635 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2637 if (!pc || !pc->cb_info) {
2638 LOGE("NULL handle");
2639 return CAMERA_ERROR_INVALID_PARAMETER;
2644 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2647 LOGE("error is occurred 0x%x", ret);
2651 LOGD("ret : %d", ret);
2657 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)
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_CONTINUOUS_CAPTURE;
2662 camera_msg_param param;
2665 if (!pc || !pc->cb_info) {
2666 LOGE("NULL handle");
2667 return CAMERA_ERROR_INVALID_PARAMETER;
2672 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2673 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2675 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2676 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2678 value = (count << 16) | interval;
2679 CAMERA_MSG_PARAM_SET(param, INT, value);
2681 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2683 LOGD("ret : 0x%x", ret);
2689 int camera_stop_continuous_capture(camera_h camera)
2691 int ret = CAMERA_ERROR_NONE;
2692 camera_cli_s *pc = (camera_cli_s *)camera;
2693 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2695 if (!pc || !pc->cb_info) {
2696 LOGE("NULL handle");
2697 return CAMERA_ERROR_INVALID_PARAMETER;
2702 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2704 LOGD("ret : 0x%x", ret);
2710 bool camera_is_supported_face_detection(camera_h camera)
2712 int ret = CAMERA_ERROR_NONE;
2713 camera_cli_s *pc = (camera_cli_s *)camera;
2714 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2716 if (!pc || !pc->cb_info) {
2717 LOGE("NULL handle");
2718 return CAMERA_ERROR_INVALID_PARAMETER;
2723 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2726 LOGE("error is occurred 0x%x", ret);
2730 LOGD("ret : %d", ret);
2736 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2738 int ret = CAMERA_ERROR_NONE;
2739 camera_cli_s *pc = (camera_cli_s *)camera;
2740 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2742 if (!pc || !pc->cb_info) {
2743 LOGE("NULL handle");
2744 return CAMERA_ERROR_INVALID_PARAMETER;
2749 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2752 LOGE("error is occurred 0x%x", ret);
2756 LOGD("ret : %d", ret);
2762 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2764 int ret = CAMERA_ERROR_NONE;
2765 camera_cli_s *pc = (camera_cli_s *)camera;
2766 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2768 if (!pc || !pc->cb_info) {
2769 LOGE("NULL handle");
2770 return CAMERA_ERROR_INVALID_PARAMETER;
2775 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2778 LOGE("error is occurred 0x%x", ret);
2782 LOGD("ret : %d", ret);
2787 int camera_get_device_count(camera_h camera, int *device_count)
2789 int ret = CAMERA_ERROR_NONE;
2790 camera_cli_s *pc = (camera_cli_s *)camera;
2791 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2793 if (!pc || !pc->cb_info) {
2794 LOGE("NULL handle");
2795 return CAMERA_ERROR_INVALID_PARAMETER;
2800 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2802 if (ret == CAMERA_ERROR_NONE)
2803 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2805 LOGD("ret : 0x%x", ret);
2810 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2812 int ret = CAMERA_ERROR_NONE;
2813 camera_cli_s *pc = (camera_cli_s *)camera;
2814 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2816 if (!pc || !pc->cb_info) {
2817 LOGE("NULL handle");
2818 return CAMERA_ERROR_INVALID_PARAMETER;
2823 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2825 if (ret == CAMERA_ERROR_NONE) {
2826 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2828 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2829 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2831 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2834 LOGD("ret : 0x%x", ret);
2839 int camera_stop_face_detection(camera_h camera)
2841 int ret = CAMERA_ERROR_NONE;
2842 camera_cli_s *pc = (camera_cli_s *)camera;
2843 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
2845 if (!pc || !pc->cb_info) {
2846 LOGE("NULL handle");
2847 return CAMERA_ERROR_INVALID_PARAMETER;
2852 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2854 if (ret == CAMERA_ERROR_NONE) {
2855 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2857 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
2858 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
2860 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2863 LOGD("ret : 0x%x", ret);
2868 int camera_get_state(camera_h camera, camera_state_e *state)
2870 int ret = CAMERA_ERROR_NONE;
2871 camera_cli_s *pc = (camera_cli_s *)camera;
2872 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
2874 if (!pc || !pc->cb_info || !state) {
2875 LOGE("NULL pointer %p %p", pc, state);
2876 return CAMERA_ERROR_INVALID_PARAMETER;
2881 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2883 if (ret == CAMERA_ERROR_NONE)
2884 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
2886 LOGD("ret : 0x%x", ret);
2891 int camera_start_focusing(camera_h camera, bool continuous)
2893 int ret = CAMERA_ERROR_NONE;
2894 camera_cli_s *pc = (camera_cli_s *)camera;
2895 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
2896 camera_msg_param param;
2897 int is_continuous = (int)continuous;
2899 if (!pc || !pc->cb_info) {
2900 LOGE("NULL handle");
2901 return CAMERA_ERROR_INVALID_PARAMETER;
2906 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
2908 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2910 LOGD("ret : 0x%x", ret);
2915 int camera_cancel_focusing(camera_h camera)
2917 int ret = CAMERA_ERROR_NONE;
2918 camera_cli_s *pc = (camera_cli_s *)camera;
2919 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
2921 if (!pc || !pc->cb_info) {
2922 LOGE("NULL handle");
2923 return CAMERA_ERROR_INVALID_PARAMETER;
2926 LOGD("Enter, remote_handle : %x", pc->remote_handle);
2928 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2930 LOGD("ret : 0x%x", ret);
2935 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
2937 int ret = CAMERA_ERROR_NONE;
2938 camera_cli_s *pc = (camera_cli_s *)camera;
2939 camera_cb_info_s *cb_info = NULL;
2940 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
2941 camera_state_e current_state = CAMERA_STATE_NONE;
2942 camera_msg_param param;
2946 if (!pc || !pc->cb_info) {
2947 LOGE("NULL handle");
2948 return CAMERA_ERROR_INVALID_PARAMETER;
2951 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
2952 LOGE("invalid type %d", type);
2953 return CAMERA_ERROR_INVALID_PARAMETER;
2956 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
2957 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
2958 return CAMERA_ERROR_INVALID_PARAMETER;
2961 cb_info = (camera_cb_info_s *)pc->cb_info;
2963 ret = camera_get_state(camera, ¤t_state);
2964 if (ret != CAMERA_ERROR_NONE) {
2965 LOGE("failed to get current state 0x%x", ret);
2969 if (current_state != CAMERA_STATE_CREATED) {
2970 LOGE("INVALID_STATE : current %d", current_state);
2971 return CAMERA_ERROR_INVALID_STATE;
2974 LOGD("Enter - display : %p", display);
2976 if (type == CAMERA_DISPLAY_TYPE_NONE) {
2977 LOGD("display type NONE");
2979 /* display interface handle */
2980 if (!cb_info->dp_interface) {
2981 if (mm_display_interface_init(&cb_info->dp_interface) != MM_ERROR_NONE) {
2982 LOGE("display interface init failed");
2983 return CAMERA_ERROR_NOT_SUPPORTED;
2987 ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &cb_info->parent_id);
2988 if (ret != MM_ERROR_NONE) {
2989 LOGE("[INVALID_OPERATION] set display failed[0x%x]", ret);
2990 return CAMERA_ERROR_INVALID_OPERATION;
2993 if (type == CAMERA_DISPLAY_TYPE_EVAS) {
2995 camera_flip_e flip = CAMERA_FLIP_NONE;
2996 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
2997 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
3004 camera_get_display_flip(camera, &flip);
3005 camera_get_display_mode(camera, &mode);
3006 camera_get_display_rotation(camera, &rotation);
3007 camera_is_display_visible(camera, &visible);
3008 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
3010 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
3011 flip, mode, rotation, visible, x, y, width, height);
3013 ret = mm_display_interface_evas_set_flip(cb_info->dp_interface, flip);
3014 ret |= mm_display_interface_evas_set_mode(cb_info->dp_interface, mode);
3015 ret |= mm_display_interface_evas_set_rotation(cb_info->dp_interface, rotation);
3016 ret |= mm_display_interface_evas_set_visible(cb_info->dp_interface, visible);
3018 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
3019 ret |= mm_display_interface_evas_set_roi_area(cb_info->dp_interface, x, y, width, height);
3024 if (type == CAMERA_DISPLAY_TYPE_OVERLAY) {
3027 length = sizeof(camera_wl_info_s) / sizeof(int) + \
3028 (sizeof(camera_wl_info_s) % sizeof(int) ? 1 : 0);
3030 msg = muse_core_msg_new(api,
3031 MUSE_TYPE_INT, "type", type,
3032 MUSE_TYPE_INT, "parent_id", cb_info->parent_id,
3035 LOGE("msg creation failed: api %d", api);
3036 return CAMERA_ERROR_OUT_OF_MEMORY;
3039 if (pc->cb_info->is_server_connected) {
3040 __camera_update_api_waiting(pc->cb_info, api, 1);
3042 g_mutex_lock(&pc->cb_info->fd_lock);
3043 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
3044 g_mutex_unlock(&pc->cb_info->fd_lock);
3048 LOGE("message send failed");
3049 ret = CAMERA_ERROR_INVALID_OPERATION;
3051 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
3054 __camera_update_api_waiting(pc->cb_info, api, -1);
3056 muse_core_msg_free(msg);
3058 CAMERA_MSG_PARAM_SET(param, INT, type);
3060 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3063 if (ret != CAMERA_ERROR_NONE)
3064 LOGE("set display error 0x%x", ret);
3065 else if (type == CAMERA_DISPLAY_TYPE_EVAS)
3066 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3072 int camera_set_preview_resolution(camera_h camera, int width, int height)
3074 int ret = CAMERA_ERROR_NONE;
3075 camera_state_e current_state = CAMERA_STATE_NONE;
3076 camera_cli_s *pc = (camera_cli_s *)camera;
3077 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3078 camera_msg_param param;
3081 if (!pc || !pc->cb_info) {
3082 LOGE("NULL handle");
3083 return CAMERA_ERROR_INVALID_PARAMETER;
3086 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3087 ret = camera_get_state(camera, ¤t_state);
3088 if (ret != CAMERA_ERROR_NONE) {
3089 LOGE("failed to get current state 0x%x", ret);
3093 if (current_state == CAMERA_STATE_PREVIEW) {
3094 ret = _camera_stop_evas_rendering(camera, true);
3095 if (ret != CAMERA_ERROR_NONE)
3100 value = (width << 16) | height;
3101 CAMERA_MSG_PARAM_SET(param, INT, value);
3103 LOGD("%dx%d -> 0x%x", width, height, value);
3105 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3107 LOGD("ret : 0x%x", ret);
3109 if (current_state == CAMERA_STATE_PREVIEW) {
3110 LOGW("restart evas rendering");
3111 _camera_start_evas_rendering(camera);
3118 int camera_set_capture_resolution(camera_h camera, int width, int height)
3120 int ret = CAMERA_ERROR_NONE;
3121 camera_cli_s *pc = (camera_cli_s *)camera;
3122 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3123 camera_msg_param param;
3126 if (!pc || !pc->cb_info) {
3127 LOGE("NULL handle");
3128 return CAMERA_ERROR_INVALID_PARAMETER;
3133 value = (width << 16) | height;
3134 CAMERA_MSG_PARAM_SET(param, INT, value);
3136 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3138 LOGD("ret : 0x%x", ret);
3144 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3146 int ret = CAMERA_ERROR_NONE;
3147 int set_format = (int)format;
3148 camera_cli_s *pc = (camera_cli_s *)camera;
3149 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3150 camera_msg_param param;
3152 if (!pc || !pc->cb_info) {
3153 LOGE("NULL handle");
3154 return CAMERA_ERROR_INVALID_PARAMETER;
3157 LOGD("Enter - format %d", set_format);
3159 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3161 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3163 LOGD("ret : 0x%x", ret);
3169 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3171 int ret = CAMERA_ERROR_NONE;
3172 int set_format = (int)format;
3173 camera_msg_param param;
3174 camera_cli_s *pc = (camera_cli_s *)camera;
3175 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3177 if (!pc || !pc->cb_info) {
3178 LOGE("NULL handle");
3179 return CAMERA_ERROR_INVALID_PARAMETER;
3182 LOGD("Enter - capture_format %d", set_format);
3184 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3186 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3188 LOGD("ret : 0x%x", ret);
3194 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3196 int ret = CAMERA_ERROR_NONE;
3197 camera_cli_s *pc = (camera_cli_s *)camera;
3198 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3200 if (!pc || !pc->cb_info || !width || !height) {
3201 LOGE("NULL pointer %p %p %p", pc, width, height);
3202 return CAMERA_ERROR_INVALID_PARAMETER;
3207 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3209 if (ret == CAMERA_ERROR_NONE) {
3210 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3211 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3214 LOGD("ret : 0x%x", ret);
3220 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3222 int ret = CAMERA_ERROR_NONE;
3223 int set_rotation = (int)rotation;
3224 camera_cli_s *pc = (camera_cli_s *)camera;
3225 camera_msg_param param;
3227 if (!pc || !pc->cb_info) {
3228 LOGE("NULL handle");
3229 return CAMERA_ERROR_INVALID_PARAMETER;
3232 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3233 ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
3234 if (ret != MM_ERROR_NONE) {
3235 LOGE("failed to set rotation for evas surface 0x%x", ret);
3236 return CAMERA_ERROR_INVALID_OPERATION;
3240 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3242 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3248 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3250 int ret = CAMERA_ERROR_NONE;
3251 camera_cli_s *pc = (camera_cli_s *)camera;
3253 if (!pc || !pc->cb_info || !rotation) {
3254 LOGE("NULL pointer %p %p", pc, rotation);
3255 return CAMERA_ERROR_INVALID_PARAMETER;
3258 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3260 if (ret == CAMERA_ERROR_NONE)
3261 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3267 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3269 int ret = CAMERA_ERROR_NONE;
3270 int set_flip = (int)flip;
3271 camera_cli_s *pc = (camera_cli_s *)camera;
3272 camera_msg_param param;
3274 if (!pc || !pc->cb_info) {
3275 LOGE("NULL handle");
3276 return CAMERA_ERROR_INVALID_PARAMETER;
3279 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3280 ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
3281 if (ret != MM_ERROR_NONE) {
3282 LOGE("failed to set flip for evas surface 0x%x", ret);
3283 return CAMERA_ERROR_INVALID_OPERATION;
3287 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3289 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3295 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3297 int ret = CAMERA_ERROR_NONE;
3298 camera_cli_s *pc = (camera_cli_s *)camera;
3300 if (!pc || !pc->cb_info || !flip) {
3301 LOGE("NULL pointer %p %p", pc, flip);
3302 return CAMERA_ERROR_INVALID_PARAMETER;
3305 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3307 if (ret == CAMERA_ERROR_NONE)
3308 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3314 int camera_set_display_visible(camera_h camera, bool visible)
3316 int ret = CAMERA_ERROR_NONE;
3317 int set_visible = (int)visible;
3318 camera_cli_s *pc = (camera_cli_s *)camera;
3319 camera_msg_param param;
3321 if (!pc || !pc->cb_info) {
3322 LOGE("NULL handle");
3323 return CAMERA_ERROR_INVALID_PARAMETER;
3326 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3327 ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
3328 if (ret != MM_ERROR_NONE) {
3329 LOGE("failed to set visible for evas surface 0x%x", ret);
3330 return CAMERA_ERROR_INVALID_OPERATION;
3334 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3336 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3342 int camera_is_display_visible(camera_h camera, bool *visible)
3344 int ret = CAMERA_ERROR_NONE;
3345 camera_cli_s *pc = (camera_cli_s *)camera;
3347 if (!pc || !pc->cb_info || !visible) {
3348 LOGE("NULL pointer %p %p", pc, visible);
3349 return CAMERA_ERROR_INVALID_PARAMETER;
3352 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3354 if (ret == CAMERA_ERROR_NONE)
3355 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3361 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3363 int ret = CAMERA_ERROR_NONE;
3364 int set_mode = (int)mode;
3365 camera_cli_s *pc = (camera_cli_s *)camera;
3366 camera_msg_param param;
3368 if (!pc || !pc->cb_info) {
3369 LOGE("NULL handle");
3370 return CAMERA_ERROR_INVALID_PARAMETER;
3373 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3374 ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
3375 if (ret != MM_ERROR_NONE) {
3376 LOGE("failed to set geometry for evas surface 0x%x", ret);
3377 return CAMERA_ERROR_INVALID_OPERATION;
3381 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3383 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3389 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3391 int ret = CAMERA_ERROR_NONE;
3392 camera_cli_s *pc = (camera_cli_s *)camera;
3394 if (!pc || !pc->cb_info || !mode) {
3395 LOGE("NULL pointer %p %p", pc, mode);
3396 return CAMERA_ERROR_INVALID_PARAMETER;
3399 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3401 if (ret == CAMERA_ERROR_NONE)
3402 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3408 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3410 int ret = CAMERA_ERROR_NONE;
3411 int set_hint = (int)hint;
3412 camera_cli_s *pc = (camera_cli_s *)camera;
3413 camera_msg_param param;
3415 if (!pc || !pc->cb_info) {
3416 LOGE("NULL handle");
3417 return CAMERA_ERROR_INVALID_PARAMETER;
3420 LOGD("Enter - hint %d", set_hint);
3422 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3424 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3430 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3432 int ret = CAMERA_ERROR_NONE;
3433 camera_cli_s *pc = (camera_cli_s *)camera;
3434 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3436 if (!pc || !pc->cb_info || !hint) {
3437 LOGE("NULL pointer %p %p", pc, hint);
3438 return CAMERA_ERROR_INVALID_PARAMETER;
3441 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3443 if (ret == CAMERA_ERROR_NONE) {
3444 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3445 LOGD("display reuse hint %d", *hint);
3452 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3454 int ret = CAMERA_ERROR_NONE;
3455 camera_cli_s *pc = (camera_cli_s *)camera;
3456 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3458 if (!pc || !pc->cb_info || !width || !height) {
3459 LOGE("NULL pointer %p %p %p", pc, width, height);
3460 return CAMERA_ERROR_INVALID_PARAMETER;
3465 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3467 if (ret == CAMERA_ERROR_NONE) {
3468 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3469 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3472 LOGD("ret : 0x%x", ret);
3478 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3480 int ret = CAMERA_ERROR_NONE;
3481 camera_cli_s *pc = (camera_cli_s *)camera;
3482 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3484 if (!pc || !pc->cb_info || !format) {
3485 LOGE("NULL pointer %p %p", pc, format);
3486 return CAMERA_ERROR_INVALID_PARAMETER;
3491 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3493 if (ret == CAMERA_ERROR_NONE)
3494 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3496 LOGD("ret : 0x%x", ret);
3502 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3504 int ret = CAMERA_ERROR_NONE;
3505 camera_cli_s *pc = (camera_cli_s *)camera;
3506 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3508 if (!pc || !pc->cb_info || !format) {
3509 LOGE("NULL pointer %p %p", pc, format);
3510 return CAMERA_ERROR_INVALID_PARAMETER;
3515 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3517 if (ret == CAMERA_ERROR_NONE)
3518 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3520 LOGD("ret : 0x%x", ret);
3526 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3528 int ret = CAMERA_ERROR_NONE;
3529 camera_cli_s *pc = (camera_cli_s *)camera;
3530 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3532 if (!pc || !pc->cb_info || !facing_direction) {
3533 LOGE("NULL pointer %p %p", pc, facing_direction);
3534 return CAMERA_ERROR_INVALID_PARAMETER;
3539 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3541 if (ret == CAMERA_ERROR_NONE)
3542 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3544 LOGD("ret : 0x%x", ret);
3550 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3552 int ret = CAMERA_ERROR_NONE;
3553 camera_cli_s *pc = (camera_cli_s *)camera;
3554 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3556 if (!pc || !pc->cb_info || !callback) {
3557 LOGE("NULL pointer %p %p", pc, callback);
3558 return CAMERA_ERROR_INVALID_PARAMETER;
3563 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3565 if (ret == CAMERA_ERROR_NONE) {
3566 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3568 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3569 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3571 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3573 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3576 LOGD("ret : 0x%x", ret);
3582 int camera_unset_preview_cb(camera_h camera)
3584 int ret = CAMERA_ERROR_NONE;
3585 camera_cli_s *pc = (camera_cli_s *)camera;
3586 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3588 if (!pc || !pc->cb_info) {
3589 LOGE("NULL handle");
3590 return CAMERA_ERROR_INVALID_PARAMETER;
3595 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3597 if (ret == CAMERA_ERROR_NONE) {
3598 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3600 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3601 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3603 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3605 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3608 LOGD("ret : 0x%x", ret);
3614 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3616 int ret = CAMERA_ERROR_NONE;
3617 camera_cli_s *pc = (camera_cli_s *)camera;
3618 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3620 if (!pc || !pc->cb_info) {
3621 LOGE("NULL handle");
3622 return CAMERA_ERROR_INVALID_PARAMETER;
3625 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3626 LOGE("NOT SUPPORTED");
3627 return CAMERA_ERROR_NOT_SUPPORTED;
3630 if (callback == NULL) {
3631 LOGE("NULL callback");
3632 return CAMERA_ERROR_INVALID_PARAMETER;
3637 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3639 if (ret == CAMERA_ERROR_NONE) {
3640 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3642 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3643 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3645 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3648 LOGD("ret : 0x%x", ret);
3654 int camera_unset_media_packet_preview_cb(camera_h camera)
3656 int ret = CAMERA_ERROR_NONE;
3657 camera_cli_s *pc = (camera_cli_s *)camera;
3658 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3660 if (!pc || !pc->cb_info) {
3661 LOGE("NULL handle");
3662 return CAMERA_ERROR_INVALID_PARAMETER;
3667 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3669 if (ret == CAMERA_ERROR_NONE) {
3670 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3672 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3673 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3675 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3678 LOGD("ret : 0x%x", ret);
3684 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3686 int ret = CAMERA_ERROR_NONE;
3687 camera_cli_s *pc = (camera_cli_s *)camera;
3688 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3690 if (!pc || !pc->cb_info || !callback) {
3691 LOGE("NULL pointer %p %p", pc, callback);
3692 return CAMERA_ERROR_INVALID_PARAMETER;
3697 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3699 if (ret == CAMERA_ERROR_NONE) {
3700 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3702 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3703 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3705 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3708 LOGD("ret : 0x%x", ret);
3714 int camera_unset_state_changed_cb(camera_h camera)
3716 int ret = CAMERA_ERROR_NONE;
3717 camera_cli_s *pc = (camera_cli_s *)camera;
3718 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3720 if (!pc || !pc->cb_info) {
3721 LOGE("NULL handle");
3722 return CAMERA_ERROR_INVALID_PARAMETER;
3727 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3729 if (ret == CAMERA_ERROR_NONE) {
3730 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3732 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3733 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3735 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3738 LOGD("ret : 0x%x", ret);
3744 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3746 int ret = CAMERA_ERROR_NONE;
3747 camera_cli_s *pc = (camera_cli_s *)camera;
3748 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3750 if (!pc || !pc->cb_info || !callback) {
3751 LOGE("NULL pointer %p %p", pc, callback);
3752 return CAMERA_ERROR_INVALID_PARAMETER;
3757 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3759 if (ret == CAMERA_ERROR_NONE) {
3760 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3762 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3763 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3765 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3768 LOGD("ret : 0x%x", ret);
3774 int camera_unset_interrupted_cb(camera_h camera)
3776 int ret = CAMERA_ERROR_NONE;
3777 camera_cli_s *pc = (camera_cli_s *)camera;
3778 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3780 if (!pc || !pc->cb_info) {
3781 LOGE("NULL handle");
3782 return CAMERA_ERROR_INVALID_PARAMETER;
3787 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3789 if (ret == CAMERA_ERROR_NONE) {
3790 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3792 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3793 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3795 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3798 LOGD("ret : 0x%x", ret);
3804 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
3806 int ret = CAMERA_ERROR_NONE;
3807 camera_cli_s *pc = (camera_cli_s *)camera;
3808 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
3810 if (!pc || !pc->cb_info || !callback) {
3811 LOGE("NULL pointer %p %p", pc, callback);
3812 return CAMERA_ERROR_INVALID_PARAMETER;
3817 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3819 if (ret == CAMERA_ERROR_NONE) {
3820 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3822 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
3823 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
3825 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3828 LOGD("ret : 0x%x", ret);
3834 int camera_unset_interrupt_started_cb(camera_h camera)
3836 int ret = CAMERA_ERROR_NONE;
3837 camera_cli_s *pc = (camera_cli_s *)camera;
3838 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
3840 if (!pc || !pc->cb_info) {
3841 LOGE("NULL handle");
3842 return CAMERA_ERROR_INVALID_PARAMETER;
3847 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3849 if (ret == CAMERA_ERROR_NONE) {
3850 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3852 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3853 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3855 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3858 LOGD("ret : 0x%x", ret);
3864 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
3866 int ret = CAMERA_ERROR_NONE;
3867 camera_cli_s *pc = (camera_cli_s *)camera;
3868 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3870 if (!pc || !pc->cb_info || !callback) {
3871 LOGE("NULL pointer %p %p", pc, callback);
3872 return CAMERA_ERROR_INVALID_PARAMETER;
3877 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3879 if (ret == CAMERA_ERROR_NONE) {
3880 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3882 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3883 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3885 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3888 LOGD("ret : 0x%x", ret);
3894 int camera_unset_focus_changed_cb(camera_h camera)
3896 int ret = CAMERA_ERROR_NONE;
3897 camera_cli_s *pc = (camera_cli_s *)camera;
3898 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
3900 if (!pc || !pc->cb_info) {
3901 LOGE("NULL handle");
3902 return CAMERA_ERROR_INVALID_PARAMETER;
3907 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3909 if (ret == CAMERA_ERROR_NONE) {
3910 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3912 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3913 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3915 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3918 LOGD("ret : 0x%x", ret);
3924 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
3926 int ret = CAMERA_ERROR_NONE;
3927 camera_cli_s *pc = (camera_cli_s *)camera;
3928 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
3930 if (!pc || !pc->cb_info || !callback) {
3931 LOGE("NULL pointer %p %p", pc, callback);
3932 return CAMERA_ERROR_INVALID_PARAMETER;
3937 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3939 if (ret == CAMERA_ERROR_NONE) {
3940 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3942 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
3943 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
3945 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3948 LOGD("ret : 0x%x", ret);
3954 int camera_unset_error_cb(camera_h camera)
3956 int ret = CAMERA_ERROR_NONE;
3957 camera_cli_s *pc = (camera_cli_s *)camera;
3958 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
3960 if (!pc || !pc->cb_info) {
3961 LOGE("NULL handle");
3962 return CAMERA_ERROR_INVALID_PARAMETER;
3967 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3969 if (ret == CAMERA_ERROR_NONE) {
3970 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3972 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
3973 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
3975 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3978 LOGD("ret : 0x%x", ret);
3984 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
3986 int ret = CAMERA_ERROR_NONE;
3987 camera_cli_s *pc = (camera_cli_s *)camera;
3988 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
3990 if (!pc || !pc->cb_info || !foreach_cb) {
3991 LOGE("NULL pointer %p %p", pc, foreach_cb);
3992 return CAMERA_ERROR_INVALID_PARAMETER;
3997 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
3998 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
4000 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4002 LOGD("ret : 0x%x", ret);
4008 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
4010 int ret = CAMERA_ERROR_NONE;
4011 camera_cli_s *pc = (camera_cli_s *)camera;
4012 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
4014 if (!pc || !pc->cb_info || !foreach_cb) {
4015 LOGE("NULL pointer %p %p", pc, foreach_cb);
4016 return CAMERA_ERROR_INVALID_PARAMETER;
4021 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
4022 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4024 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4026 LOGD("ret : 0x%x", ret);
4032 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4034 int ret = CAMERA_ERROR_NONE;
4035 camera_cli_s *pc = (camera_cli_s *)camera;
4036 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4038 if (!pc || !pc->cb_info || !foreach_cb) {
4039 LOGE("NULL pointer %p %p", pc, foreach_cb);
4040 return CAMERA_ERROR_INVALID_PARAMETER;
4045 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4046 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4048 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4050 LOGD("ret : 0x%x", ret);
4056 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4058 int ret = CAMERA_ERROR_NONE;
4059 camera_cli_s *pc = (camera_cli_s *)camera;
4060 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4062 if (!pc || !pc->cb_info || !foreach_cb) {
4063 LOGE("NULL pointer %p %p", pc, foreach_cb);
4064 return CAMERA_ERROR_INVALID_PARAMETER;
4069 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4070 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4072 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4074 LOGD("ret : 0x%x", ret);
4080 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4082 int ret = CAMERA_ERROR_NONE;
4083 camera_cli_s *pc = (camera_cli_s *)camera;
4084 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4086 if (!pc || !pc->cb_info || !width || !height) {
4087 LOGE("NULL pointer %p %p %p", pc, width, height);
4088 return CAMERA_ERROR_INVALID_PARAMETER;
4092 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4094 if (ret == CAMERA_ERROR_NONE) {
4095 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4096 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4099 LOGD("ret : 0x%x", ret);
4105 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4107 int ret = CAMERA_ERROR_NONE;
4108 camera_cli_s *pc = (camera_cli_s *)camera;
4109 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4111 if (!pc || !pc->cb_info || !angle) {
4112 LOGE("NULL pointer %p %p", pc, angle);
4113 return CAMERA_ERROR_INVALID_PARAMETER;
4118 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4120 if (ret == CAMERA_ERROR_NONE)
4121 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4123 LOGD("ret : 0x%x", ret);
4129 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4131 int ret = CAMERA_ERROR_NONE;
4132 camera_cli_s *pc = (camera_cli_s *)camera;
4133 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4134 camera_msg_param param;
4135 int set_mode = (int)mode;
4137 if (!pc || !pc->cb_info) {
4138 LOGE("NULL handle");
4139 return CAMERA_ERROR_INVALID_PARAMETER;
4144 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4146 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4148 LOGD("ret : 0x%x", ret);
4154 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4156 int ret = CAMERA_ERROR_NONE;
4157 camera_cli_s *pc = (camera_cli_s *)camera;
4158 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4160 if (!pc || !pc->cb_info || !mode) {
4161 LOGE("NULL pointer %p %p", pc, mode);
4162 return CAMERA_ERROR_INVALID_PARAMETER;
4167 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4169 if (ret == CAMERA_ERROR_NONE)
4170 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4172 LOGD("ret : 0x%x", ret);
4178 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4180 int ret = CAMERA_ERROR_NONE;
4181 camera_cli_s *pc = (camera_cli_s *)camera;
4182 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4184 if (!pc || !pc->cb_info || !foreach_cb) {
4185 LOGE("NULL pointer %p %p", pc, foreach_cb);
4186 return CAMERA_ERROR_INVALID_PARAMETER;
4191 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4192 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4194 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4196 LOGD("Finish, return :%x", ret);
4202 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4204 int ret = CAMERA_ERROR_NONE;
4205 camera_cli_s *pc = (camera_cli_s *)camera;
4206 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4207 camera_msg_param param;
4208 int set_fps = (int)fps;
4210 if (!pc || !pc->cb_info) {
4211 LOGE("NULL handle");
4212 return CAMERA_ERROR_INVALID_PARAMETER;
4217 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4219 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4221 LOGD("ret : 0x%x", ret);
4227 int camera_attr_set_image_quality(camera_h camera, int quality)
4229 int ret = CAMERA_ERROR_NONE;
4230 camera_cli_s *pc = (camera_cli_s *)camera;
4231 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4232 camera_msg_param param;
4234 if (!pc || !pc->cb_info) {
4235 LOGE("NULL handle");
4236 return CAMERA_ERROR_INVALID_PARAMETER;
4241 CAMERA_MSG_PARAM_SET(param, INT, quality);
4243 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4245 LOGD("ret : 0x%x", ret);
4251 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4253 int ret = CAMERA_ERROR_NONE;
4254 camera_cli_s *pc = (camera_cli_s *)camera;
4255 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4257 if (!pc || !pc->cb_info || !fps) {
4258 LOGE("NULL pointer %p %p", pc, fps);
4259 return CAMERA_ERROR_INVALID_PARAMETER;
4264 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4266 if (ret == CAMERA_ERROR_NONE)
4267 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4269 LOGD("ret : 0x%x", ret);
4275 int camera_attr_get_image_quality(camera_h camera, int *quality)
4277 int ret = CAMERA_ERROR_NONE;
4278 camera_cli_s *pc = (camera_cli_s *)camera;
4279 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4281 if (!pc || !pc->cb_info || !quality) {
4282 LOGE("NULL pointer %p %p", pc, quality);
4283 return CAMERA_ERROR_INVALID_PARAMETER;
4288 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4290 if (ret == CAMERA_ERROR_NONE)
4291 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4293 LOGD("ret : 0x%x", ret);
4299 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4301 int ret = CAMERA_ERROR_NONE;
4302 camera_cli_s *pc = (camera_cli_s *)camera;
4303 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4305 if (!pc || !pc->cb_info || !bitrate) {
4306 LOGE("NULL pointer %p %p", pc, bitrate);
4307 return CAMERA_ERROR_INVALID_PARAMETER;
4312 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4314 if (ret == CAMERA_ERROR_NONE)
4315 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4317 LOGD("ret : 0x%x", ret);
4323 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4325 int ret = CAMERA_ERROR_NONE;
4326 camera_cli_s *pc = (camera_cli_s *)camera;
4327 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4328 camera_msg_param param;
4329 int set_bitrate = bitrate;
4331 if (!pc || !pc->cb_info) {
4332 LOGE("NULL handle");
4333 return CAMERA_ERROR_INVALID_PARAMETER;
4338 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4340 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4342 LOGD("ret : 0x%x", ret);
4348 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4350 int ret = CAMERA_ERROR_NONE;
4351 camera_cli_s *pc = (camera_cli_s *)camera;
4352 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4354 if (!pc || !pc->cb_info || !interval) {
4355 LOGE("NULL pointer %p %p", pc, interval);
4356 return CAMERA_ERROR_INVALID_PARAMETER;
4361 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4363 if (ret == CAMERA_ERROR_NONE)
4364 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4366 LOGD("ret : 0x%x", ret);
4372 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4374 int ret = CAMERA_ERROR_NONE;
4375 camera_cli_s *pc = (camera_cli_s *)camera;
4376 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4377 camera_msg_param param;
4378 int set_gop_interval = interval;
4380 if (!pc || !pc->cb_info) {
4381 LOGE("NULL handle");
4382 return CAMERA_ERROR_INVALID_PARAMETER;
4387 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4389 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4391 LOGD("ret : 0x%x", ret);
4397 int camera_attr_set_zoom(camera_h camera, int zoom)
4399 int ret = CAMERA_ERROR_NONE;
4400 camera_cli_s *pc = (camera_cli_s *)camera;
4401 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4402 camera_msg_param param;
4404 if (!pc || !pc->cb_info) {
4405 LOGE("NULL handle");
4406 return CAMERA_ERROR_INVALID_PARAMETER;
4409 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4411 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4413 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4415 LOGD("ret : 0x%x", ret);
4421 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4423 int ret = CAMERA_ERROR_NONE;
4424 camera_cli_s *pc = (camera_cli_s *)camera;
4425 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4426 camera_msg_param param;
4427 int set_mode = (int)mode;
4429 if (!pc || !pc->cb_info) {
4430 LOGE("NULL handle");
4431 return CAMERA_ERROR_INVALID_PARAMETER;
4434 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4436 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4438 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4444 int camera_attr_set_af_area(camera_h camera, int x, int y)
4446 int ret = CAMERA_ERROR_NONE;
4447 camera_cli_s *pc = (camera_cli_s *)camera;
4448 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4449 camera_msg_param param;
4452 if (!pc || !pc->cb_info) {
4453 LOGE("NULL handle");
4454 return CAMERA_ERROR_INVALID_PARAMETER;
4457 LOGD("Enter - %d,%d", x, y);
4459 value = (x << 16) | y;
4460 CAMERA_MSG_PARAM_SET(param, INT, value);
4462 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4464 LOGD("ret : 0x%x", ret);
4470 int camera_attr_clear_af_area(camera_h camera)
4472 int ret = CAMERA_ERROR_NONE;
4473 camera_cli_s *pc = (camera_cli_s *)camera;
4474 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4476 if (!pc || !pc->cb_info) {
4477 LOGE("NULL handle");
4478 return CAMERA_ERROR_INVALID_PARAMETER;
4483 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4485 LOGD("ret : 0x%x", ret);
4491 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4493 int ret = CAMERA_ERROR_NONE;
4494 camera_cli_s *pc = (camera_cli_s *)camera;
4495 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4496 camera_msg_param param;
4497 int set_mode = (int)mode;
4499 if (!pc || !pc->cb_info) {
4500 LOGE("NULL handle");
4501 return CAMERA_ERROR_INVALID_PARAMETER;
4506 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4508 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4510 LOGD("ret : 0x%x", ret);
4516 int camera_attr_set_exposure(camera_h camera, int value)
4518 int ret = CAMERA_ERROR_NONE;
4519 camera_cli_s *pc = (camera_cli_s *)camera;
4520 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4521 camera_msg_param param;
4523 if (!pc || !pc->cb_info) {
4524 LOGE("NULL handle");
4525 return CAMERA_ERROR_INVALID_PARAMETER;
4530 CAMERA_MSG_PARAM_SET(param, INT, value);
4532 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4534 LOGD("ret : 0x%x", ret);
4540 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4542 int ret = CAMERA_ERROR_NONE;
4543 camera_cli_s *pc = (camera_cli_s *)camera;
4544 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4545 camera_msg_param param;
4546 int set_iso = (int)iso;
4548 if (!pc || !pc->cb_info) {
4549 LOGE("NULL handle");
4550 return CAMERA_ERROR_INVALID_PARAMETER;
4555 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4557 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4559 LOGD("ret : 0x%x", ret);
4565 int camera_attr_set_brightness(camera_h camera, int level)
4567 int ret = CAMERA_ERROR_NONE;
4568 camera_cli_s *pc = (camera_cli_s *)camera;
4569 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4570 camera_msg_param param;
4572 if (!pc || !pc->cb_info) {
4573 LOGE("NULL handle");
4574 return CAMERA_ERROR_INVALID_PARAMETER;
4579 CAMERA_MSG_PARAM_SET(param, INT, level);
4581 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4583 LOGD("ret : 0x%x", ret);
4589 int camera_attr_set_contrast(camera_h camera, int level)
4591 int ret = CAMERA_ERROR_NONE;
4592 camera_cli_s *pc = (camera_cli_s *)camera;
4593 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4594 camera_msg_param param;
4596 if (!pc || !pc->cb_info) {
4597 LOGE("NULL handle");
4598 return CAMERA_ERROR_INVALID_PARAMETER;
4603 CAMERA_MSG_PARAM_SET(param, INT, level);
4605 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4607 LOGD("ret : 0x%x", ret);
4613 int camera_attr_set_hue(camera_h camera, int level)
4615 int ret = CAMERA_ERROR_NONE;
4616 camera_cli_s *pc = (camera_cli_s *)camera;
4617 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HUE;
4618 camera_msg_param param;
4620 if (!pc || !pc->cb_info) {
4621 LOGE("NULL handle");
4622 return CAMERA_ERROR_INVALID_PARAMETER;
4627 CAMERA_MSG_PARAM_SET(param, INT, level);
4629 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4631 LOGD("ret : 0x%x", ret);
4637 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4639 int ret = CAMERA_ERROR_NONE;
4640 camera_cli_s *pc = (camera_cli_s *)camera;
4641 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4642 camera_msg_param param;
4643 int set_whitebalance = (int)wb;
4645 if (!pc || !pc->cb_info) {
4646 LOGE("NULL handle");
4647 return CAMERA_ERROR_INVALID_PARAMETER;
4652 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4654 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4656 LOGD("ret : 0x%x", ret);
4662 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4664 int ret = CAMERA_ERROR_NONE;
4665 camera_cli_s *pc = (camera_cli_s *)camera;
4666 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4667 camera_msg_param param;
4668 int set_effect = (int)effect;
4670 if (!pc || !pc->cb_info) {
4671 LOGE("NULL handle");
4672 return CAMERA_ERROR_INVALID_PARAMETER;
4677 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4679 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4681 LOGD("ret : 0x%x", ret);
4687 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4689 int ret = CAMERA_ERROR_NONE;
4690 camera_cli_s *pc = (camera_cli_s *)camera;
4691 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4692 camera_msg_param param;
4693 int set_mode = (int)mode;
4695 if (!pc || !pc->cb_info) {
4696 LOGE("NULL handle");
4697 return CAMERA_ERROR_INVALID_PARAMETER;
4702 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4704 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4706 LOGD("ret : 0x%x", ret);
4712 int camera_attr_enable_tag(camera_h camera, bool enable)
4714 int ret = CAMERA_ERROR_NONE;
4715 camera_cli_s *pc = (camera_cli_s *)camera;
4716 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4717 camera_msg_param param;
4718 int set_enable = (int)enable;
4720 if (!pc || !pc->cb_info) {
4721 LOGE("NULL handle");
4722 return CAMERA_ERROR_INVALID_PARAMETER;
4727 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4729 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4731 LOGD("ret : 0x%x", ret);
4737 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4739 int ret = CAMERA_ERROR_NONE;
4740 camera_cli_s *pc = (camera_cli_s *)camera;
4741 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4742 camera_msg_param param;
4744 if (!pc || !pc->cb_info || !description) {
4745 LOGE("NULL pointer %p %p", pc, description);
4746 return CAMERA_ERROR_INVALID_PARAMETER;
4751 CAMERA_MSG_PARAM_SET(param, STRING, description);
4753 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4755 LOGD("ret : 0x%x", ret);
4761 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4763 int ret = CAMERA_ERROR_NONE;
4764 camera_cli_s *pc = (camera_cli_s *)camera;
4765 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4766 camera_msg_param param;
4767 int set_orientation = (int)orientation;
4769 if (!pc || !pc->cb_info) {
4770 LOGE("NULL handle");
4771 return CAMERA_ERROR_INVALID_PARAMETER;
4776 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4778 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4780 LOGD("ret : 0x%x", ret);
4786 int camera_attr_set_tag_software(camera_h camera, const char *software)
4788 int ret = CAMERA_ERROR_NONE;
4789 camera_cli_s *pc = (camera_cli_s *)camera;
4790 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4791 camera_msg_param param;
4793 if (!pc || !pc->cb_info || !software) {
4794 LOGE("NULL pointer %p %p", pc, software);
4795 return CAMERA_ERROR_INVALID_PARAMETER;
4798 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4800 CAMERA_MSG_PARAM_SET(param, STRING, software);
4802 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4804 LOGD("ret : 0x%x", ret);
4810 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4812 int ret = CAMERA_ERROR_NONE;
4813 camera_cli_s *pc = (camera_cli_s *)camera;
4814 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4815 double set_geotag[3] = {latitude, longitude, altitude};
4820 if (!pc || !pc->cb_info) {
4821 LOGE("NULL handle");
4822 return CAMERA_ERROR_INVALID_PARAMETER;
4827 length = sizeof(set_geotag) / sizeof(int) + \
4828 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4830 msg = muse_core_msg_new(api,
4831 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4834 LOGE("msg creation failed: api %d", api);
4835 return CAMERA_ERROR_OUT_OF_MEMORY;
4838 if (pc->cb_info->is_server_connected) {
4839 __camera_update_api_waiting(pc->cb_info, api, 1);
4841 g_mutex_lock(&pc->cb_info->fd_lock);
4842 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
4843 g_mutex_unlock(&pc->cb_info->fd_lock);
4847 LOGE("message send failed");
4848 ret = CAMERA_ERROR_INVALID_OPERATION;
4850 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
4853 __camera_update_api_waiting(pc->cb_info, api, -1);
4855 muse_core_msg_free(msg);
4857 LOGD("ret : 0x%x", ret);
4863 int camera_attr_remove_geotag(camera_h camera)
4865 int ret = CAMERA_ERROR_NONE;
4866 camera_cli_s *pc = (camera_cli_s *)camera;
4867 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4869 if (!pc || !pc->cb_info) {
4870 LOGE("NULL handle");
4871 return CAMERA_ERROR_INVALID_PARAMETER;
4876 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4878 LOGD("ret : 0x%x", ret);
4884 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4886 int ret = CAMERA_ERROR_NONE;
4887 camera_cli_s *pc = (camera_cli_s *)camera;
4888 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
4889 camera_msg_param param;
4890 int set_mode = (int)mode;
4892 if (!pc || !pc->cb_info) {
4893 LOGE("NULL handle");
4894 return CAMERA_ERROR_INVALID_PARAMETER;
4899 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4901 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4903 LOGD("ret : 0x%x", ret);
4909 int camera_attr_get_zoom(camera_h camera, int *zoom)
4911 int ret = CAMERA_ERROR_NONE;
4912 camera_cli_s *pc = (camera_cli_s *)camera;
4913 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4915 if (!pc || !pc->cb_info || !zoom) {
4916 LOGE("NULL pointer %p %p", pc, zoom);
4917 return CAMERA_ERROR_INVALID_PARAMETER;
4922 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4924 if (ret == CAMERA_ERROR_NONE)
4925 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
4927 LOGD("ret : 0x%x", ret);
4933 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
4935 int ret = CAMERA_ERROR_NONE;
4936 camera_cli_s *pc = (camera_cli_s *)camera;
4937 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
4939 if (!pc || !pc->cb_info || !min || !max) {
4940 LOGE("NULL pointer %p %p %p", pc, min, max);
4941 return CAMERA_ERROR_INVALID_PARAMETER;
4946 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4948 if (ret == CAMERA_ERROR_NONE) {
4949 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
4950 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
4953 LOGD("ret : 0x%x", ret);
4959 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
4961 int ret = CAMERA_ERROR_NONE;
4962 camera_cli_s *pc = (camera_cli_s *)camera;
4963 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
4965 if (!pc || !pc->cb_info || !mode) {
4966 LOGE("NULL pointer %p %p", pc, mode);
4967 return CAMERA_ERROR_INVALID_PARAMETER;
4972 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4974 if (ret == CAMERA_ERROR_NONE)
4975 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
4977 LOGD("ret : 0x%x", ret);
4983 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
4985 int ret = CAMERA_ERROR_NONE;
4986 camera_cli_s *pc = (camera_cli_s *)camera;
4987 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
4989 if (!pc || !pc->cb_info || !mode) {
4990 LOGE("NULL pointer %p %p", pc, mode);
4991 return CAMERA_ERROR_INVALID_PARAMETER;
4996 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4998 if (ret == CAMERA_ERROR_NONE)
4999 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
5001 LOGD("ret : 0x%x", ret);
5007 int camera_attr_get_exposure(camera_h camera, int *value)
5009 int ret = CAMERA_ERROR_NONE;
5010 camera_cli_s *pc = (camera_cli_s *)camera;
5011 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
5013 if (!pc || !pc->cb_info || !value) {
5014 LOGE("NULL pointer %p %p", pc, value);
5015 return CAMERA_ERROR_INVALID_PARAMETER;
5020 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5022 if (ret == CAMERA_ERROR_NONE)
5023 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5025 LOGD("ret : 0x%x", ret);
5031 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5033 int ret = CAMERA_ERROR_NONE;
5034 camera_cli_s *pc = (camera_cli_s *)camera;
5035 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5037 if (!pc || !pc->cb_info || !min || !max) {
5038 LOGE("NULL pointer %p %p %p", pc, min, max);
5039 return CAMERA_ERROR_INVALID_PARAMETER;
5044 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5046 if (ret == CAMERA_ERROR_NONE) {
5047 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5048 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5051 LOGD("ret : 0x%x", ret);
5057 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5059 int ret = CAMERA_ERROR_NONE;
5060 camera_cli_s *pc = (camera_cli_s *)camera;
5061 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5063 if (!pc || !pc->cb_info || !iso) {
5064 LOGE("NULL pointer %p %p", pc, iso);
5065 return CAMERA_ERROR_INVALID_PARAMETER;
5070 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5072 if (ret == CAMERA_ERROR_NONE)
5073 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5075 LOGD("ret : 0x%x", ret);
5081 int camera_attr_get_brightness(camera_h camera, int *level)
5083 int ret = CAMERA_ERROR_NONE;
5084 camera_cli_s *pc = (camera_cli_s *)camera;
5085 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5087 if (!pc || !pc->cb_info || !level) {
5088 LOGE("NULL pointer %p %p", pc, level);
5089 return CAMERA_ERROR_INVALID_PARAMETER;
5094 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5096 if (ret == CAMERA_ERROR_NONE)
5097 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5099 LOGD("ret : 0x%x", ret);
5105 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5107 int ret = CAMERA_ERROR_NONE;
5108 camera_cli_s *pc = (camera_cli_s *)camera;
5109 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5111 if (!pc || !pc->cb_info || !min || !max) {
5112 LOGE("NULL pointer %p %p %p", pc, min, max);
5113 return CAMERA_ERROR_INVALID_PARAMETER;
5118 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5120 if (ret == CAMERA_ERROR_NONE) {
5121 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5122 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5125 LOGD("ret : 0x%x", ret);
5131 int camera_attr_get_contrast(camera_h camera, int *level)
5133 int ret = CAMERA_ERROR_NONE;
5134 camera_cli_s *pc = (camera_cli_s *)camera;
5135 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5137 if (!pc || !pc->cb_info || !level) {
5138 LOGE("NULL pointer %p %p", pc, level);
5139 return CAMERA_ERROR_INVALID_PARAMETER;
5144 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5146 if (ret == CAMERA_ERROR_NONE)
5147 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5149 LOGD("ret : 0x%x", ret);
5155 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5157 int ret = CAMERA_ERROR_NONE;
5158 camera_cli_s *pc = (camera_cli_s *)camera;
5159 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5161 if (!pc || !pc->cb_info || !min || !max) {
5162 LOGE("NULL pointer %p %p %p", pc, min, max);
5163 return CAMERA_ERROR_INVALID_PARAMETER;
5168 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5170 if (ret == CAMERA_ERROR_NONE) {
5171 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5172 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5173 LOGD("min %d, max %d", *min, *max);
5176 LOGD("ret : 0x%x", ret);
5182 int camera_attr_get_hue(camera_h camera, int *level)
5184 int ret = CAMERA_ERROR_NONE;
5185 camera_cli_s *pc = (camera_cli_s *)camera;
5186 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE;
5188 if (!pc || !pc->cb_info || !level) {
5189 LOGE("NULL pointer %p %p", pc, level);
5190 return CAMERA_ERROR_INVALID_PARAMETER;
5195 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5197 if (ret == CAMERA_ERROR_NONE)
5198 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HUE];
5200 LOGD("ret : 0x%x", ret);
5206 int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
5208 int ret = CAMERA_ERROR_NONE;
5209 camera_cli_s *pc = (camera_cli_s *)camera;
5210 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE_RANGE;
5212 if (!pc || !pc->cb_info || !min || !max) {
5213 LOGE("NULL pointer %p %p %p", pc, min, max);
5214 return CAMERA_ERROR_INVALID_PARAMETER;
5219 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5221 if (ret == CAMERA_ERROR_NONE) {
5222 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][0];
5223 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][1];
5224 LOGD("min %d, max %d", *min, *max);
5227 LOGD("ret : 0x%x", ret);
5233 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5235 int ret = CAMERA_ERROR_NONE;
5236 camera_cli_s *pc = (camera_cli_s *)camera;
5237 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5239 if (!pc || !pc->cb_info || !wb) {
5240 LOGE("NULL pointer %p %p", pc, wb);
5241 return CAMERA_ERROR_INVALID_PARAMETER;
5246 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5248 if (ret == CAMERA_ERROR_NONE)
5249 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5251 LOGD("ret : 0x%x", ret);
5257 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5259 int ret = CAMERA_ERROR_NONE;
5260 camera_cli_s *pc = (camera_cli_s *)camera;
5261 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5263 if (!pc || !pc->cb_info || !effect) {
5264 LOGE("NULL pointer %p %p", pc, effect);
5265 return CAMERA_ERROR_INVALID_PARAMETER;
5270 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5272 if (ret == CAMERA_ERROR_NONE)
5273 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5275 LOGD("ret : 0x%x", ret);
5281 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5283 int ret = CAMERA_ERROR_NONE;
5284 camera_cli_s *pc = (camera_cli_s *)camera;
5285 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5287 if (!pc || !pc->cb_info || !mode) {
5288 LOGE("NULL pointer %p %p", pc, mode);
5289 return CAMERA_ERROR_INVALID_PARAMETER;
5294 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5296 if (ret == CAMERA_ERROR_NONE)
5297 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5299 LOGD("ret : 0x%x", ret);
5305 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5307 int ret = CAMERA_ERROR_NONE;
5308 camera_cli_s *pc = (camera_cli_s *)camera;
5309 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5311 if (!pc || !pc->cb_info || !enable) {
5312 LOGE("NULL pointer %p %p", pc, enable);
5313 return CAMERA_ERROR_INVALID_PARAMETER;
5318 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5320 if (ret == CAMERA_ERROR_NONE)
5321 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5323 LOGD("ret : 0x%x", ret);
5329 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5331 int ret = CAMERA_ERROR_NONE;
5332 camera_cli_s *pc = (camera_cli_s *)camera;
5333 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5335 if (!pc || !pc->cb_info || !description) {
5336 LOGE("NULL pointer %p %p", pc, description);
5337 return CAMERA_ERROR_INVALID_PARAMETER;
5342 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5344 if (ret == CAMERA_ERROR_NONE)
5345 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5347 LOGD("ret : 0x%x", ret);
5353 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5355 int ret = CAMERA_ERROR_NONE;
5356 camera_cli_s *pc = (camera_cli_s *)camera;
5357 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5359 if (!pc || !pc->cb_info || !orientation) {
5360 LOGE("NULL pointer %p %p", pc, orientation);
5361 return CAMERA_ERROR_INVALID_PARAMETER;
5366 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5368 if (ret == CAMERA_ERROR_NONE)
5369 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5371 LOGD("ret : 0x%x", ret);
5377 int camera_attr_get_tag_software(camera_h camera, char **software)
5379 int ret = CAMERA_ERROR_NONE;
5380 camera_cli_s *pc = (camera_cli_s *)camera;
5381 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5383 if (!pc || !pc->cb_info || !software) {
5384 LOGE("NULL pointer %p %p", pc, software);
5385 return CAMERA_ERROR_INVALID_PARAMETER;
5390 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5392 if (ret == CAMERA_ERROR_NONE)
5393 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5395 LOGD("ret : 0x%x", ret);
5401 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5403 int ret = CAMERA_ERROR_NONE;
5404 camera_cli_s *pc = (camera_cli_s *)camera;
5405 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5407 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5408 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5409 return CAMERA_ERROR_INVALID_PARAMETER;
5414 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5416 if (ret == CAMERA_ERROR_NONE) {
5417 *latitude = pc->cb_info->get_geotag[0];
5418 *longitude = pc->cb_info->get_geotag[1];
5419 *altitude = pc->cb_info->get_geotag[2];
5422 LOGD("ret : 0x%x", ret);
5428 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5430 int ret = CAMERA_ERROR_NONE;
5431 camera_cli_s *pc = (camera_cli_s *)camera;
5432 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5434 if (!pc || !pc->cb_info || !mode) {
5435 LOGE("NULL pointer %p %p", pc, mode);
5436 return CAMERA_ERROR_INVALID_PARAMETER;
5441 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5443 if (ret == CAMERA_ERROR_NONE)
5444 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5446 LOGD("ret : 0x%x", ret);
5452 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5454 int ret = CAMERA_ERROR_NONE;
5455 int get_flash_state = 0;
5458 LOGE("NULL pointer");
5459 return CAMERA_ERROR_INVALID_PARAMETER;
5462 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5463 (int)device, "get_flash_state", &get_flash_state);
5465 if (ret == CAMERA_ERROR_NONE) {
5466 *state = (camera_flash_state_e)get_flash_state;
5467 LOGD("flash state %d", *state);
5469 LOGE("failed 0x%x", ret);
5476 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5478 int ret = CAMERA_ERROR_NONE;
5479 camera_cli_s *pc = (camera_cli_s *)camera;
5480 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5482 if (!pc || !pc->cb_info || !foreach_cb) {
5483 LOGE("NULL pointer %p %p", pc, foreach_cb);
5484 return CAMERA_ERROR_INVALID_PARAMETER;
5489 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5490 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5492 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5494 LOGD("ret : 0x%x", ret);
5500 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5502 int ret = CAMERA_ERROR_NONE;
5503 camera_cli_s *pc = (camera_cli_s *)camera;
5504 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5506 if (!pc || !pc->cb_info || !foreach_cb) {
5507 LOGE("NULL pointer %p %p", pc, foreach_cb);
5508 return CAMERA_ERROR_INVALID_PARAMETER;
5513 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5514 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5516 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5518 LOGD("ret : 0x%x", ret);
5524 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5526 int ret = CAMERA_ERROR_NONE;
5527 camera_cli_s *pc = (camera_cli_s *)camera;
5528 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5530 if (!pc || !pc->cb_info || !foreach_cb) {
5531 LOGE("NULL pointer %p %p", pc, foreach_cb);
5532 return CAMERA_ERROR_INVALID_PARAMETER;
5537 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5538 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5540 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5542 LOGD("ret : 0x%x", ret);
5548 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5550 int ret = CAMERA_ERROR_NONE;
5551 camera_cli_s *pc = (camera_cli_s *)camera;
5552 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5554 if (!pc || !pc->cb_info || !foreach_cb) {
5555 LOGE("NULL pointer %p %p", pc, foreach_cb);
5556 return CAMERA_ERROR_INVALID_PARAMETER;
5561 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5562 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5564 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5566 LOGD("ret : 0x%x", ret);
5572 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5574 int ret = CAMERA_ERROR_NONE;
5575 camera_cli_s *pc = (camera_cli_s *)camera;
5576 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5578 if (!pc || !pc->cb_info || !foreach_cb) {
5579 LOGE("NULL pointer %p %p", pc, foreach_cb);
5580 return CAMERA_ERROR_INVALID_PARAMETER;
5585 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5586 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5588 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5590 LOGD("ret : 0x%x", ret);
5596 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5598 int ret = CAMERA_ERROR_NONE;
5599 camera_cli_s *pc = (camera_cli_s *)camera;
5600 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5602 if (!pc || !pc->cb_info || !foreach_cb) {
5603 LOGE("NULL pointer %p %p", pc, foreach_cb);
5604 return CAMERA_ERROR_INVALID_PARAMETER;
5609 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5610 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5612 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5614 LOGD("ret : 0x%x", ret);
5620 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5622 int ret = CAMERA_ERROR_NONE;
5623 camera_cli_s *pc = (camera_cli_s *)camera;
5624 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5626 if (!pc || !pc->cb_info || !foreach_cb) {
5627 LOGE("NULL pointer %p %p", pc, foreach_cb);
5628 return CAMERA_ERROR_INVALID_PARAMETER;
5633 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5634 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5636 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5638 LOGD("ret : 0x%x", ret);
5644 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5646 int ret = CAMERA_ERROR_NONE;
5647 camera_cli_s *pc = (camera_cli_s *)camera;
5648 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5650 if (!pc || !pc->cb_info || !foreach_cb) {
5651 LOGE("NULL pointer %p %p", pc, foreach_cb);
5652 return CAMERA_ERROR_INVALID_PARAMETER;
5657 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5658 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5660 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5662 LOGD("Enter, handle :%x", pc->remote_handle);
5668 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)
5670 int ret = CAMERA_ERROR_NONE;
5671 camera_cli_s *pc = (camera_cli_s *)camera;
5672 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5673 camera_msg_param param;
5676 if (!pc || !pc->cb_info || !foreach_cb) {
5677 LOGE("NULL pointer %p %p", pc, foreach_cb);
5678 return CAMERA_ERROR_INVALID_PARAMETER;
5683 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5684 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5686 value = (width << 16) | height;
5687 CAMERA_MSG_PARAM_SET(param, INT, value);
5689 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5691 LOGD("ret : 0x%x", ret);
5697 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5699 int ret = CAMERA_ERROR_NONE;
5700 camera_cli_s *pc = (camera_cli_s *)camera;
5701 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5703 if (!pc || !pc->cb_info || !foreach_cb) {
5704 LOGE("NULL pointer %p %p", pc, foreach_cb);
5705 return CAMERA_ERROR_INVALID_PARAMETER;
5710 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5711 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5713 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5715 LOGD("ret : 0x%x", ret);
5721 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5723 int ret = CAMERA_ERROR_NONE;
5724 camera_cli_s *pc = (camera_cli_s *)camera;
5725 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5727 if (!pc || !pc->cb_info || !foreach_cb) {
5728 LOGE("NULL pointer %p %p", pc, foreach_cb);
5729 return CAMERA_ERROR_INVALID_PARAMETER;
5734 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5735 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5737 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5739 LOGD("ret : 0x%x", ret);
5745 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5747 int ret = CAMERA_ERROR_NONE;
5748 camera_cli_s *pc = (camera_cli_s *)camera;
5749 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5750 camera_msg_param param;
5751 int set_rotation = (int)rotation;
5753 if (!pc || !pc->cb_info) {
5754 LOGE("NULL handle");
5755 return CAMERA_ERROR_INVALID_PARAMETER;
5760 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5762 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5764 LOGD("ret : 0x%x", ret);
5770 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5772 int ret = CAMERA_ERROR_NONE;
5773 camera_cli_s *pc = (camera_cli_s *)camera;
5774 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5776 if (!pc || !pc->cb_info || !rotation) {
5777 LOGE("NULL pointer %p %p", pc, rotation);
5778 return CAMERA_ERROR_INVALID_PARAMETER;
5783 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5785 if (ret == CAMERA_ERROR_NONE)
5786 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5788 LOGD("ret : 0x%x", ret);
5794 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5796 int ret = CAMERA_ERROR_NONE;
5797 camera_cli_s *pc = (camera_cli_s *)camera;
5798 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5799 camera_msg_param param;
5800 int set_flip = (int)flip;
5802 if (!pc || !pc->cb_info) {
5803 LOGE("NULL handle");
5804 return CAMERA_ERROR_INVALID_PARAMETER;
5809 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5811 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5813 LOGD("ret : 0x%x", ret);
5819 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5821 int ret = CAMERA_ERROR_NONE;
5822 camera_cli_s *pc = (camera_cli_s *)camera;
5823 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5825 if (!pc || !pc->cb_info || !flip) {
5826 LOGE("NULL pointer %p %p", pc, flip);
5827 return CAMERA_ERROR_INVALID_PARAMETER;
5832 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5834 if (ret == CAMERA_ERROR_NONE)
5835 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5837 LOGD("ret : 0x%x", ret);
5842 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5844 int ret = CAMERA_ERROR_NONE;
5845 camera_cli_s *pc = (camera_cli_s *)camera;
5846 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5847 camera_msg_param param;
5848 int set_mode = (int)mode;
5850 if (!pc || !pc->cb_info) {
5851 LOGE("NULL handle");
5852 return CAMERA_ERROR_INVALID_PARAMETER;
5857 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5859 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5861 LOGD("ret : 0x%x", ret);
5867 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5869 int ret = CAMERA_ERROR_NONE;
5870 camera_cli_s *pc = (camera_cli_s *)camera;
5871 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5873 if (!pc || !pc->cb_info || !mode) {
5874 LOGE("NULL pointer %p %p", pc, mode);
5875 return CAMERA_ERROR_INVALID_PARAMETER;
5880 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5882 if (ret == CAMERA_ERROR_NONE)
5883 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
5885 LOGD("ret : 0x%x", ret);
5891 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5893 int ret = CAMERA_ERROR_NONE;
5894 camera_cli_s *pc = (camera_cli_s *)camera;
5895 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
5897 if (!pc || !pc->cb_info) {
5898 LOGE("NULL handle");
5899 return CAMERA_ERROR_INVALID_PARAMETER;
5904 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5907 LOGE("error is occurred 0x%x", ret);
5911 LOGD("ret : %d", ret);
5917 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5919 int ret = CAMERA_ERROR_NONE;
5920 camera_cli_s *pc = (camera_cli_s *)camera;
5921 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5923 if (!pc || !pc->cb_info) {
5924 LOGE("NULL handle");
5925 return CAMERA_ERROR_INVALID_PARAMETER;
5930 if (!camera_attr_is_supported_hdr_capture(camera)) {
5931 LOGE("HDR not supported");
5932 return CAMERA_ERROR_NOT_SUPPORTED;
5936 LOGE("NULL callback");
5937 return CAMERA_ERROR_INVALID_PARAMETER;
5940 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5942 if (ret == CAMERA_ERROR_NONE) {
5943 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5945 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5946 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5948 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5951 LOGD("ret : 0x%x", ret);
5957 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5959 int ret = CAMERA_ERROR_NONE;
5960 camera_cli_s *pc = (camera_cli_s *)camera;
5961 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5963 if (!pc || !pc->cb_info) {
5964 LOGE("NULL handle");
5965 return CAMERA_ERROR_INVALID_PARAMETER;
5970 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5972 if (ret == CAMERA_ERROR_NONE) {
5973 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5975 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5976 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5978 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5981 LOGD("ret : 0x%x", ret);
5987 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
5989 int ret = CAMERA_ERROR_NONE;
5990 camera_cli_s *pc = (camera_cli_s *)camera;
5991 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
5992 camera_msg_param param;
5993 int set_enable = (int)enable;
5995 if (!pc || !pc->cb_info) {
5996 LOGE("NULL handle");
5997 return CAMERA_ERROR_INVALID_PARAMETER;
6002 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6004 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6006 LOGD("ret : 0x%x", ret);
6012 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
6014 int ret = CAMERA_ERROR_NONE;
6015 camera_cli_s *pc = (camera_cli_s *)camera;
6016 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
6018 if (!pc || !pc->cb_info || !enabled) {
6019 LOGE("NULL pointer %p %p", pc, enabled);
6020 return CAMERA_ERROR_INVALID_PARAMETER;
6025 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6027 if (ret == CAMERA_ERROR_NONE)
6028 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6030 LOGD("ret : 0x%x", ret);
6036 bool camera_attr_is_supported_anti_shake(camera_h camera)
6038 int ret = CAMERA_ERROR_NONE;
6039 camera_cli_s *pc = (camera_cli_s *)camera;
6040 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6042 if (!pc || !pc->cb_info) {
6043 LOGE("NULL handle");
6044 return CAMERA_ERROR_INVALID_PARAMETER;
6049 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6052 LOGE("error is occurred 0x%x", ret);
6056 LOGD("ret : %d", ret);
6062 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6064 int ret = CAMERA_ERROR_NONE;
6065 camera_cli_s *pc = (camera_cli_s *)camera;
6066 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6067 camera_msg_param param;
6068 int set_enable = (int)enable;
6070 if (!pc || !pc->cb_info) {
6071 LOGE("NULL handle");
6072 return CAMERA_ERROR_INVALID_PARAMETER;
6077 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6079 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6081 LOGD("ret : 0x%x", ret);
6087 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6089 int ret = CAMERA_ERROR_NONE;
6090 camera_cli_s *pc = (camera_cli_s *)camera;
6091 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6093 if (!pc || !pc->cb_info || !enabled) {
6094 LOGE("NULL pointer %p %p", pc, enabled);
6095 return CAMERA_ERROR_INVALID_PARAMETER;
6100 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6102 if (ret == CAMERA_ERROR_NONE)
6103 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6105 LOGD("ret : 0x%x", ret);
6111 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6113 int ret = CAMERA_ERROR_NONE;
6114 camera_cli_s *pc = (camera_cli_s *)camera;
6115 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6117 if (!pc || !pc->cb_info) {
6118 LOGE("NULL handle");
6119 return CAMERA_ERROR_INVALID_PARAMETER;
6124 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6127 LOGE("error is occurred 0x%x", ret);
6131 LOGD("ret : %d", ret);
6137 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6139 int ret = CAMERA_ERROR_NONE;
6140 camera_cli_s *pc = (camera_cli_s *)camera;
6141 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6142 camera_msg_param param;
6143 int set_enable = (int)enable;
6145 if (!pc || !pc->cb_info) {
6146 LOGE("NULL handle");
6147 return CAMERA_ERROR_INVALID_PARAMETER;
6152 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6154 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6156 LOGD("ret : 0x%x", ret);
6162 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6164 int ret = CAMERA_ERROR_NONE;
6165 camera_cli_s *pc = (camera_cli_s *)camera;
6166 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6168 if (!pc || !pc->cb_info || !enabled) {
6169 LOGE("NULL pointer %p %p", pc, enabled);
6170 return CAMERA_ERROR_INVALID_PARAMETER;
6175 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6177 if (ret == CAMERA_ERROR_NONE)
6178 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6180 LOGD("ret : 0x%x", ret);
6186 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6188 int ret = CAMERA_ERROR_NONE;
6189 camera_cli_s *pc = (camera_cli_s *)camera;
6190 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6192 if (!pc || !pc->cb_info) {
6193 LOGE("NULL handle");
6194 return CAMERA_ERROR_INVALID_PARAMETER;
6199 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6202 LOGE("error is occurred 0x%x", ret);
6206 LOGD("ret : %d", ret);
6212 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6214 int ret = CAMERA_ERROR_NONE;
6215 camera_cli_s *pc = (camera_cli_s *)camera;
6216 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6217 camera_msg_param param;
6218 int set_disable = (int)disable;
6220 if (!pc || !pc->cb_info) {
6221 LOGE("NULL handle");
6222 return CAMERA_ERROR_INVALID_PARAMETER;
6227 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6229 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6231 LOGD("ret : 0x%x", ret);
6237 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6239 int ret = CAMERA_ERROR_NONE;
6240 camera_cli_s *pc = (camera_cli_s *)camera;
6241 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6242 camera_msg_param param;
6243 int set_move_type = (int)move_type;
6246 if (!pc || !pc->cb_info) {
6247 LOGE("NULL handle");
6248 return CAMERA_ERROR_INVALID_PARAMETER;
6253 value = (set_move_type << 16) | pan_step;
6254 CAMERA_MSG_PARAM_SET(param, INT, value);
6256 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6258 LOGD("ret : 0x%x", ret);
6264 int camera_attr_get_pan(camera_h camera, int *pan_step)
6266 int ret = CAMERA_ERROR_NONE;
6267 camera_cli_s *pc = (camera_cli_s *)camera;
6268 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6270 if (!pc || !pc->cb_info || !pan_step) {
6271 LOGE("NULL pointer %p %p", pc, pan_step);
6272 return CAMERA_ERROR_INVALID_PARAMETER;
6277 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6279 if (ret == CAMERA_ERROR_NONE)
6280 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6282 LOGD("ret : 0x%x", ret);
6288 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6290 int ret = CAMERA_ERROR_NONE;
6291 camera_cli_s *pc = (camera_cli_s *)camera;
6292 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6294 if (!pc || !pc->cb_info || !min || !max) {
6295 LOGE("NULL pointer %p %p %p", pc, min, max);
6296 return CAMERA_ERROR_INVALID_PARAMETER;
6301 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6303 if (ret == CAMERA_ERROR_NONE) {
6304 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6305 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6308 LOGD("ret : 0x%x", ret);
6314 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6316 int ret = CAMERA_ERROR_NONE;
6317 camera_cli_s *pc = (camera_cli_s *)camera;
6318 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6319 camera_msg_param param;
6320 int set_move_type = (int)move_type;
6323 if (!pc || !pc->cb_info) {
6324 LOGE("NULL handle");
6325 return CAMERA_ERROR_INVALID_PARAMETER;
6330 value = (set_move_type << 16) | tilt_step;
6331 CAMERA_MSG_PARAM_SET(param, INT, value);
6333 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6335 LOGD("ret : 0x%x", ret);
6341 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6343 int ret = CAMERA_ERROR_NONE;
6344 camera_cli_s *pc = (camera_cli_s *)camera;
6345 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6347 if (!pc || !pc->cb_info || !tilt_step) {
6348 LOGE("NULL pointer %p %p", pc, tilt_step);
6349 return CAMERA_ERROR_INVALID_PARAMETER;
6354 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6356 if (ret == CAMERA_ERROR_NONE)
6357 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6359 LOGD("ret : 0x%x", ret);
6365 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6367 int ret = CAMERA_ERROR_NONE;
6368 camera_cli_s *pc = (camera_cli_s *)camera;
6369 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6371 if (!pc || !pc->cb_info || !min || !max) {
6372 LOGE("NULL pointer %p %p %p", pc, min, max);
6373 return CAMERA_ERROR_INVALID_PARAMETER;
6378 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6380 if (ret == CAMERA_ERROR_NONE) {
6381 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6382 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6385 LOGD("ret : 0x%x", ret);
6391 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6393 int ret = CAMERA_ERROR_NONE;
6394 camera_cli_s *pc = (camera_cli_s *)camera;
6395 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6396 camera_msg_param param;
6397 int set_ptz_type = (int)ptz_type;
6399 if (!pc || !pc->cb_info) {
6400 LOGE("NULL handle");
6401 return CAMERA_ERROR_INVALID_PARAMETER;
6406 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6408 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6410 LOGD("ret : 0x%x", ret);
6416 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6418 int ret = CAMERA_ERROR_NONE;
6419 camera_cli_s *pc = (camera_cli_s *)camera;
6420 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6422 if (!pc || !pc->cb_info || !foreach_cb) {
6423 LOGE("NULL pointer %p %p", pc, foreach_cb);
6424 return CAMERA_ERROR_INVALID_PARAMETER;
6429 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6430 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6432 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6434 LOGD("ret : 0x%x", ret);
6440 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6442 int ret = CAMERA_ERROR_NONE;
6443 camera_cli_s *pc = (camera_cli_s *)camera;
6444 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6445 int set_display_roi_area[4] = {x, y, width, height};
6450 if (!pc || !pc->cb_info) {
6451 LOGE("NULL handle");
6452 return CAMERA_ERROR_INVALID_PARAMETER;
6457 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6458 ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
6459 if (ret != MM_ERROR_NONE) {
6460 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6461 return CAMERA_ERROR_INVALID_OPERATION;
6465 length = sizeof(set_display_roi_area) / sizeof(int) + \
6466 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6468 msg = muse_core_msg_new(api,
6469 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6472 LOGE("msg creation failed: api %d", api);
6473 return CAMERA_ERROR_OUT_OF_MEMORY;
6476 if (pc->cb_info->is_server_connected) {
6477 __camera_update_api_waiting(pc->cb_info, api, 1);
6479 g_mutex_lock(&pc->cb_info->fd_lock);
6480 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
6481 g_mutex_unlock(&pc->cb_info->fd_lock);
6485 LOGE("message send failed");
6486 ret = CAMERA_ERROR_INVALID_OPERATION;
6488 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6491 __camera_update_api_waiting(pc->cb_info, api, -1);
6493 muse_core_msg_free(msg);
6495 LOGD("ret : 0x%x", ret);
6501 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6503 camera_cli_s *pc = (camera_cli_s *)camera;
6504 int ret = CAMERA_ERROR_NONE;
6505 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6507 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6508 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6509 return CAMERA_ERROR_INVALID_PARAMETER;
6514 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6516 if (ret == CAMERA_ERROR_NONE) {
6517 *x = pc->cb_info->get_display_roi_area[0];
6518 *y = pc->cb_info->get_display_roi_area[1];
6519 *width = pc->cb_info->get_display_roi_area[2];
6520 *height = pc->cb_info->get_display_roi_area[3];
6523 LOGD("ret : 0x%x", ret);
6529 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6531 int ret = CAMERA_ERROR_NONE;
6532 int get_device_state = 0;
6535 LOGE("NULL pointer");
6536 return CAMERA_ERROR_INVALID_PARAMETER;
6539 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6540 (int)device, "get_device_state", &get_device_state);
6542 if (ret == CAMERA_ERROR_NONE) {
6543 *state = (camera_device_state_e)get_device_state;
6544 LOGD("device state %d", *state);
6546 LOGE("failed 0x%x", ret);
6553 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6555 int ret = CAMERA_ERROR_NONE;
6556 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6557 camera_cb_info *info = NULL;
6559 if (!callback || !cb_id) {
6560 LOGE("invalid pointer %p %p", callback, cb_id);
6561 return CAMERA_ERROR_INVALID_PARAMETER;
6564 /* check camera support */
6565 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6566 if (ret != CAMERA_ERROR_NONE) {
6567 LOGE("get device state failed");
6571 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6573 info = g_new0(camera_cb_info, 1);
6575 LOGE("info failed");
6576 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6580 info->id = ++g_cam_dev_state_changed_cb_id;
6581 info->callback = (void *)callback;
6582 info->user_data = user_data;
6586 /* subscribe dbus signal for camera state change */
6587 if (!g_cam_dev_state_changed_cb_conn) {
6588 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6589 if (!g_cam_dev_state_changed_cb_conn) {
6590 LOGE("failed to get gdbus connection");
6591 ret = CAMERA_ERROR_INVALID_OPERATION;
6595 LOGD("subscribe signal %s - %s - %s",
6596 MM_CAMCORDER_DBUS_OBJECT,
6597 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6598 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6600 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6601 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6602 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6603 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6604 LOGE("failed to get gdbus connection");
6605 ret = CAMERA_ERROR_INVALID_OPERATION;
6609 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6612 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6614 LOGD("callback id %d", info->id);
6617 if (ret != CAMERA_ERROR_NONE) {
6623 if (g_cam_dev_state_changed_cb_conn) {
6624 g_object_unref(g_cam_dev_state_changed_cb_conn);
6625 g_cam_dev_state_changed_cb_conn = NULL;
6629 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6635 int camera_remove_device_state_changed_cb(int cb_id)
6637 int ret = CAMERA_ERROR_NONE;
6638 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6639 GList *tmp_list = NULL;
6640 camera_cb_info *info = NULL;
6642 /* check camera support */
6643 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6644 if (ret != CAMERA_ERROR_NONE) {
6645 LOGE("get device state failed");
6649 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6651 if (!g_cam_dev_state_changed_cb_list) {
6652 LOGE("there is no callback info");
6653 ret = CAMERA_ERROR_INVALID_OPERATION;
6657 tmp_list = g_cam_dev_state_changed_cb_list;
6660 info = tmp_list->data;
6661 tmp_list = tmp_list->next;
6668 if (info->id == cb_id) {
6669 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6674 if (!g_cam_dev_state_changed_cb_list) {
6675 /* no remained callback */
6676 if (g_cam_dev_state_changed_cb_conn) {
6677 /* unsubscribe signal */
6678 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6679 g_cam_dev_state_changed_cb_subscribe_id = 0;
6681 /* unref connection */
6682 g_object_unref(g_cam_dev_state_changed_cb_conn);
6683 g_cam_dev_state_changed_cb_conn = NULL;
6687 LOGD("id %d callback removed", cb_id);
6688 ret = CAMERA_ERROR_NONE;
6694 LOGE("id %d callback not found", cb_id);
6695 ret = CAMERA_ERROR_INVALID_PARAMETER;
6698 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);