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;
683 case MM_PIXEL_FORMAT_NV16:
684 *out_format = TBM_FORMAT_NV16;
686 case MM_PIXEL_FORMAT_NV21:
687 *out_format = TBM_FORMAT_NV21;
689 case MM_PIXEL_FORMAT_YUYV:
690 *out_format = TBM_FORMAT_YUYV;
692 case MM_PIXEL_FORMAT_UYVY:
693 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
694 *out_format = TBM_FORMAT_UYVY;
696 case MM_PIXEL_FORMAT_422P:
697 *out_format = TBM_FORMAT_YUV422;
699 case MM_PIXEL_FORMAT_I420:
700 *out_format = TBM_FORMAT_YUV420;
702 case MM_PIXEL_FORMAT_YV12:
703 *out_format = TBM_FORMAT_YVU420;
705 case MM_PIXEL_FORMAT_RGB565:
706 *out_format = TBM_FORMAT_RGB565;
708 case MM_PIXEL_FORMAT_RGB888:
709 *out_format = TBM_FORMAT_RGB888;
711 case MM_PIXEL_FORMAT_RGBA:
712 *out_format = TBM_FORMAT_RGBA8888;
714 case MM_PIXEL_FORMAT_ARGB:
715 *out_format = TBM_FORMAT_ARGB8888;
718 LOGE("invalid in_format %d", in_format);
719 return CAMERA_ERROR_INVALID_PARAMETER;
722 return CAMERA_ERROR_NONE;
726 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
728 if (in_format <= MM_PIXEL_FORMAT_INVALID ||
729 in_format >= MM_PIXEL_FORMAT_NUM ||
731 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
732 return CAMERA_ERROR_INVALID_PARAMETER;
736 case MM_PIXEL_FORMAT_NV12:
737 case MM_PIXEL_FORMAT_NV12T:
738 *mimetype = MEDIA_FORMAT_NV12;
740 case MM_PIXEL_FORMAT_NV16:
741 *mimetype = MEDIA_FORMAT_NV16;
743 case MM_PIXEL_FORMAT_NV21:
744 *mimetype = MEDIA_FORMAT_NV21;
746 case MM_PIXEL_FORMAT_YUYV:
747 *mimetype = MEDIA_FORMAT_YUYV;
749 case MM_PIXEL_FORMAT_UYVY:
750 case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
751 *mimetype = MEDIA_FORMAT_UYVY;
753 case MM_PIXEL_FORMAT_422P:
754 *mimetype = MEDIA_FORMAT_422P;
756 case MM_PIXEL_FORMAT_I420:
757 *mimetype = MEDIA_FORMAT_I420;
759 case MM_PIXEL_FORMAT_YV12:
760 *mimetype = MEDIA_FORMAT_YV12;
762 case MM_PIXEL_FORMAT_RGB565:
763 *mimetype = MEDIA_FORMAT_RGB565;
765 case MM_PIXEL_FORMAT_RGB888:
766 *mimetype = MEDIA_FORMAT_RGB888;
768 case MM_PIXEL_FORMAT_RGBA:
769 *mimetype = MEDIA_FORMAT_RGBA;
771 case MM_PIXEL_FORMAT_ARGB:
772 *mimetype = MEDIA_FORMAT_ARGB;
775 LOGE("invalid in_format %d", in_format);
776 return CAMERA_ERROR_INVALID_PARAMETER;
779 return CAMERA_ERROR_NONE;
782 static void _camera_preview_frame_create(camera_stream_data_s *stream, int num_buffer_key,
783 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame)
786 unsigned char *buf_pos = NULL;
788 if (stream == NULL || buffer_bo_handle == NULL || frame == NULL) {
789 LOGE("invalid parameter - stream:%p, buffer_bo_handle:%p", stream, buffer_bo_handle);
794 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
795 frame->format = MM_PIXEL_FORMAT_UYVY;
797 frame->format = stream->format;
799 frame->width = stream->width;
800 frame->height = stream->height;
801 frame->timestamp = stream->timestamp;
802 frame->num_of_planes = stream->num_planes;
804 if (num_buffer_key == 0) {
806 if (!data_bo_handle || !data_bo_handle->ptr) {
807 LOGE("NULL pointer");
811 buf_pos = data_bo_handle->ptr;
813 if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) {
814 frame->data.encoded_plane.data = buf_pos;
815 frame->data.encoded_plane.size = stream->data.encoded.length_data;
816 total_size = stream->data.encoded.length_data;
818 switch (stream->num_planes) {
820 frame->data.single_plane.yuv = buf_pos;
821 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
822 total_size = stream->data.yuv420.length_yuv;
825 frame->data.double_plane.y = buf_pos;
826 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
827 buf_pos += stream->data.yuv420sp.length_y;
828 frame->data.double_plane.uv = buf_pos;
829 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
830 total_size = stream->data.yuv420sp.length_y + \
831 stream->data.yuv420sp.length_uv;
834 frame->data.triple_plane.y = buf_pos;
835 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
836 buf_pos += stream->data.yuv420p.length_y;
837 frame->data.triple_plane.u = buf_pos;
838 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
839 buf_pos += stream->data.yuv420p.length_u;
840 frame->data.triple_plane.v = buf_pos;
841 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
842 total_size = stream->data.yuv420p.length_y + \
843 stream->data.yuv420p.length_u + \
844 stream->data.yuv420p.length_v;
852 switch (stream->num_planes) {
854 frame->data.single_plane.yuv = buffer_bo_handle[0].ptr;
855 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
856 total_size = stream->data.yuv420.length_yuv;
859 frame->data.double_plane.y = buffer_bo_handle[0].ptr;
860 if (stream->num_planes == (unsigned int)num_buffer_key)
861 frame->data.double_plane.uv = buffer_bo_handle[1].ptr;
863 frame->data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
864 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
865 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
866 total_size = stream->data.yuv420sp.length_y + \
867 stream->data.yuv420sp.length_uv;
870 frame->data.triple_plane.y = buffer_bo_handle[0].ptr;
871 if (stream->num_planes == (unsigned int)num_buffer_key) {
872 frame->data.triple_plane.u = buffer_bo_handle[1].ptr;
873 frame->data.triple_plane.v = buffer_bo_handle[2].ptr;
875 frame->data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y;
876 frame->data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u;
878 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
879 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
880 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
881 total_size = stream->data.yuv420p.length_y + \
882 stream->data.yuv420p.length_u + \
883 stream->data.yuv420p.length_v;
891 LOGD("format %d, %dx%d, size %d plane num %d",
892 frame.format, frame.width, frame.height, total_size, frame.num_of_planes);
898 static int _camera_media_packet_data_create(int tbm_key, int num_buffer_key, tbm_bo bo,
899 tbm_bo *buffer_bo, tbm_bo data_bo, camera_media_packet_data **mp_data)
902 int ret = CAMERA_ERROR_NONE;
903 camera_media_packet_data *tmp_mp_data = NULL;
905 if (*mp_data == NULL) {
906 tmp_mp_data = g_new0(camera_media_packet_data, 1);
908 tmp_mp_data->tbm_key = tbm_key;
909 tmp_mp_data->num_buffer_key = num_buffer_key;
910 tmp_mp_data->bo = bo;
911 tmp_mp_data->data_bo = data_bo;
912 tmp_mp_data->ref_cnt++;
914 for (i = 0 ; i < num_buffer_key ; i++)
915 tmp_mp_data->buffer_bo[i] = buffer_bo[i];
917 *mp_data = tmp_mp_data;
918 /*LOGD("mp_data %p", tmp_mp_data);*/
920 ret = CAMERA_ERROR_OUT_OF_MEMORY;
921 LOGE("failed to alloc media packet data");
924 ((camera_media_packet_data *)*mp_data)->ref_cnt++;
930 static void _camera_media_packet_data_release(camera_media_packet_data *mp_data, camera_cb_info_s *cb_info)
934 camera_msg_param param;
936 if (!mp_data || !cb_info) {
937 LOGE("NULL pointer %p %p", mp_data, cb_info);
941 if (mp_data->ref_cnt > 1) {
943 LOGD("ref count %d", mp_data->ref_cnt);
945 /* release imported bo */
946 for (i = 0 ; i < mp_data->num_buffer_key ; i++) {
947 tbm_bo_unref(mp_data->buffer_bo[i]);
948 mp_data->buffer_bo[i] = NULL;
952 _camera_release_imported_bo(&mp_data->bo);
953 _camera_release_imported_bo(&mp_data->data_bo);
956 tbm_key = mp_data->tbm_key;
958 CAMERA_MSG_PARAM_SET(param, INT, tbm_key);
960 _camera_msg_send_param1(MUSE_CAMERA_API_RETURN_BUFFER, cb_info, NULL, ¶m, 0);
969 static int _camera_media_packet_create(camera_cb_info_s *cb_info, camera_stream_data_s *stream,
970 camera_media_packet_data *mp_data, media_packet_h *packet)
972 media_packet_h pkt = NULL;
973 bool make_pkt_fmt = false;
974 tbm_surface_h tsurf = NULL;
975 tbm_surface_info_s tsurf_info;
976 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
977 uint32_t bo_format = 0;
980 int num_buffer_key = 0;
981 tbm_bo *buffer_bo = NULL;
983 if (cb_info == NULL || stream == NULL || mp_data == NULL || packet == NULL) {
984 LOGE("invalid parameter - cb_info:%p, stream:%p, mp_data:%p, packet:%p",
985 cb_info, stream, mp_data, packet);
986 return CAMERA_ERROR_INVALID_PARAMETER;
989 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
990 buffer_bo = mp_data->buffer_bo;
991 num_buffer_key = mp_data->num_buffer_key;
993 /* create tbm surface */
994 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
995 tsurf_info.planes[i].stride = stream->stride[i];
997 /* get tbm surface format */
998 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
999 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
1001 if (ret == CAMERA_ERROR_NONE) {
1002 tsurf_info.width = stream->width;
1003 tsurf_info.height = stream->height;
1004 tsurf_info.format = bo_format;
1005 tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
1006 tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
1008 if (num_buffer_key > 0) {
1009 switch (bo_format) {
1010 case TBM_FORMAT_NV12:
1011 case TBM_FORMAT_NV21:
1012 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1013 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1014 tsurf_info.planes[0].offset = 0;
1015 if (num_buffer_key == 1)
1016 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1017 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1019 case TBM_FORMAT_YUV420:
1020 case TBM_FORMAT_YVU420:
1021 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
1022 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
1023 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
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.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1029 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1031 case TBM_FORMAT_UYVY:
1032 case TBM_FORMAT_YUYV:
1033 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
1034 tsurf_info.planes[0].offset = 0;
1035 tsurf_info.size = tsurf_info.planes[0].size;
1041 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_key);
1042 } else if (mp_data->data_bo) {
1043 switch (bo_format) {
1044 case TBM_FORMAT_NV12:
1045 case TBM_FORMAT_NV21:
1046 tsurf_info.planes[0].size = stream->width * stream->height;
1047 tsurf_info.planes[1].size = (tsurf_info.planes[0].size) >> 1;
1048 tsurf_info.planes[0].offset = 0;
1049 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1050 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1052 case TBM_FORMAT_YUV420:
1053 case TBM_FORMAT_YVU420:
1054 tsurf_info.planes[0].size = stream->width * stream->height;
1055 tsurf_info.planes[1].size = (stream->width >> 1) * (stream->height >> 1);
1056 tsurf_info.planes[2].size = tsurf_info.planes[1].size;
1057 tsurf_info.planes[0].offset = 0;
1058 tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
1059 tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
1060 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
1062 case TBM_FORMAT_UYVY:
1063 case TBM_FORMAT_YUYV:
1064 tsurf_info.planes[0].size = (stream->width * stream->height) << 1;
1065 tsurf_info.planes[0].offset = 0;
1066 tsurf_info.size = tsurf_info.planes[0].size;
1072 tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, &mp_data->data_bo, 1);
1074 /*LOGD("tbm surface %p", tsurf);*/
1078 /* check media packet format */
1079 if (cb_info->pkt_fmt) {
1080 int pkt_fmt_width = 0;
1081 int pkt_fmt_height = 0;
1082 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
1084 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
1085 if (pkt_fmt_mimetype != mimetype ||
1086 pkt_fmt_width != stream->width ||
1087 pkt_fmt_height != stream->height) {
1088 LOGW("change fmt: current 0x%x, %dx%d",
1089 pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height);
1090 media_format_unref(cb_info->pkt_fmt);
1091 cb_info->pkt_fmt = NULL;
1092 make_pkt_fmt = true;
1095 make_pkt_fmt = true;
1098 /* create packet format */
1100 LOGW("make new pkt_fmt - 0x%x, %dx%d", mimetype, stream->width, stream->height);
1101 ret = media_format_create(&cb_info->pkt_fmt);
1102 if (ret == MEDIA_FORMAT_ERROR_NONE) {
1103 ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
1104 ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
1105 ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
1106 LOGW("media_format_set : 0x%x", ret);
1108 LOGW("media_format_create failed 0x%x", ret);
1112 /* create media packet */
1113 ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt,
1114 tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
1115 (void *)cb_info, &pkt);
1116 if (ret != MEDIA_PACKET_ERROR_NONE) {
1117 LOGE("media_packet_create failed 0x%x", ret);
1118 tbm_surface_destroy(tsurf);
1122 LOGE("tbm surface failed. %dx%d, format %d, num_buffer_key %d, data_bo %p",
1123 stream->width, stream->height, stream->format, num_buffer_key, mp_data->data_bo);
1127 /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
1128 /* set media packet data */
1129 ret = media_packet_set_extra(pkt, (void *)mp_data);
1130 if (ret != MEDIA_PACKET_ERROR_NONE) {
1131 LOGE("media_packet_set_extra failed");
1133 _camera_media_packet_data_release(mp_data, cb_info);
1136 media_packet_destroy(pkt);
1139 /* set timestamp : msec -> nsec */
1140 if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
1141 LOGW("media_packet_set_pts failed");
1150 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
1153 camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
1154 camera_media_packet_data *mp_data = NULL;
1155 tbm_surface_h tsurf = NULL;
1157 if (!pkt || !cb_info) {
1158 LOGE("NULL pointer %p %p", pkt, cb_info);
1159 return MEDIA_PACKET_FINALIZE;
1162 ret = media_packet_get_extra(pkt, (void **)&mp_data);
1163 if (ret != MEDIA_PACKET_ERROR_NONE) {
1164 LOGE("media_packet_get_extra failed 0x%x", ret);
1165 return MEDIA_PACKET_FINALIZE;
1168 /*LOGD("mp_data %p", mp_data);*/
1170 g_mutex_lock(&cb_info->mp_data_mutex);
1172 _camera_media_packet_data_release(mp_data, cb_info);
1175 g_mutex_unlock(&cb_info->mp_data_mutex);
1177 ret = media_packet_get_tbm_surface(pkt, &tsurf);
1178 if (ret != MEDIA_PACKET_ERROR_NONE)
1179 LOGE("get tbm_surface failed 0x%x", ret);
1182 tbm_surface_destroy(tsurf);
1186 return MEDIA_PACKET_FINALIZE;
1189 static void _camera_client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event)
1194 if (!recv_msg || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
1195 LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event);
1199 /*LOGD("get camera msg %s, event %d", recv_msg, event);*/
1201 g_mutex_lock(&cb_info->user_cb_mutex[event]);
1203 if (cb_info->user_cb[event] == NULL) {
1204 if (event != MUSE_CAMERA_EVENT_TYPE_PREVIEW &&
1205 event != MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW &&
1206 event != MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION &&
1207 event != MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1208 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1209 LOGW("NULL callback for event %d, return here", event);
1213 /* return buffer message should be sent for some events.
1214 - MUSE_CAMERA_EVENT_TYPE_PREVIEW
1215 - MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW
1216 - MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION
1217 - MUSE_CAMERA_EVENT_TYPE_CAPTURE
1222 case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
1228 muse_camera_msg_get(previous, recv_msg);
1229 muse_camera_msg_get(current, recv_msg);
1230 muse_camera_msg_get(by_policy, recv_msg);
1232 LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
1233 previous, current, by_policy);
1235 ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
1236 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
1239 case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
1243 muse_camera_msg_get(state, recv_msg);
1245 LOGD("FOCUS state - %d", state);
1247 ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
1250 case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
1251 LOGD("CAPTURE_COMPLETED");
1252 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
1254 case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
1255 case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
1256 __camera_event_handler_preview(cb_info, recv_msg);
1258 case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
1262 muse_camera_msg_get(percent, recv_msg);
1264 LOGD("HDR progress - %d %%", percent);
1266 ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
1269 case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
1275 muse_camera_msg_get(policy, recv_msg);
1276 muse_camera_msg_get(previous, recv_msg);
1277 muse_camera_msg_get(current, recv_msg);
1279 LOGW("INTERRUPTED - policy %d, state %d -> %d", policy, previous, current);
1281 ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1282 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
1285 case MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED:
1290 muse_camera_msg_get(policy, recv_msg);
1291 muse_camera_msg_get(state, recv_msg);
1293 LOGW("INTERRUPT_STARTED - policy %d, state %d", policy, state);
1295 ((camera_interrupt_started_cb)cb_info->user_cb[event])((camera_policy_e)policy,
1296 (camera_state_e)state, cb_info->user_data[event]);
1299 case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
1300 __camera_event_handler_face_detection(cb_info, recv_msg);
1302 case MUSE_CAMERA_EVENT_TYPE_ERROR:
1305 int current_state = 0;
1307 muse_camera_msg_get(error, recv_msg);
1308 muse_camera_msg_get(current_state, recv_msg);
1310 LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
1312 ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
1313 (camera_state_e)current_state, cb_info->user_data[event]);
1316 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
1318 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
1319 muse_camera_msg_get(param1, recv_msg);
1320 muse_camera_msg_get(param2, recv_msg);
1322 /*LOGD("event %d SUPPORTED %d, %d", event, param1, param2);*/
1324 if (((camera_supported_cb_param2)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
1325 cb_info->user_cb[event] = NULL;
1326 cb_info->user_data[event] = NULL;
1327 LOGW("stop foreach callback for event %d", event);
1330 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
1332 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
1334 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1336 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1338 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1340 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1342 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1344 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1346 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1348 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1350 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1352 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1354 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1356 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1358 case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE:
1359 muse_camera_msg_get(param1, recv_msg);
1361 /*LOGD("event %d SUPPORTED %d ", event, param1);*/
1363 if (((camera_supported_cb_param1)cb_info->user_cb[event])(param1, cb_info->user_data[event]) == false) {
1364 cb_info->user_cb[event] = NULL;
1365 cb_info->user_data[event] = NULL;
1366 LOGW("stop foreach callback for event %d", event);
1369 case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1370 __camera_event_handler_capture(cb_info, recv_msg);
1373 LOGW("unhandled event %d", event);
1377 g_mutex_unlock(&cb_info->user_cb_mutex[event]);
1382 static bool _camera_idle_event_callback(void *data)
1384 camera_cb_info_s *cb_info = NULL;
1385 camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1387 if (cam_idle_event == NULL) {
1388 LOGE("cam_idle_event is NULL");
1393 g_mutex_lock(&cam_idle_event->event_mutex);
1395 cb_info = cam_idle_event->cb_info;
1396 if (cb_info == NULL) {
1397 LOGW("camera cb_info is NULL. event %p %d", cam_idle_event, cam_idle_event->event);
1398 goto IDLE_EVENT_CALLBACK_DONE;
1401 /* remove event from list */
1402 g_mutex_lock(&cb_info->idle_event_mutex);
1404 if (cb_info->idle_event_list)
1405 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1407 /*LOGD("remove camera idle event %p, %p", cam_idle_event, cb_info->idle_event_list);*/
1408 g_mutex_unlock(&cb_info->idle_event_mutex);
1411 _camera_client_user_callback(cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
1413 /* send signal for waiting thread */
1414 g_cond_signal(&cb_info->idle_event_cond);
1416 IDLE_EVENT_CALLBACK_DONE:
1417 /* unlock and release event */
1418 g_mutex_unlock(&cam_idle_event->event_mutex);
1419 g_mutex_clear(&cam_idle_event->event_mutex);
1421 g_free(cam_idle_event);
1422 cam_idle_event = NULL;
1427 static void *_camera_msg_handler_func(gpointer data)
1431 camera_message_s *cam_msg = NULL;
1432 camera_idle_event_s *cam_idle_event = NULL;
1433 camera_msg_handler_info_s *handler_info = (camera_msg_handler_info_s *)data;
1434 camera_cb_info_s *cb_info = NULL;
1436 if (!handler_info || !handler_info->cb_info) {
1437 LOGE("NULL handler %p", handler_info);
1441 cb_info = (camera_cb_info_s *)handler_info->cb_info;
1442 type = handler_info->type;
1444 LOGD("t:%d start", type);
1446 g_mutex_lock(&handler_info->mutex);
1448 while (g_atomic_int_get(&handler_info->running)) {
1449 if (g_queue_is_empty(handler_info->queue)) {
1450 /*LOGD("t:%d signal wait...", type);*/
1451 g_cond_wait(&handler_info->cond, &handler_info->mutex);
1452 /*LOGD("t:%d signal received", type);*/
1454 if (g_atomic_int_get(&handler_info->running) == 0) {
1455 LOGD("t:%d stop event thread", type);
1460 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1462 g_mutex_unlock(&handler_info->mutex);
1464 if (cam_msg == NULL) {
1465 LOGE("t:%d NULL message", type);
1466 g_mutex_lock(&handler_info->mutex);
1472 if (api < MUSE_CAMERA_API_MAX) {
1475 g_mutex_lock(&cb_info->api_mutex[api]);
1477 if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1478 if (cb_info->api_waiting[api] > 0) {
1479 cb_info->api_ret[api] = ret;
1480 cb_info->api_activating[api] = 1;
1482 /*LOGD("t:%d camera api %d - return 0x%x", type, ret);*/
1484 g_cond_signal(&cb_info->api_cond[api]);
1486 LOGW("no waiting for this api [%d]", api);
1489 LOGE("t:%d failed to get camera ret for api %d, msg %s", type, api, cam_msg->recv_msg);
1492 g_mutex_unlock(&cb_info->api_mutex[api]);
1493 } else if (api == MUSE_CAMERA_CB_EVENT) {
1494 switch (cam_msg->event_class) {
1495 case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1496 _camera_client_user_callback(cb_info, cam_msg->recv_msg, cam_msg->event);
1498 case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1499 cam_idle_event = g_new0(camera_idle_event_s, 1);
1500 if (cam_idle_event == NULL) {
1501 LOGE("t:%d cam_idle_event alloc failed", type);
1505 cam_idle_event->event = cam_msg->event;
1506 cam_idle_event->cb_info = cb_info;
1507 g_mutex_init(&cam_idle_event->event_mutex);
1508 strncpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg) - 1);
1510 /*LOGD("t:%d add camera event[%d, %p] to IDLE", type, cam_msg->event, cam_idle_event);*/
1512 g_mutex_lock(&cb_info->idle_event_mutex);
1513 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1514 g_mutex_unlock(&cb_info->idle_event_mutex);
1516 g_idle_add_full(G_PRIORITY_DEFAULT,
1517 (GSourceFunc)_camera_idle_event_callback,
1518 (gpointer)cam_idle_event,
1522 LOGE("t:%d not handled event class %d", type, cam_msg->event_class);
1526 LOGE("t:%d unknown camera api[%d] message[%s]", type, api, cam_msg->recv_msg);
1532 g_mutex_lock(&handler_info->mutex);
1535 /* remove remained event */
1536 while (!g_queue_is_empty(handler_info->queue)) {
1537 cam_msg = (camera_message_s *)g_queue_pop_head(handler_info->queue);
1539 LOGD("t:%d remove camera message %p", type, cam_msg);
1543 LOGW("t:%d NULL camera message", type);
1547 g_mutex_unlock(&handler_info->mutex);
1549 LOGD("t:%d return", type);
1555 static void _camera_deactivate_idle_event_all(camera_cb_info_s *cb_info)
1557 camera_idle_event_s *cam_idle_event = NULL;
1559 gint64 end_time = 0;
1561 if (cb_info == NULL) {
1562 LOGE("cb_info is NULL");
1566 g_mutex_lock(&cb_info->idle_event_mutex);
1568 if (cb_info->idle_event_list == NULL) {
1569 LOGD("No remained idle event");
1570 g_mutex_unlock(&cb_info->idle_event_mutex);
1574 list = cb_info->idle_event_list;
1577 cam_idle_event = list->data;
1578 list = g_list_next(list);
1580 if (!cam_idle_event) {
1581 LOGW("Fail to remove idle event. The event is NULL");
1585 if (g_idle_remove_by_data(cam_idle_event)) {
1586 LOGW("remove idle event %p done", cam_idle_event);
1588 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1590 g_mutex_clear(&cam_idle_event->event_mutex);
1591 g_free(cam_idle_event);
1592 cam_idle_event = NULL;
1597 LOGW("remove idle event %p failed", cam_idle_event);
1599 if (!g_mutex_trylock(&cam_idle_event->event_mutex)) {
1600 LOGW("lock failed, %p event is calling now", cam_idle_event);
1602 end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
1604 if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
1605 LOGW("signal received");
1612 LOGW("set NULL cb_info for event %p %d, it will be freed on idle callback",
1613 cam_idle_event, cam_idle_event->event);
1615 cam_idle_event->cb_info = NULL;
1617 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1619 g_mutex_unlock(&cam_idle_event->event_mutex);
1622 g_list_free(cb_info->idle_event_list);
1623 cb_info->idle_event_list = NULL;
1625 g_mutex_unlock(&cb_info->idle_event_mutex);
1631 static void __camera_add_msg_to_queue(camera_cb_info_s *cb_info, int api, int event, int event_class, char *msg)
1633 camera_message_s *cam_msg = NULL;
1635 if (!cb_info || !msg) {
1636 LOGE("NULL pointer %p %p", cb_info, msg);
1640 cam_msg = g_new0(camera_message_s, 1);
1642 LOGE("failed to alloc cam_msg for [%s]", msg);
1647 cam_msg->event = event;
1648 cam_msg->event_class = event_class;
1650 strncpy(cam_msg->recv_msg, msg, sizeof(cam_msg->recv_msg) - 1);
1652 /*LOGD("add camera message to queue : api %d, event %d, event_class %d", api, event, event_class);*/
1654 if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
1655 g_mutex_lock(&cb_info->preview_cb_info.mutex);
1656 g_queue_push_tail(cb_info->preview_cb_info.queue, (gpointer)cam_msg);
1657 g_cond_signal(&cb_info->preview_cb_info.cond);
1658 g_mutex_unlock(&cb_info->preview_cb_info.mutex);
1659 } else if (event == MUSE_CAMERA_EVENT_TYPE_CAPTURE) {
1660 g_mutex_lock(&cb_info->capture_cb_info.mutex);
1661 g_queue_push_tail(cb_info->capture_cb_info.queue, (gpointer)cam_msg);
1662 g_cond_signal(&cb_info->capture_cb_info.cond);
1663 g_mutex_unlock(&cb_info->capture_cb_info.mutex);
1665 g_mutex_lock(&cb_info->msg_handler_info.mutex);
1666 g_queue_push_tail(cb_info->msg_handler_info.queue, (gpointer)cam_msg);
1667 g_cond_signal(&cb_info->msg_handler_info.cond);
1668 g_mutex_unlock(&cb_info->msg_handler_info.mutex);
1677 static void __camera_process_msg(camera_cb_info_s *cb_info, char *msg)
1679 int ret = CAMERA_ERROR_NONE;
1683 int event_class = -1;
1687 if (!cb_info || !msg) {
1688 LOGE("invalid ptr %p %p", cb_info, msg);
1692 /*LOGD("msg [%s]", msg);*/
1694 if (!muse_camera_msg_get(api, msg)) {
1695 LOGE("failed to get camera api");
1699 if (api == MUSE_CAMERA_CB_EVENT) {
1700 if (!muse_camera_msg_get(event, msg) ||
1701 !muse_camera_msg_get(event_class, msg)) {
1702 LOGE("failed to get camera event or event_class [%s]", msg);
1706 if (!muse_camera_msg_get(api_class, msg)) {
1707 LOGE("failed to get camera api_class [%s]", msg);
1712 if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1713 if (api >= MUSE_CAMERA_API_MAX) {
1714 LOGE("invalid api %d", api);
1718 if (!muse_camera_msg_get(ret, msg)) {
1719 LOGE("failed to get camera ret");
1723 g_mutex_lock(&cb_info->api_mutex[api]);
1726 case MUSE_CAMERA_API_CREATE:
1727 if (ret != CAMERA_ERROR_NONE) {
1728 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1729 LOGE("camera create error 0x%x. close client cb handler", ret);
1732 case MUSE_CAMERA_API_DESTROY:
1733 if (ret == CAMERA_ERROR_NONE) {
1734 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1735 LOGD("camera destroy done. close client cb handler");
1739 muse_camera_msg_get(get_type, msg);
1740 if (get_type != MUSE_CAMERA_GET_TYPE_NONE) {
1741 if (get_type != MUSE_CAMERA_GET_TYPE_ARRAY)
1742 muse_camera_msg_get(get_index, msg);
1745 case MUSE_CAMERA_GET_TYPE_INT:
1746 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int[get_index]);
1748 case MUSE_CAMERA_GET_TYPE_INT_PAIR:
1749 muse_core_msg_deserialize("get_value0", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][0]);
1750 muse_core_msg_deserialize("get_value1", msg, NULL, NULL, MUSE_TYPE_INT, &cb_info->get_int_pair[get_index][1]);
1752 case MUSE_CAMERA_GET_TYPE_ARRAY:
1753 if (api == MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA) {
1754 muse_core_msg_deserialize("get_value",
1755 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_display_roi_area);
1756 LOGD("get display roi %d,%d,%dx%d",
1757 cb_info->get_display_roi_area[0],
1758 cb_info->get_display_roi_area[1],
1759 cb_info->get_display_roi_area[2],
1760 cb_info->get_display_roi_area[3]);
1762 muse_core_msg_deserialize("get_value",
1763 msg, NULL, NULL, MUSE_TYPE_ARRAY, cb_info->get_geotag);
1764 LOGD("get geotag %lf, %lf, %lf",
1765 cb_info->get_geotag[0], cb_info->get_geotag[1], cb_info->get_geotag[2]);
1768 case MUSE_CAMERA_GET_TYPE_STRING:
1769 muse_core_msg_deserialize("get_value", msg, NULL, NULL, MUSE_TYPE_STRING, cb_info->get_string[get_index]);
1772 LOGW("unknown type %d", get_type);
1779 if (cb_info->api_waiting[api] > 0) {
1780 cb_info->api_ret[api] = ret;
1781 cb_info->api_activating[api] = 1;
1783 g_cond_signal(&cb_info->api_cond[api]);
1785 LOGW("no waiting for this api [%d]", api);
1788 g_mutex_unlock(&cb_info->api_mutex[api]);
1789 } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
1790 __camera_add_msg_to_queue(cb_info, api, event, event_class, msg);
1792 LOGW("unknown camera api %d, class %d", api, api_class);
1799 static void *_camera_msg_recv_func(gpointer data)
1801 int recv_length = 0;
1802 int single_length = 0;
1803 int remained_length = 0;
1804 char *recv_msg = NULL;
1805 char *single_msg = NULL;
1806 char *remained_msg = NULL;
1810 camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
1813 LOGE("cb_info NULL");
1817 LOGD("start - fd : %d", cb_info->fd);
1819 single_msg = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
1821 LOGE("single_msg malloc failed");
1825 recv_msg = cb_info->recv_msg;
1827 while (g_atomic_int_get(&cb_info->msg_recv_running)) {
1828 recv_length = muse_core_msg_recv(cb_info->fd, recv_msg);
1829 if (recv_length <= 0) {
1830 cb_info->is_server_connected = FALSE;
1831 LOGE("receive msg failed - server disconnected");
1839 /*LOGD("recv msg : %s, length : %d", recv_msg, recv_length);*/
1841 /* Need to split the combined entering msgs */
1842 for (cur_pos = 0 ; cur_pos < recv_length ; cur_pos++) {
1843 if (recv_msg[cur_pos] == '}') {
1844 single_length = cur_pos - prev_pos + 1;
1846 if (single_length < MUSE_CAMERA_MSG_MAX_LENGTH) {
1847 /* check remained msg */
1848 if (remained_length > 0) {
1850 strncpy(single_msg, remained_msg, remained_length);
1851 strncpy(single_msg + remained_length, recv_msg + prev_pos, single_length);
1852 single_msg[remained_length + single_length] = '\0';
1855 remained_msg = NULL;
1857 strncpy(single_msg, recv_msg + prev_pos, single_length);
1858 single_msg[single_length] = '\0';
1859 LOGE("lost msg [%s], skip...", single_msg);
1862 remained_length = 0;
1864 strncpy(single_msg, recv_msg + prev_pos, single_length);
1865 single_msg[single_length] = '\0';
1868 if (single_msg[0] == '{') {
1870 /*LOGD("splitted msg : [%s], Index : %d", single_msg, num_msg);*/
1871 /* process each message */
1872 __camera_process_msg(cb_info, single_msg);
1874 LOGE("invalid msg [%s]", single_msg);
1877 LOGE("too long message [len %d] skip...", single_length);
1880 prev_pos = cur_pos + 1;
1884 /* check incompleted message */
1885 if (recv_msg[recv_length - 1] != '}') {
1886 remained_length = recv_length - prev_pos;
1888 LOGW("incompleted message [len %d]", remained_length);
1892 remained_msg = NULL;
1895 remained_msg = (char *)malloc(remained_length + 1);
1897 strncpy(remained_msg, recv_msg + prev_pos, remained_length);
1898 remained_msg[remained_length] = '\0';
1900 LOGE("failed to alloc for remained msg");
1903 remained_length = 0;
1907 LOGD("client cb exit - server connected %d", cb_info->is_server_connected);
1909 if (!cb_info->is_server_connected) {
1910 char *error_msg = NULL;
1912 if (cb_info->fd < 0) {
1913 LOGE("fd is closed in client side");
1914 goto CB_HANDLER_EXIT;
1917 /* send error msg for server disconnection */
1918 error_msg = muse_core_msg_new(MUSE_CAMERA_CB_EVENT,
1919 MUSE_TYPE_INT, "error", CAMERA_ERROR_SERVICE_DISCONNECTED,
1920 MUSE_TYPE_INT, "current_state", CAMERA_STATE_NONE,
1924 LOGE("error_msg failed");
1925 goto CB_HANDLER_EXIT;
1928 __camera_add_msg_to_queue(cb_info,
1929 MUSE_CAMERA_CB_EVENT,
1930 MUSE_CAMERA_EVENT_TYPE_ERROR,
1931 MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN,
1934 muse_core_msg_free(error_msg);
1937 LOGE("add error msg for service disconnection done");
1948 remained_msg = NULL;
1955 static bool __create_msg_handler_thread(camera_msg_handler_info_s *handler_info,
1956 int type, const char *thread_name, camera_cb_info_s *cb_info)
1958 if (!handler_info || !thread_name || !cb_info) {
1959 LOGE("t:%d NULL %p %p %p",
1960 type, handler_info, thread_name, cb_info);
1966 handler_info->type = type;
1967 handler_info->queue = g_queue_new();
1968 if (handler_info->queue == NULL) {
1969 LOGE("t:%d queue failed", type);
1973 g_mutex_init(&handler_info->mutex);
1974 g_cond_init(&handler_info->cond);
1976 handler_info->cb_info = (void *)cb_info;
1977 g_atomic_int_set(&handler_info->running, 1);
1979 handler_info->thread = g_thread_try_new(thread_name,
1980 _camera_msg_handler_func, (gpointer)handler_info, NULL);
1981 if (handler_info->thread == NULL) {
1982 LOGE("t:%d thread failed", type);
1984 g_mutex_clear(&handler_info->mutex);
1985 g_cond_clear(&handler_info->cond);
1986 g_queue_free(handler_info->queue);
1987 handler_info->queue = NULL;
1992 LOGD("t:%d done", type);
1998 static void __destroy_msg_handler_thread(camera_msg_handler_info_s *handler_info)
2002 if (!handler_info) {
2003 LOGE("NULL handler");
2007 if (!handler_info->thread) {
2008 LOGW("thread is not created");
2012 type = handler_info->type;
2014 LOGD("t:%d thread %p", type, handler_info->thread);
2016 g_mutex_lock(&handler_info->mutex);
2017 g_atomic_int_set(&handler_info->running, 0);
2018 g_cond_signal(&handler_info->cond);
2019 g_mutex_unlock(&handler_info->mutex);
2021 g_thread_join(handler_info->thread);
2022 handler_info->thread = NULL;
2024 g_mutex_clear(&handler_info->mutex);
2025 g_cond_clear(&handler_info->cond);
2026 g_queue_free(handler_info->queue);
2027 handler_info->queue = NULL;
2029 LOGD("t:%d done", type);
2035 static camera_cb_info_s *_camera_client_callback_new(gint sockfd)
2037 camera_cb_info_s *cb_info = NULL;
2040 g_return_val_if_fail(sockfd > 0, NULL);
2042 cb_info = g_new0(camera_cb_info_s, 1);
2043 if (cb_info == NULL) {
2044 LOGE("cb_info failed");
2048 cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 1;
2050 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2051 g_mutex_init(&cb_info->api_mutex[i]);
2052 g_cond_init(&cb_info->api_cond[i]);
2055 g_mutex_init(&cb_info->fd_lock);
2056 g_mutex_init(&cb_info->idle_event_mutex);
2057 g_cond_init(&cb_info->idle_event_cond);
2058 g_mutex_init(&cb_info->mp_data_mutex);
2060 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2061 g_mutex_init(&cb_info->user_cb_mutex[i]);
2063 /* message handler thread */
2064 if (!__create_msg_handler_thread(&cb_info->msg_handler_info,
2065 CAMERA_MESSAGE_HANDLER_TYPE_GENERAL, "camera_msg_handler", cb_info)) {
2066 LOGE("msg_handler_info failed");
2070 /* message handler thread for preview callback */
2071 if (!__create_msg_handler_thread(&cb_info->preview_cb_info,
2072 CAMERA_MESSAGE_HANDLER_TYPE_PREVIEW_CB, "camera_msg_handler:preview_cb", cb_info)) {
2073 LOGE("preview_cb_info failed");
2077 /* message handler thread for capture callback */
2078 if (!__create_msg_handler_thread(&cb_info->capture_cb_info,
2079 CAMERA_MESSAGE_HANDLER_TYPE_CAPTURE_CB, "camera_msg_handler:capture_cb", cb_info)) {
2080 LOGE("capture_cb_info failed");
2084 cb_info->fd = sockfd;
2085 cb_info->preview_cb_flag = 0;
2087 /* message receive thread */
2088 g_atomic_int_set(&cb_info->msg_recv_running, 1);
2089 cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
2090 _camera_msg_recv_func, (gpointer)cb_info, NULL);
2091 if (cb_info->msg_recv_thread == NULL) {
2092 LOGE("message receive thread creation failed");
2096 cb_info->is_server_connected = TRUE;
2102 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2103 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2104 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2106 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2107 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2109 g_mutex_clear(&cb_info->fd_lock);
2110 g_mutex_clear(&cb_info->idle_event_mutex);
2111 g_cond_clear(&cb_info->idle_event_cond);
2112 g_mutex_clear(&cb_info->mp_data_mutex);
2114 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2115 g_mutex_clear(&cb_info->api_mutex[i]);
2116 g_cond_clear(&cb_info->api_cond[i]);
2126 static void _camera_client_callback_destroy(camera_cb_info_s *cb_info)
2130 g_return_if_fail(cb_info != NULL);
2132 LOGD("msg_recv thread[%p] destroy", cb_info->msg_recv_thread);
2134 g_thread_join(cb_info->msg_recv_thread);
2135 cb_info->msg_recv_thread = NULL;
2137 LOGD("msg_recv thread removed");
2139 /* destroy msg handler threads */
2140 __destroy_msg_handler_thread(&cb_info->msg_handler_info);
2141 __destroy_msg_handler_thread(&cb_info->preview_cb_info);
2142 __destroy_msg_handler_thread(&cb_info->capture_cb_info);
2144 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++)
2145 g_mutex_clear(&cb_info->user_cb_mutex[i]);
2147 g_mutex_clear(&cb_info->fd_lock);
2148 g_mutex_clear(&cb_info->idle_event_mutex);
2149 g_cond_clear(&cb_info->idle_event_cond);
2150 g_mutex_clear(&cb_info->mp_data_mutex);
2152 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
2153 g_mutex_clear(&cb_info->api_mutex[i]);
2154 g_cond_clear(&cb_info->api_cond[i]);
2157 if (cb_info->fd > -1) {
2158 muse_client_close(cb_info->fd);
2162 if (cb_info->bufmgr) {
2163 tbm_bufmgr_deinit(cb_info->bufmgr);
2164 cb_info->bufmgr = NULL;
2166 if (cb_info->pkt_fmt) {
2167 media_format_unref(cb_info->pkt_fmt);
2168 cb_info->pkt_fmt = NULL;
2171 if (cb_info->dp_interface) {
2172 mm_display_interface_deinit(cb_info->dp_interface);
2173 cb_info->dp_interface = NULL;
2176 cb_info->preview_cb_flag = 0;
2185 int _camera_start_evas_rendering(camera_h camera)
2187 camera_cli_s *pc = (camera_cli_s *)camera;
2189 if (!pc || !pc->cb_info) {
2190 LOGE("NULL handle");
2191 return CAMERA_ERROR_INVALID_PARAMETER;
2196 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2197 LOGE("EVAS surface is not set");
2198 return CAMERA_ERROR_NONE;
2201 /* set evas render flag as RUN */
2202 pc->cb_info->run_evas_render = true;
2204 return CAMERA_ERROR_NONE;
2208 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2210 int ret = CAMERA_ERROR_NONE;
2211 camera_cli_s *pc = (camera_cli_s *)camera;
2213 if (!pc || !pc->cb_info) {
2214 LOGE("NULL handle");
2215 return CAMERA_ERROR_INVALID_PARAMETER;
2218 LOGD("stop - keep screen %d", keep_screen);
2220 if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2221 LOGE("EVAS surface is not set");
2222 return CAMERA_ERROR_NONE;
2225 /* set evas render flag as STOP and release buffers */
2226 pc->cb_info->run_evas_render = false;
2228 ret = mm_display_interface_evas_flush(pc->cb_info->dp_interface, keep_screen);
2229 if (ret == MM_ERROR_NONE) {
2230 ret = CAMERA_ERROR_NONE;
2232 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2233 ret = CAMERA_ERROR_INVALID_OPERATION;
2240 int _camera_independent_request(int api, int device_type, const char *key, int *value)
2242 int ret = CAMERA_ERROR_NONE;
2245 char recv_msg[MUSE_CAMERA_MSG_MAX_LENGTH] = {'\0',};
2247 /* create muse connection */
2248 if (!key || !value) {
2249 LOGE("NULL pointer");
2250 return CAMERA_ERROR_INVALID_PARAMETER;
2253 sock_fd = muse_client_new();
2255 LOGE("muse_client_new failed");
2256 return CAMERA_ERROR_INVALID_OPERATION;
2259 msg = muse_core_msg_new(api,
2260 MUSE_TYPE_INT, "module", MUSE_CAMERA,
2261 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2265 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2269 ret = muse_core_msg_send(sock_fd, msg);
2271 muse_core_msg_free(msg);
2275 LOGE("send msg failed");
2276 ret = CAMERA_ERROR_INVALID_OPERATION;
2280 ret = muse_core_msg_recv(sock_fd, recv_msg);
2282 LOGE("recv msg failed %d", errno);
2283 ret = CAMERA_ERROR_INVALID_OPERATION;
2287 if (!muse_camera_msg_get(ret, recv_msg)) {
2288 LOGE("failed to get return value from msg [%s]", recv_msg);
2289 ret = CAMERA_ERROR_INVALID_OPERATION;
2293 if (ret == CAMERA_ERROR_NONE)
2294 muse_core_msg_deserialize(key, recv_msg, NULL, NULL, MUSE_TYPE_ANY, value);
2296 LOGD("api %d - value %d", api, *value);
2300 muse_client_close(sock_fd);
2308 int camera_create(camera_device_e device, camera_h *camera)
2311 char *send_msg = NULL;
2313 int ret = CAMERA_ERROR_NONE;
2315 camera_cli_s *pc = NULL;
2316 tbm_bufmgr bufmgr = NULL;
2318 muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2319 muse_core_api_module_e muse_module = MUSE_CAMERA;
2320 int device_type = (int)device;
2323 LOGE("NULL pointer");
2324 return CAMERA_ERROR_INVALID_PARAMETER;
2327 sock_fd = muse_client_new();
2329 LOGE("muse_client_new failed - returned fd %d", sock_fd);
2330 ret = CAMERA_ERROR_INVALID_OPERATION;
2336 send_msg = muse_core_msg_new(api,
2337 MUSE_TYPE_INT, "module", muse_module,
2338 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2339 MUSE_TYPE_INT, "pid", pid,
2344 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2348 send_ret = muse_core_msg_send(sock_fd, send_msg);
2350 muse_core_msg_free(send_msg);
2354 LOGE("send msg failed %d", errno);
2355 ret = CAMERA_ERROR_INVALID_OPERATION;
2359 pc = g_new0(camera_cli_s, 1);
2361 LOGE("camera_cli_s alloc failed");
2362 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2366 bufmgr = tbm_bufmgr_init(-1);
2367 if (bufmgr == NULL) {
2368 LOGE("get tbm bufmgr failed");
2369 ret = CAMERA_ERROR_INVALID_OPERATION;
2373 pc->cb_info = _camera_client_callback_new(sock_fd);
2374 if (pc->cb_info == NULL) {
2375 LOGE("cb_info alloc failed");
2376 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2382 LOGD("cb info : %d", pc->cb_info->fd);
2384 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
2386 pc->cb_info->api_waiting[MUSE_CAMERA_API_CREATE] = 0;
2388 if (ret == CAMERA_ERROR_NONE) {
2389 intptr_t handle = 0;
2390 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2392 LOGE("Receiving Handle Failed!!");
2393 ret = CAMERA_ERROR_INVALID_OPERATION;
2397 pc->remote_handle = handle;
2398 pc->cb_info->bufmgr = bufmgr;
2400 ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL);
2401 if (ret != CAMERA_ERROR_NONE) {
2402 LOGE("init display failed 0x%x", ret);
2406 LOGD("camera create 0x%x", pc->remote_handle);
2407 *camera = (camera_h)pc;
2416 tbm_bufmgr_deinit(bufmgr);
2421 muse_client_close(sock_fd);
2427 int temp_fd = pc->cb_info->fd;
2429 /* pc->cb_info->fd should be closed,
2430 because g_thread_join for msg_recv_thread is not returned
2431 in _camera_client_callback_destroy. */
2433 pc->cb_info->fd = -1;
2434 muse_client_close(temp_fd);
2437 _camera_client_callback_destroy(pc->cb_info);
2444 LOGE("camera create error : 0x%x", ret);
2450 int camera_change_device(camera_h camera, camera_device_e device)
2453 int ret = CAMERA_ERROR_NONE;
2454 muse_camera_api_e api = MUSE_CAMERA_API_CHANGE_DEVICE;
2455 camera_cli_s *pc = (camera_cli_s *)camera;
2456 camera_msg_param param;
2458 if (!pc || !pc->cb_info) {
2459 LOGE("NULL handle");
2460 return CAMERA_ERROR_INVALID_PARAMETER;
2463 CAMERA_MSG_PARAM_SET(param, INT, device);
2465 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2467 if (ret == CAMERA_ERROR_NONE) {
2468 /* reset callback and user data */
2469 for (i = 0 ; i < MUSE_CAMERA_EVENT_TYPE_NUM ; i++) {
2470 pc->cb_info->user_cb[i] = NULL;
2471 pc->cb_info->user_data[i] = NULL;
2473 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
2480 int camera_destroy(camera_h camera)
2482 int ret = CAMERA_ERROR_NONE;
2483 muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2484 camera_cli_s *pc = (camera_cli_s *)camera;
2486 if (!pc || !pc->cb_info) {
2487 LOGE("NULL handle");
2488 return CAMERA_ERROR_INVALID_PARAMETER;
2493 if (pc->cb_info->is_server_connected)
2494 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2496 LOGW("server disconnected. release resource without send message.");
2498 if (ret == CAMERA_ERROR_NONE) {
2499 _camera_deactivate_idle_event_all(pc->cb_info);
2500 _camera_client_callback_destroy(pc->cb_info);
2507 LOGD("ret : 0x%x", ret);
2512 int camera_start_preview(camera_h camera)
2514 int ret = CAMERA_ERROR_NONE;
2515 muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2516 camera_cli_s *pc = (camera_cli_s *)camera;
2518 if (!pc || !pc->cb_info) {
2519 LOGE("NULL handle");
2520 return CAMERA_ERROR_INVALID_PARAMETER;
2525 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_NO_TIMEOUT);
2526 if (ret == CAMERA_ERROR_NONE && CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2527 ret = _camera_start_evas_rendering(camera);
2528 if (ret != CAMERA_ERROR_NONE) {
2529 LOGE("stop preview because of error");
2530 _camera_msg_send(MUSE_CAMERA_API_STOP_PREVIEW, pc->cb_info, NULL, 0);
2534 LOGD("ret : 0x%x", ret);
2540 int camera_stop_preview(camera_h camera)
2542 int ret = CAMERA_ERROR_NONE;
2543 camera_cli_s *pc = (camera_cli_s *)camera;
2544 muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2545 camera_state_e current_state = CAMERA_STATE_NONE;
2547 if (!pc || !pc->cb_info) {
2548 LOGE("NULL handle");
2549 return CAMERA_ERROR_INVALID_PARAMETER;
2554 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2555 ret = camera_get_state(camera, ¤t_state);
2556 if (ret != CAMERA_ERROR_NONE) {
2557 LOGE("failed to get current state 0x%x", ret);
2561 if (current_state == CAMERA_STATE_PREVIEW) {
2562 ret = _camera_stop_evas_rendering(camera, false);
2563 if (ret != CAMERA_ERROR_NONE)
2568 /* send stop preview message */
2569 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2571 if (ret != CAMERA_ERROR_NONE &&
2572 current_state == CAMERA_STATE_PREVIEW) {
2573 LOGW("restart evas rendering");
2574 _camera_start_evas_rendering(camera);
2577 LOGD("ret : 0x%x", ret);
2583 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2585 int ret = CAMERA_ERROR_NONE;
2586 camera_cli_s *pc = (camera_cli_s *)camera;
2587 muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2589 if (!pc || !pc->cb_info) {
2590 LOGE("NULL handle");
2591 return CAMERA_ERROR_INVALID_PARAMETER;
2596 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2597 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2599 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2600 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2602 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2604 LOGD("ret : 0x%x", ret);
2610 bool camera_is_supported_continuous_capture(camera_h camera)
2612 int ret = CAMERA_ERROR_NONE;
2613 camera_cli_s *pc = (camera_cli_s *)camera;
2614 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2616 if (!pc || !pc->cb_info) {
2617 LOGE("NULL handle");
2618 return CAMERA_ERROR_INVALID_PARAMETER;
2623 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2626 LOGE("error is occurred 0x%x", ret);
2630 LOGD("ret : %d", ret);
2636 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)
2638 int ret = CAMERA_ERROR_NONE;
2639 camera_cli_s *pc = (camera_cli_s *)camera;
2640 muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2641 camera_msg_param param;
2644 if (!pc || !pc->cb_info) {
2645 LOGE("NULL handle");
2646 return CAMERA_ERROR_INVALID_PARAMETER;
2651 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2652 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2654 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2655 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2657 value = (count << 16) | interval;
2658 CAMERA_MSG_PARAM_SET(param, INT, value);
2660 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2662 LOGD("ret : 0x%x", ret);
2668 int camera_stop_continuous_capture(camera_h camera)
2670 int ret = CAMERA_ERROR_NONE;
2671 camera_cli_s *pc = (camera_cli_s *)camera;
2672 muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2674 if (!pc || !pc->cb_info) {
2675 LOGE("NULL handle");
2676 return CAMERA_ERROR_INVALID_PARAMETER;
2681 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2683 LOGD("ret : 0x%x", ret);
2689 bool camera_is_supported_face_detection(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_SUPPORT_FACE_DETECTION;
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);
2705 LOGE("error is occurred 0x%x", ret);
2709 LOGD("ret : %d", ret);
2715 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2717 int ret = CAMERA_ERROR_NONE;
2718 camera_cli_s *pc = (camera_cli_s *)camera;
2719 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2721 if (!pc || !pc->cb_info) {
2722 LOGE("NULL handle");
2723 return CAMERA_ERROR_INVALID_PARAMETER;
2728 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2731 LOGE("error is occurred 0x%x", ret);
2735 LOGD("ret : %d", ret);
2741 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2743 int ret = CAMERA_ERROR_NONE;
2744 camera_cli_s *pc = (camera_cli_s *)camera;
2745 muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2747 if (!pc || !pc->cb_info) {
2748 LOGE("NULL handle");
2749 return CAMERA_ERROR_INVALID_PARAMETER;
2754 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2757 LOGE("error is occurred 0x%x", ret);
2761 LOGD("ret : %d", ret);
2766 int camera_get_device_count(camera_h camera, int *device_count)
2768 int ret = CAMERA_ERROR_NONE;
2769 camera_cli_s *pc = (camera_cli_s *)camera;
2770 muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2772 if (!pc || !pc->cb_info) {
2773 LOGE("NULL handle");
2774 return CAMERA_ERROR_INVALID_PARAMETER;
2779 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2781 if (ret == CAMERA_ERROR_NONE)
2782 *device_count = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DEVICE_COUNT];
2784 LOGD("ret : 0x%x", ret);
2789 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2791 int ret = CAMERA_ERROR_NONE;
2792 camera_cli_s *pc = (camera_cli_s *)camera;
2793 muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2795 if (!pc || !pc->cb_info) {
2796 LOGE("NULL handle");
2797 return CAMERA_ERROR_INVALID_PARAMETER;
2802 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2804 if (ret == CAMERA_ERROR_NONE) {
2805 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2807 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2808 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2810 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2813 LOGD("ret : 0x%x", ret);
2818 int camera_stop_face_detection(camera_h camera)
2820 int ret = CAMERA_ERROR_NONE;
2821 camera_cli_s *pc = (camera_cli_s *)camera;
2822 muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
2824 if (!pc || !pc->cb_info) {
2825 LOGE("NULL handle");
2826 return CAMERA_ERROR_INVALID_PARAMETER;
2831 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2833 if (ret == CAMERA_ERROR_NONE) {
2834 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2836 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
2837 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = NULL;
2839 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION]);
2842 LOGD("ret : 0x%x", ret);
2847 int camera_get_state(camera_h camera, camera_state_e *state)
2849 int ret = CAMERA_ERROR_NONE;
2850 camera_cli_s *pc = (camera_cli_s *)camera;
2851 muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
2853 if (!pc || !pc->cb_info || !state) {
2854 LOGE("NULL pointer %p %p", pc, state);
2855 return CAMERA_ERROR_INVALID_PARAMETER;
2860 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2862 if (ret == CAMERA_ERROR_NONE)
2863 *state = (camera_state_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STATE];
2865 LOGD("ret : 0x%x", ret);
2870 int camera_start_focusing(camera_h camera, bool continuous)
2872 int ret = CAMERA_ERROR_NONE;
2873 camera_cli_s *pc = (camera_cli_s *)camera;
2874 muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
2875 camera_msg_param param;
2876 int is_continuous = (int)continuous;
2878 if (!pc || !pc->cb_info) {
2879 LOGE("NULL handle");
2880 return CAMERA_ERROR_INVALID_PARAMETER;
2885 CAMERA_MSG_PARAM_SET(param, INT, is_continuous);
2887 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
2889 LOGD("ret : 0x%x", ret);
2894 int camera_cancel_focusing(camera_h camera)
2896 int ret = CAMERA_ERROR_NONE;
2897 camera_cli_s *pc = (camera_cli_s *)camera;
2898 muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
2900 if (!pc || !pc->cb_info) {
2901 LOGE("NULL handle");
2902 return CAMERA_ERROR_INVALID_PARAMETER;
2905 LOGD("Enter, remote_handle : %x", pc->remote_handle);
2907 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
2909 LOGD("ret : 0x%x", ret);
2914 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
2916 int ret = CAMERA_ERROR_NONE;
2917 camera_cli_s *pc = (camera_cli_s *)camera;
2918 camera_cb_info_s *cb_info = NULL;
2919 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
2920 camera_state_e current_state = CAMERA_STATE_NONE;
2921 camera_msg_param param;
2925 if (!pc || !pc->cb_info) {
2926 LOGE("NULL handle");
2927 return CAMERA_ERROR_INVALID_PARAMETER;
2930 if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
2931 LOGE("invalid type %d", type);
2932 return CAMERA_ERROR_INVALID_PARAMETER;
2935 if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
2936 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
2937 return CAMERA_ERROR_INVALID_PARAMETER;
2940 cb_info = (camera_cb_info_s *)pc->cb_info;
2942 ret = camera_get_state(camera, ¤t_state);
2943 if (ret != CAMERA_ERROR_NONE) {
2944 LOGE("failed to get current state 0x%x", ret);
2948 if (current_state != CAMERA_STATE_CREATED) {
2949 LOGE("INVALID_STATE : current %d", current_state);
2950 return CAMERA_ERROR_INVALID_STATE;
2953 LOGD("Enter - display : %p", display);
2955 if (type == CAMERA_DISPLAY_TYPE_NONE) {
2956 LOGD("display type NONE");
2958 /* display interface handle */
2959 if (!cb_info->dp_interface) {
2960 if (mm_display_interface_init(&cb_info->dp_interface) != MM_ERROR_NONE) {
2961 LOGE("display interface init failed");
2962 return CAMERA_ERROR_NOT_SUPPORTED;
2966 ret = mm_display_interface_set_display(cb_info->dp_interface, type, display, &cb_info->parent_id);
2967 if (ret != MM_ERROR_NONE) {
2968 LOGE("[INVALID_OPERATION] set display failed[0x%x]", ret);
2969 return CAMERA_ERROR_INVALID_OPERATION;
2972 if (type == CAMERA_DISPLAY_TYPE_EVAS) {
2973 camera_flip_e flip = CAMERA_FLIP_NONE;
2974 camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
2975 camera_rotation_e rotation = CAMERA_ROTATION_NONE;
2982 camera_get_display_flip(camera, &flip);
2983 camera_get_display_mode(camera, &mode);
2984 camera_get_display_rotation(camera, &rotation);
2985 camera_is_display_visible(camera, &visible);
2986 camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
2988 LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
2989 flip, mode, rotation, visible, x, y, width, height);
2991 ret = mm_display_interface_evas_set_flip(cb_info->dp_interface, flip);
2992 ret |= mm_display_interface_evas_set_mode(cb_info->dp_interface, mode);
2993 ret |= mm_display_interface_evas_set_rotation(cb_info->dp_interface, rotation);
2994 ret |= mm_display_interface_evas_set_visible(cb_info->dp_interface, visible);
2996 if (mode == CAMERA_DISPLAY_MODE_CUSTOM_ROI)
2997 ret |= mm_display_interface_evas_set_roi_area(cb_info->dp_interface, x, y, width, height);
3001 if (type == CAMERA_DISPLAY_TYPE_OVERLAY) {
3004 length = sizeof(camera_wl_info_s) / sizeof(int) + \
3005 (sizeof(camera_wl_info_s) % sizeof(int) ? 1 : 0);
3007 msg = muse_core_msg_new(api,
3008 MUSE_TYPE_INT, "type", type,
3009 MUSE_TYPE_INT, "parent_id", cb_info->parent_id,
3012 LOGE("msg creation failed: api %d", api);
3013 return CAMERA_ERROR_OUT_OF_MEMORY;
3016 if (pc->cb_info->is_server_connected) {
3017 __camera_update_api_waiting(pc->cb_info, api, 1);
3019 g_mutex_lock(&pc->cb_info->fd_lock);
3020 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
3021 g_mutex_unlock(&pc->cb_info->fd_lock);
3025 LOGE("message send failed");
3026 ret = CAMERA_ERROR_INVALID_OPERATION;
3028 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
3031 __camera_update_api_waiting(pc->cb_info, api, -1);
3033 muse_core_msg_free(msg);
3035 CAMERA_MSG_PARAM_SET(param, INT, type);
3037 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3040 if (ret != CAMERA_ERROR_NONE)
3041 LOGE("set display error 0x%x", ret);
3042 else if (type == CAMERA_DISPLAY_TYPE_EVAS)
3043 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
3049 int camera_set_preview_resolution(camera_h camera, int width, int height)
3051 int ret = CAMERA_ERROR_NONE;
3052 camera_state_e current_state = CAMERA_STATE_NONE;
3053 camera_cli_s *pc = (camera_cli_s *)camera;
3054 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
3055 camera_msg_param param;
3058 if (!pc || !pc->cb_info) {
3059 LOGE("NULL handle");
3060 return CAMERA_ERROR_INVALID_PARAMETER;
3063 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3064 ret = camera_get_state(camera, ¤t_state);
3065 if (ret != CAMERA_ERROR_NONE) {
3066 LOGE("failed to get current state 0x%x", ret);
3070 if (current_state == CAMERA_STATE_PREVIEW) {
3071 ret = _camera_stop_evas_rendering(camera, true);
3072 if (ret != CAMERA_ERROR_NONE)
3077 value = (width << 16) | height;
3078 CAMERA_MSG_PARAM_SET(param, INT, value);
3080 LOGD("%dx%d -> 0x%x", width, height, value);
3082 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3084 LOGD("ret : 0x%x", ret);
3086 if (current_state == CAMERA_STATE_PREVIEW) {
3087 LOGW("restart evas rendering");
3088 _camera_start_evas_rendering(camera);
3095 int camera_set_capture_resolution(camera_h camera, int width, int height)
3097 int ret = CAMERA_ERROR_NONE;
3098 camera_cli_s *pc = (camera_cli_s *)camera;
3099 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
3100 camera_msg_param param;
3103 if (!pc || !pc->cb_info) {
3104 LOGE("NULL handle");
3105 return CAMERA_ERROR_INVALID_PARAMETER;
3110 value = (width << 16) | height;
3111 CAMERA_MSG_PARAM_SET(param, INT, value);
3113 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3115 LOGD("ret : 0x%x", ret);
3121 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
3123 int ret = CAMERA_ERROR_NONE;
3124 int set_format = (int)format;
3125 camera_cli_s *pc = (camera_cli_s *)camera;
3126 muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
3127 camera_msg_param param;
3129 if (!pc || !pc->cb_info) {
3130 LOGE("NULL handle");
3131 return CAMERA_ERROR_INVALID_PARAMETER;
3134 LOGD("Enter - format %d", set_format);
3136 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3138 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3140 LOGD("ret : 0x%x", ret);
3146 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
3148 int ret = CAMERA_ERROR_NONE;
3149 int set_format = (int)format;
3150 camera_msg_param param;
3151 camera_cli_s *pc = (camera_cli_s *)camera;
3152 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
3154 if (!pc || !pc->cb_info) {
3155 LOGE("NULL handle");
3156 return CAMERA_ERROR_INVALID_PARAMETER;
3159 LOGD("Enter - capture_format %d", set_format);
3161 CAMERA_MSG_PARAM_SET(param, INT, set_format);
3163 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3165 LOGD("ret : 0x%x", ret);
3171 int camera_get_preview_resolution(camera_h camera, int *width, int *height)
3173 int ret = CAMERA_ERROR_NONE;
3174 camera_cli_s *pc = (camera_cli_s *)camera;
3175 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
3177 if (!pc || !pc->cb_info || !width || !height) {
3178 LOGE("NULL pointer %p %p %p", pc, width, height);
3179 return CAMERA_ERROR_INVALID_PARAMETER;
3184 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3186 if (ret == CAMERA_ERROR_NONE) {
3187 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION] >> 16;
3188 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_RESOLUTION];
3191 LOGD("ret : 0x%x", ret);
3197 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
3199 int ret = CAMERA_ERROR_NONE;
3200 int set_rotation = (int)rotation;
3201 camera_cli_s *pc = (camera_cli_s *)camera;
3202 camera_msg_param param;
3204 if (!pc || !pc->cb_info) {
3205 LOGE("NULL handle");
3206 return CAMERA_ERROR_INVALID_PARAMETER;
3209 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3210 ret = mm_display_interface_evas_set_rotation(pc->cb_info->dp_interface, rotation);
3211 if (ret != MM_ERROR_NONE) {
3212 LOGE("failed to set rotation for evas surface 0x%x", ret);
3213 return CAMERA_ERROR_INVALID_OPERATION;
3217 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
3219 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3225 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3227 int ret = CAMERA_ERROR_NONE;
3228 camera_cli_s *pc = (camera_cli_s *)camera;
3230 if (!pc || !pc->cb_info || !rotation) {
3231 LOGE("NULL pointer %p %p", pc, rotation);
3232 return CAMERA_ERROR_INVALID_PARAMETER;
3235 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3237 if (ret == CAMERA_ERROR_NONE)
3238 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_ROTATION];
3244 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3246 int ret = CAMERA_ERROR_NONE;
3247 int set_flip = (int)flip;
3248 camera_cli_s *pc = (camera_cli_s *)camera;
3249 camera_msg_param param;
3251 if (!pc || !pc->cb_info) {
3252 LOGE("NULL handle");
3253 return CAMERA_ERROR_INVALID_PARAMETER;
3256 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3257 ret = mm_display_interface_evas_set_flip(pc->cb_info->dp_interface, flip);
3258 if (ret != MM_ERROR_NONE) {
3259 LOGE("failed to set flip for evas surface 0x%x", ret);
3260 return CAMERA_ERROR_INVALID_OPERATION;
3264 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
3266 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_FLIP, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3272 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3274 int ret = CAMERA_ERROR_NONE;
3275 camera_cli_s *pc = (camera_cli_s *)camera;
3277 if (!pc || !pc->cb_info || !flip) {
3278 LOGE("NULL pointer %p %p", pc, flip);
3279 return CAMERA_ERROR_INVALID_PARAMETER;
3282 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3284 if (ret == CAMERA_ERROR_NONE)
3285 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_FLIP];
3291 int camera_set_display_visible(camera_h camera, bool visible)
3293 int ret = CAMERA_ERROR_NONE;
3294 int set_visible = (int)visible;
3295 camera_cli_s *pc = (camera_cli_s *)camera;
3296 camera_msg_param param;
3298 if (!pc || !pc->cb_info) {
3299 LOGE("NULL handle");
3300 return CAMERA_ERROR_INVALID_PARAMETER;
3303 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3304 ret = mm_display_interface_evas_set_visible(pc->cb_info->dp_interface, visible);
3305 if (ret != MM_ERROR_NONE) {
3306 LOGE("failed to set visible for evas surface 0x%x", ret);
3307 return CAMERA_ERROR_INVALID_OPERATION;
3311 CAMERA_MSG_PARAM_SET(param, INT, set_visible);
3313 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3319 int camera_is_display_visible(camera_h camera, bool *visible)
3321 int ret = CAMERA_ERROR_NONE;
3322 camera_cli_s *pc = (camera_cli_s *)camera;
3324 if (!pc || !pc->cb_info || !visible) {
3325 LOGE("NULL pointer %p %p", pc, visible);
3326 return CAMERA_ERROR_INVALID_PARAMETER;
3329 _camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3331 if (ret == CAMERA_ERROR_NONE)
3332 *visible = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_VISIBLE];
3338 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3340 int ret = CAMERA_ERROR_NONE;
3341 int set_mode = (int)mode;
3342 camera_cli_s *pc = (camera_cli_s *)camera;
3343 camera_msg_param param;
3345 if (!pc || !pc->cb_info) {
3346 LOGE("NULL handle");
3347 return CAMERA_ERROR_INVALID_PARAMETER;
3350 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3351 ret = mm_display_interface_evas_set_mode(pc->cb_info->dp_interface, mode);
3352 if (ret != MM_ERROR_NONE) {
3353 LOGE("failed to set geometry for evas surface 0x%x", ret);
3354 return CAMERA_ERROR_INVALID_OPERATION;
3358 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
3360 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_MODE, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3366 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3368 int ret = CAMERA_ERROR_NONE;
3369 camera_cli_s *pc = (camera_cli_s *)camera;
3371 if (!pc || !pc->cb_info || !mode) {
3372 LOGE("NULL pointer %p %p", pc, mode);
3373 return CAMERA_ERROR_INVALID_PARAMETER;
3376 _camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3378 if (ret == CAMERA_ERROR_NONE)
3379 *mode = (camera_display_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_MODE];
3385 int camera_set_display_reuse_hint(camera_h camera, bool hint)
3387 int ret = CAMERA_ERROR_NONE;
3388 int set_hint = (int)hint;
3389 camera_cli_s *pc = (camera_cli_s *)camera;
3390 camera_msg_param param;
3392 if (!pc || !pc->cb_info) {
3393 LOGE("NULL handle");
3394 return CAMERA_ERROR_INVALID_PARAMETER;
3397 LOGD("Enter - hint %d", set_hint);
3399 CAMERA_MSG_PARAM_SET(param, INT, set_hint);
3401 _camera_msg_send_param1(MUSE_CAMERA_API_SET_DISPLAY_REUSE_HINT, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
3407 int camera_get_display_reuse_hint(camera_h camera, bool *hint)
3409 int ret = CAMERA_ERROR_NONE;
3410 camera_cli_s *pc = (camera_cli_s *)camera;
3411 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_REUSE_HINT;
3413 if (!pc || !pc->cb_info || !hint) {
3414 LOGE("NULL pointer %p %p", pc, hint);
3415 return CAMERA_ERROR_INVALID_PARAMETER;
3418 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3420 if (ret == CAMERA_ERROR_NONE) {
3421 *hint = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_DISPLAY_REUSE_HINT];
3422 LOGD("display reuse hint %d", *hint);
3429 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3431 int ret = CAMERA_ERROR_NONE;
3432 camera_cli_s *pc = (camera_cli_s *)camera;
3433 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3435 if (!pc || !pc->cb_info || !width || !height) {
3436 LOGE("NULL pointer %p %p %p", pc, width, height);
3437 return CAMERA_ERROR_INVALID_PARAMETER;
3442 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3444 if (ret == CAMERA_ERROR_NONE) {
3445 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION] >> 16;
3446 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_RESOLUTION];
3449 LOGD("ret : 0x%x", ret);
3455 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3457 int ret = CAMERA_ERROR_NONE;
3458 camera_cli_s *pc = (camera_cli_s *)camera;
3459 muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3461 if (!pc || !pc->cb_info || !format) {
3462 LOGE("NULL pointer %p %p", pc, format);
3463 return CAMERA_ERROR_INVALID_PARAMETER;
3468 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3470 if (ret == CAMERA_ERROR_NONE)
3471 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CAPTURE_FORMAT];
3473 LOGD("ret : 0x%x", ret);
3479 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3481 int ret = CAMERA_ERROR_NONE;
3482 camera_cli_s *pc = (camera_cli_s *)camera;
3483 muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3485 if (!pc || !pc->cb_info || !format) {
3486 LOGE("NULL pointer %p %p", pc, format);
3487 return CAMERA_ERROR_INVALID_PARAMETER;
3492 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3494 if (ret == CAMERA_ERROR_NONE)
3495 *format = (camera_pixel_format_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FORMAT];
3497 LOGD("ret : 0x%x", ret);
3503 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direction)
3505 int ret = CAMERA_ERROR_NONE;
3506 camera_cli_s *pc = (camera_cli_s *)camera;
3507 muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3509 if (!pc || !pc->cb_info || !facing_direction) {
3510 LOGE("NULL pointer %p %p", pc, facing_direction);
3511 return CAMERA_ERROR_INVALID_PARAMETER;
3516 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3518 if (ret == CAMERA_ERROR_NONE)
3519 *facing_direction = (camera_facing_direction_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FACING_DIRECTION];
3521 LOGD("ret : 0x%x", ret);
3527 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3529 int ret = CAMERA_ERROR_NONE;
3530 camera_cli_s *pc = (camera_cli_s *)camera;
3531 muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3533 if (!pc || !pc->cb_info || !callback) {
3534 LOGE("NULL pointer %p %p", pc, callback);
3535 return CAMERA_ERROR_INVALID_PARAMETER;
3540 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3542 if (ret == CAMERA_ERROR_NONE) {
3543 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3545 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3546 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3548 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3550 SET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3553 LOGD("ret : 0x%x", ret);
3559 int camera_unset_preview_cb(camera_h camera)
3561 int ret = CAMERA_ERROR_NONE;
3562 camera_cli_s *pc = (camera_cli_s *)camera;
3563 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3565 if (!pc || !pc->cb_info) {
3566 LOGE("NULL handle");
3567 return CAMERA_ERROR_INVALID_PARAMETER;
3572 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3574 if (ret == CAMERA_ERROR_NONE) {
3575 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3577 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3578 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = NULL;
3580 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_PREVIEW]);
3582 UNSET_PREVIEW_CB_TYPE(pc->cb_info, PREVIEW_CB_TYPE_USER);
3585 LOGD("ret : 0x%x", ret);
3591 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3593 int ret = CAMERA_ERROR_NONE;
3594 camera_cli_s *pc = (camera_cli_s *)camera;
3595 muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3597 if (!pc || !pc->cb_info) {
3598 LOGE("NULL handle");
3599 return CAMERA_ERROR_INVALID_PARAMETER;
3602 if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3603 LOGE("NOT SUPPORTED");
3604 return CAMERA_ERROR_NOT_SUPPORTED;
3607 if (callback == NULL) {
3608 LOGE("NULL callback");
3609 return CAMERA_ERROR_INVALID_PARAMETER;
3614 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3616 if (ret == CAMERA_ERROR_NONE) {
3617 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3619 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3620 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3622 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3625 LOGD("ret : 0x%x", ret);
3631 int camera_unset_media_packet_preview_cb(camera_h camera)
3633 int ret = CAMERA_ERROR_NONE;
3634 camera_cli_s *pc = (camera_cli_s *)camera;
3635 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3637 if (!pc || !pc->cb_info) {
3638 LOGE("NULL handle");
3639 return CAMERA_ERROR_INVALID_PARAMETER;
3644 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3646 if (ret == CAMERA_ERROR_NONE) {
3647 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3649 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3650 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = NULL;
3652 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]);
3655 LOGD("ret : 0x%x", ret);
3661 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3663 int ret = CAMERA_ERROR_NONE;
3664 camera_cli_s *pc = (camera_cli_s *)camera;
3665 muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3667 if (!pc || !pc->cb_info || !callback) {
3668 LOGE("NULL pointer %p %p", pc, callback);
3669 return CAMERA_ERROR_INVALID_PARAMETER;
3674 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3676 if (ret == CAMERA_ERROR_NONE) {
3677 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3679 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3680 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3682 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3685 LOGD("ret : 0x%x", ret);
3691 int camera_unset_state_changed_cb(camera_h camera)
3693 int ret = CAMERA_ERROR_NONE;
3694 camera_cli_s *pc = (camera_cli_s *)camera;
3695 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3697 if (!pc || !pc->cb_info) {
3698 LOGE("NULL handle");
3699 return CAMERA_ERROR_INVALID_PARAMETER;
3704 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3706 if (ret == CAMERA_ERROR_NONE) {
3707 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3709 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3710 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = NULL;
3712 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE]);
3715 LOGD("ret : 0x%x", ret);
3721 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3723 int ret = CAMERA_ERROR_NONE;
3724 camera_cli_s *pc = (camera_cli_s *)camera;
3725 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3727 if (!pc || !pc->cb_info || !callback) {
3728 LOGE("NULL pointer %p %p", pc, callback);
3729 return CAMERA_ERROR_INVALID_PARAMETER;
3734 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3736 if (ret == CAMERA_ERROR_NONE) {
3737 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3739 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3740 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3742 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3745 LOGD("ret : 0x%x", ret);
3751 int camera_unset_interrupted_cb(camera_h camera)
3753 int ret = CAMERA_ERROR_NONE;
3754 camera_cli_s *pc = (camera_cli_s *)camera;
3755 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3757 if (!pc || !pc->cb_info) {
3758 LOGE("NULL handle");
3759 return CAMERA_ERROR_INVALID_PARAMETER;
3764 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3766 if (ret == CAMERA_ERROR_NONE) {
3767 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3769 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3770 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = NULL;
3772 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED]);
3775 LOGD("ret : 0x%x", ret);
3781 int camera_set_interrupt_started_cb(camera_h camera, camera_interrupt_started_cb callback, void *user_data)
3783 int ret = CAMERA_ERROR_NONE;
3784 camera_cli_s *pc = (camera_cli_s *)camera;
3785 muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPT_STARTED_CB;
3787 if (!pc || !pc->cb_info || !callback) {
3788 LOGE("NULL pointer %p %p", pc, callback);
3789 return CAMERA_ERROR_INVALID_PARAMETER;
3794 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3796 if (ret == CAMERA_ERROR_NONE) {
3797 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3799 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = callback;
3800 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = user_data;
3802 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3805 LOGD("ret : 0x%x", ret);
3811 int camera_unset_interrupt_started_cb(camera_h camera)
3813 int ret = CAMERA_ERROR_NONE;
3814 camera_cli_s *pc = (camera_cli_s *)camera;
3815 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPT_STARTED_CB;
3817 if (!pc || !pc->cb_info) {
3818 LOGE("NULL handle");
3819 return CAMERA_ERROR_INVALID_PARAMETER;
3824 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3826 if (ret == CAMERA_ERROR_NONE) {
3827 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3829 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3830 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED] = NULL;
3832 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_INTERRUPT_STARTED]);
3835 LOGD("ret : 0x%x", ret);
3841 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
3843 int ret = CAMERA_ERROR_NONE;
3844 camera_cli_s *pc = (camera_cli_s *)camera;
3845 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3847 if (!pc || !pc->cb_info || !callback) {
3848 LOGE("NULL pointer %p %p", pc, callback);
3849 return CAMERA_ERROR_INVALID_PARAMETER;
3854 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3856 if (ret == CAMERA_ERROR_NONE) {
3857 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3859 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3860 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3862 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3865 LOGD("ret : 0x%x", ret);
3871 int camera_unset_focus_changed_cb(camera_h camera)
3873 int ret = CAMERA_ERROR_NONE;
3874 camera_cli_s *pc = (camera_cli_s *)camera;
3875 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
3877 if (!pc || !pc->cb_info) {
3878 LOGE("NULL handle");
3879 return CAMERA_ERROR_INVALID_PARAMETER;
3884 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3886 if (ret == CAMERA_ERROR_NONE) {
3887 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3889 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3890 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = NULL;
3892 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE]);
3895 LOGD("ret : 0x%x", ret);
3901 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
3903 int ret = CAMERA_ERROR_NONE;
3904 camera_cli_s *pc = (camera_cli_s *)camera;
3905 muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
3907 if (!pc || !pc->cb_info || !callback) {
3908 LOGE("NULL pointer %p %p", pc, callback);
3909 return CAMERA_ERROR_INVALID_PARAMETER;
3914 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3916 if (ret == CAMERA_ERROR_NONE) {
3917 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3919 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
3920 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
3922 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3925 LOGD("ret : 0x%x", ret);
3931 int camera_unset_error_cb(camera_h camera)
3933 int ret = CAMERA_ERROR_NONE;
3934 camera_cli_s *pc = (camera_cli_s *)camera;
3935 muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
3937 if (!pc || !pc->cb_info) {
3938 LOGE("NULL handle");
3939 return CAMERA_ERROR_INVALID_PARAMETER;
3944 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3946 if (ret == CAMERA_ERROR_NONE) {
3947 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3949 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
3950 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = NULL;
3952 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_ERROR]);
3955 LOGD("ret : 0x%x", ret);
3961 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb, void *user_data)
3963 int ret = CAMERA_ERROR_NONE;
3964 camera_cli_s *pc = (camera_cli_s *)camera;
3965 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
3967 if (!pc || !pc->cb_info || !foreach_cb) {
3968 LOGE("NULL pointer %p %p", pc, foreach_cb);
3969 return CAMERA_ERROR_INVALID_PARAMETER;
3974 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
3975 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
3977 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
3979 LOGD("ret : 0x%x", ret);
3985 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb, void *user_data)
3987 int ret = CAMERA_ERROR_NONE;
3988 camera_cli_s *pc = (camera_cli_s *)camera;
3989 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
3991 if (!pc || !pc->cb_info || !foreach_cb) {
3992 LOGE("NULL pointer %p %p", pc, foreach_cb);
3993 return CAMERA_ERROR_INVALID_PARAMETER;
3998 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
3999 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
4001 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4003 LOGD("ret : 0x%x", ret);
4009 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb, void *user_data)
4011 int ret = CAMERA_ERROR_NONE;
4012 camera_cli_s *pc = (camera_cli_s *)camera;
4013 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
4015 if (!pc || !pc->cb_info || !foreach_cb) {
4016 LOGE("NULL pointer %p %p", pc, foreach_cb);
4017 return CAMERA_ERROR_INVALID_PARAMETER;
4022 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
4023 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
4025 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4027 LOGD("ret : 0x%x", ret);
4033 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb, void *user_data)
4035 int ret = CAMERA_ERROR_NONE;
4036 camera_cli_s *pc = (camera_cli_s *)camera;
4037 muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
4039 if (!pc || !pc->cb_info || !foreach_cb) {
4040 LOGE("NULL pointer %p %p", pc, foreach_cb);
4041 return CAMERA_ERROR_INVALID_PARAMETER;
4046 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
4047 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
4049 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4051 LOGD("ret : 0x%x", ret);
4057 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
4059 int ret = CAMERA_ERROR_NONE;
4060 camera_cli_s *pc = (camera_cli_s *)camera;
4061 muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
4063 if (!pc || !pc->cb_info || !width || !height) {
4064 LOGE("NULL pointer %p %p %p", pc, width, height);
4065 return CAMERA_ERROR_INVALID_PARAMETER;
4069 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4071 if (ret == CAMERA_ERROR_NONE) {
4072 *width = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION] >> 16;
4073 *height = 0x0000ffff & pc->cb_info->get_int[MUSE_CAMERA_GET_INT_RECOMMENDED_PREVIEW_RESOLUTION];
4076 LOGD("ret : 0x%x", ret);
4082 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
4084 int ret = CAMERA_ERROR_NONE;
4085 camera_cli_s *pc = (camera_cli_s *)camera;
4086 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
4088 if (!pc || !pc->cb_info || !angle) {
4089 LOGE("NULL pointer %p %p", pc, angle);
4090 return CAMERA_ERROR_INVALID_PARAMETER;
4095 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4097 if (ret == CAMERA_ERROR_NONE)
4098 *angle = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_LENS_ORIENTATION];
4100 LOGD("ret : 0x%x", ret);
4106 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
4108 int ret = CAMERA_ERROR_NONE;
4109 camera_cli_s *pc = (camera_cli_s *)camera;
4110 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
4111 camera_msg_param param;
4112 int set_mode = (int)mode;
4114 if (!pc || !pc->cb_info) {
4115 LOGE("NULL handle");
4116 return CAMERA_ERROR_INVALID_PARAMETER;
4121 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4123 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4125 LOGD("ret : 0x%x", ret);
4131 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
4133 int ret = CAMERA_ERROR_NONE;
4134 camera_cli_s *pc = (camera_cli_s *)camera;
4135 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
4137 if (!pc || !pc->cb_info || !mode) {
4138 LOGE("NULL pointer %p %p", pc, mode);
4139 return CAMERA_ERROR_INVALID_PARAMETER;
4144 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4146 if (ret == CAMERA_ERROR_NONE)
4147 *mode = (camera_attr_theater_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_THEATER_MODE];
4149 LOGD("ret : 0x%x", ret);
4155 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
4157 int ret = CAMERA_ERROR_NONE;
4158 camera_cli_s *pc = (camera_cli_s *)camera;
4159 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
4161 if (!pc || !pc->cb_info || !foreach_cb) {
4162 LOGE("NULL pointer %p %p", pc, foreach_cb);
4163 return CAMERA_ERROR_INVALID_PARAMETER;
4168 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
4169 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
4171 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4173 LOGD("Finish, return :%x", ret);
4179 int camera_attr_set_preview_fps(camera_h camera, camera_attr_fps_e fps)
4181 int ret = CAMERA_ERROR_NONE;
4182 camera_cli_s *pc = (camera_cli_s *)camera;
4183 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
4184 camera_msg_param param;
4185 int set_fps = (int)fps;
4187 if (!pc || !pc->cb_info) {
4188 LOGE("NULL handle");
4189 return CAMERA_ERROR_INVALID_PARAMETER;
4194 CAMERA_MSG_PARAM_SET(param, INT, set_fps);
4196 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4198 LOGD("ret : 0x%x", ret);
4204 int camera_attr_set_image_quality(camera_h camera, int quality)
4206 int ret = CAMERA_ERROR_NONE;
4207 camera_cli_s *pc = (camera_cli_s *)camera;
4208 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4209 camera_msg_param param;
4211 if (!pc || !pc->cb_info) {
4212 LOGE("NULL handle");
4213 return CAMERA_ERROR_INVALID_PARAMETER;
4218 CAMERA_MSG_PARAM_SET(param, INT, quality);
4220 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4222 LOGD("ret : 0x%x", ret);
4228 int camera_attr_get_preview_fps(camera_h camera, camera_attr_fps_e *fps)
4230 int ret = CAMERA_ERROR_NONE;
4231 camera_cli_s *pc = (camera_cli_s *)camera;
4232 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4234 if (!pc || !pc->cb_info || !fps) {
4235 LOGE("NULL pointer %p %p", pc, fps);
4236 return CAMERA_ERROR_INVALID_PARAMETER;
4241 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4243 if (ret == CAMERA_ERROR_NONE)
4244 *fps = (camera_attr_fps_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PREVIEW_FPS];
4246 LOGD("ret : 0x%x", ret);
4252 int camera_attr_get_image_quality(camera_h camera, int *quality)
4254 int ret = CAMERA_ERROR_NONE;
4255 camera_cli_s *pc = (camera_cli_s *)camera;
4256 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4258 if (!pc || !pc->cb_info || !quality) {
4259 LOGE("NULL pointer %p %p", pc, quality);
4260 return CAMERA_ERROR_INVALID_PARAMETER;
4265 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4267 if (ret == CAMERA_ERROR_NONE)
4268 *quality = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_IMAGE_QUALITY];
4270 LOGD("ret : 0x%x", ret);
4276 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4278 int ret = CAMERA_ERROR_NONE;
4279 camera_cli_s *pc = (camera_cli_s *)camera;
4280 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4282 if (!pc || !pc->cb_info || !bitrate) {
4283 LOGE("NULL pointer %p %p", pc, bitrate);
4284 return CAMERA_ERROR_INVALID_PARAMETER;
4289 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4291 if (ret == CAMERA_ERROR_NONE)
4292 *bitrate = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_BITRATE];
4294 LOGD("ret : 0x%x", ret);
4300 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4302 int ret = CAMERA_ERROR_NONE;
4303 camera_cli_s *pc = (camera_cli_s *)camera;
4304 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4305 camera_msg_param param;
4306 int set_bitrate = bitrate;
4308 if (!pc || !pc->cb_info) {
4309 LOGE("NULL handle");
4310 return CAMERA_ERROR_INVALID_PARAMETER;
4315 CAMERA_MSG_PARAM_SET(param, INT, set_bitrate);
4317 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4319 LOGD("ret : 0x%x", ret);
4325 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4327 int ret = CAMERA_ERROR_NONE;
4328 camera_cli_s *pc = (camera_cli_s *)camera;
4329 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4331 if (!pc || !pc->cb_info || !interval) {
4332 LOGE("NULL pointer %p %p", pc, interval);
4333 return CAMERA_ERROR_INVALID_PARAMETER;
4338 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4340 if (ret == CAMERA_ERROR_NONE)
4341 *interval = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENCODED_PREVIEW_GOP_INTERVAL];
4343 LOGD("ret : 0x%x", ret);
4349 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4351 int ret = CAMERA_ERROR_NONE;
4352 camera_cli_s *pc = (camera_cli_s *)camera;
4353 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4354 camera_msg_param param;
4355 int set_gop_interval = interval;
4357 if (!pc || !pc->cb_info) {
4358 LOGE("NULL handle");
4359 return CAMERA_ERROR_INVALID_PARAMETER;
4364 CAMERA_MSG_PARAM_SET(param, INT, set_gop_interval);
4366 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4368 LOGD("ret : 0x%x", ret);
4374 int camera_attr_set_zoom(camera_h camera, int zoom)
4376 int ret = CAMERA_ERROR_NONE;
4377 camera_cli_s *pc = (camera_cli_s *)camera;
4378 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4379 camera_msg_param param;
4381 if (!pc || !pc->cb_info) {
4382 LOGE("NULL handle");
4383 return CAMERA_ERROR_INVALID_PARAMETER;
4386 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4388 CAMERA_MSG_PARAM_SET(param, INT, zoom);
4390 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4392 LOGD("ret : 0x%x", ret);
4398 int camera_attr_set_af_mode(camera_h camera, camera_attr_af_mode_e mode)
4400 int ret = CAMERA_ERROR_NONE;
4401 camera_cli_s *pc = (camera_cli_s *)camera;
4402 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4403 camera_msg_param param;
4404 int set_mode = (int)mode;
4406 if (!pc || !pc->cb_info) {
4407 LOGE("NULL handle");
4408 return CAMERA_ERROR_INVALID_PARAMETER;
4411 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4413 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4415 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4421 int camera_attr_set_af_area(camera_h camera, int x, int y)
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_AREA;
4426 camera_msg_param param;
4429 if (!pc || !pc->cb_info) {
4430 LOGE("NULL handle");
4431 return CAMERA_ERROR_INVALID_PARAMETER;
4434 LOGD("Enter - %d,%d", x, y);
4436 value = (x << 16) | y;
4437 CAMERA_MSG_PARAM_SET(param, INT, value);
4439 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4441 LOGD("ret : 0x%x", ret);
4447 int camera_attr_clear_af_area(camera_h camera)
4449 int ret = CAMERA_ERROR_NONE;
4450 camera_cli_s *pc = (camera_cli_s *)camera;
4451 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4453 if (!pc || !pc->cb_info) {
4454 LOGE("NULL handle");
4455 return CAMERA_ERROR_INVALID_PARAMETER;
4460 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4462 LOGD("ret : 0x%x", ret);
4468 int camera_attr_set_exposure_mode(camera_h camera, camera_attr_exposure_mode_e mode)
4470 int ret = CAMERA_ERROR_NONE;
4471 camera_cli_s *pc = (camera_cli_s *)camera;
4472 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4473 camera_msg_param param;
4474 int set_mode = (int)mode;
4476 if (!pc || !pc->cb_info) {
4477 LOGE("NULL handle");
4478 return CAMERA_ERROR_INVALID_PARAMETER;
4483 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4485 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4487 LOGD("ret : 0x%x", ret);
4493 int camera_attr_set_exposure(camera_h camera, int value)
4495 int ret = CAMERA_ERROR_NONE;
4496 camera_cli_s *pc = (camera_cli_s *)camera;
4497 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4498 camera_msg_param param;
4500 if (!pc || !pc->cb_info) {
4501 LOGE("NULL handle");
4502 return CAMERA_ERROR_INVALID_PARAMETER;
4507 CAMERA_MSG_PARAM_SET(param, INT, value);
4509 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4511 LOGD("ret : 0x%x", ret);
4517 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4519 int ret = CAMERA_ERROR_NONE;
4520 camera_cli_s *pc = (camera_cli_s *)camera;
4521 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4522 camera_msg_param param;
4523 int set_iso = (int)iso;
4525 if (!pc || !pc->cb_info) {
4526 LOGE("NULL handle");
4527 return CAMERA_ERROR_INVALID_PARAMETER;
4532 CAMERA_MSG_PARAM_SET(param, INT, set_iso);
4534 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4536 LOGD("ret : 0x%x", ret);
4542 int camera_attr_set_brightness(camera_h camera, int level)
4544 int ret = CAMERA_ERROR_NONE;
4545 camera_cli_s *pc = (camera_cli_s *)camera;
4546 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4547 camera_msg_param param;
4549 if (!pc || !pc->cb_info) {
4550 LOGE("NULL handle");
4551 return CAMERA_ERROR_INVALID_PARAMETER;
4556 CAMERA_MSG_PARAM_SET(param, INT, level);
4558 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4560 LOGD("ret : 0x%x", ret);
4566 int camera_attr_set_contrast(camera_h camera, int level)
4568 int ret = CAMERA_ERROR_NONE;
4569 camera_cli_s *pc = (camera_cli_s *)camera;
4570 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4571 camera_msg_param param;
4573 if (!pc || !pc->cb_info) {
4574 LOGE("NULL handle");
4575 return CAMERA_ERROR_INVALID_PARAMETER;
4580 CAMERA_MSG_PARAM_SET(param, INT, level);
4582 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4584 LOGD("ret : 0x%x", ret);
4590 int camera_attr_set_hue(camera_h camera, int level)
4592 int ret = CAMERA_ERROR_NONE;
4593 camera_cli_s *pc = (camera_cli_s *)camera;
4594 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HUE;
4595 camera_msg_param param;
4597 if (!pc || !pc->cb_info) {
4598 LOGE("NULL handle");
4599 return CAMERA_ERROR_INVALID_PARAMETER;
4604 CAMERA_MSG_PARAM_SET(param, INT, level);
4606 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4608 LOGD("ret : 0x%x", ret);
4614 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4616 int ret = CAMERA_ERROR_NONE;
4617 camera_cli_s *pc = (camera_cli_s *)camera;
4618 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4619 camera_msg_param param;
4620 int set_whitebalance = (int)wb;
4622 if (!pc || !pc->cb_info) {
4623 LOGE("NULL handle");
4624 return CAMERA_ERROR_INVALID_PARAMETER;
4629 CAMERA_MSG_PARAM_SET(param, INT, set_whitebalance);
4631 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4633 LOGD("ret : 0x%x", ret);
4639 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4641 int ret = CAMERA_ERROR_NONE;
4642 camera_cli_s *pc = (camera_cli_s *)camera;
4643 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4644 camera_msg_param param;
4645 int set_effect = (int)effect;
4647 if (!pc || !pc->cb_info) {
4648 LOGE("NULL handle");
4649 return CAMERA_ERROR_INVALID_PARAMETER;
4654 CAMERA_MSG_PARAM_SET(param, INT, set_effect);
4656 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4658 LOGD("ret : 0x%x", ret);
4664 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4666 int ret = CAMERA_ERROR_NONE;
4667 camera_cli_s *pc = (camera_cli_s *)camera;
4668 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4669 camera_msg_param param;
4670 int set_mode = (int)mode;
4672 if (!pc || !pc->cb_info) {
4673 LOGE("NULL handle");
4674 return CAMERA_ERROR_INVALID_PARAMETER;
4679 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4681 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4683 LOGD("ret : 0x%x", ret);
4689 int camera_attr_enable_tag(camera_h camera, bool enable)
4691 int ret = CAMERA_ERROR_NONE;
4692 camera_cli_s *pc = (camera_cli_s *)camera;
4693 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4694 camera_msg_param param;
4695 int set_enable = (int)enable;
4697 if (!pc || !pc->cb_info) {
4698 LOGE("NULL handle");
4699 return CAMERA_ERROR_INVALID_PARAMETER;
4704 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
4706 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4708 LOGD("ret : 0x%x", ret);
4714 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4716 int ret = CAMERA_ERROR_NONE;
4717 camera_cli_s *pc = (camera_cli_s *)camera;
4718 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4719 camera_msg_param param;
4721 if (!pc || !pc->cb_info || !description) {
4722 LOGE("NULL pointer %p %p", pc, description);
4723 return CAMERA_ERROR_INVALID_PARAMETER;
4728 CAMERA_MSG_PARAM_SET(param, STRING, description);
4730 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4732 LOGD("ret : 0x%x", ret);
4738 int camera_attr_set_tag_orientation(camera_h camera, camera_attr_tag_orientation_e orientation)
4740 int ret = CAMERA_ERROR_NONE;
4741 camera_cli_s *pc = (camera_cli_s *)camera;
4742 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4743 camera_msg_param param;
4744 int set_orientation = (int)orientation;
4746 if (!pc || !pc->cb_info) {
4747 LOGE("NULL handle");
4748 return CAMERA_ERROR_INVALID_PARAMETER;
4753 CAMERA_MSG_PARAM_SET(param, INT, set_orientation);
4755 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4757 LOGD("ret : 0x%x", ret);
4763 int camera_attr_set_tag_software(camera_h camera, const char *software)
4765 int ret = CAMERA_ERROR_NONE;
4766 camera_cli_s *pc = (camera_cli_s *)camera;
4767 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4768 camera_msg_param param;
4770 if (!pc || !pc->cb_info || !software) {
4771 LOGE("NULL pointer %p %p", pc, software);
4772 return CAMERA_ERROR_INVALID_PARAMETER;
4775 LOGD("Enter, remote_handle : %x", pc->remote_handle);
4777 CAMERA_MSG_PARAM_SET(param, STRING, software);
4779 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4781 LOGD("ret : 0x%x", ret);
4787 int camera_attr_set_geotag(camera_h camera, double latitude, double longitude, double altitude)
4789 int ret = CAMERA_ERROR_NONE;
4790 camera_cli_s *pc = (camera_cli_s *)camera;
4791 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4792 double set_geotag[3] = {latitude, longitude, altitude};
4797 if (!pc || !pc->cb_info) {
4798 LOGE("NULL handle");
4799 return CAMERA_ERROR_INVALID_PARAMETER;
4804 length = sizeof(set_geotag) / sizeof(int) + \
4805 (sizeof(set_geotag) % sizeof(int) ? 1 : 0);
4807 msg = muse_core_msg_new(api,
4808 MUSE_TYPE_ARRAY, "set_geotag", length, (int *)set_geotag,
4811 LOGE("msg creation failed: api %d", api);
4812 return CAMERA_ERROR_OUT_OF_MEMORY;
4815 if (pc->cb_info->is_server_connected) {
4816 __camera_update_api_waiting(pc->cb_info, api, 1);
4818 g_mutex_lock(&pc->cb_info->fd_lock);
4819 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
4820 g_mutex_unlock(&pc->cb_info->fd_lock);
4824 LOGE("message send failed");
4825 ret = CAMERA_ERROR_INVALID_OPERATION;
4827 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
4830 __camera_update_api_waiting(pc->cb_info, api, -1);
4832 muse_core_msg_free(msg);
4834 LOGD("ret : 0x%x", ret);
4840 int camera_attr_remove_geotag(camera_h camera)
4842 int ret = CAMERA_ERROR_NONE;
4843 camera_cli_s *pc = (camera_cli_s *)camera;
4844 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4846 if (!pc || !pc->cb_info) {
4847 LOGE("NULL handle");
4848 return CAMERA_ERROR_INVALID_PARAMETER;
4853 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4855 LOGD("ret : 0x%x", ret);
4861 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4863 int ret = CAMERA_ERROR_NONE;
4864 camera_cli_s *pc = (camera_cli_s *)camera;
4865 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
4866 camera_msg_param param;
4867 int set_mode = (int)mode;
4869 if (!pc || !pc->cb_info) {
4870 LOGE("NULL handle");
4871 return CAMERA_ERROR_INVALID_PARAMETER;
4876 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
4878 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
4880 LOGD("ret : 0x%x", ret);
4886 int camera_attr_get_zoom(camera_h camera, int *zoom)
4888 int ret = CAMERA_ERROR_NONE;
4889 camera_cli_s *pc = (camera_cli_s *)camera;
4890 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4892 if (!pc || !pc->cb_info || !zoom) {
4893 LOGE("NULL pointer %p %p", pc, zoom);
4894 return CAMERA_ERROR_INVALID_PARAMETER;
4899 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4901 if (ret == CAMERA_ERROR_NONE)
4902 *zoom = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ZOOM];
4904 LOGD("ret : 0x%x", ret);
4910 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
4912 int ret = CAMERA_ERROR_NONE;
4913 camera_cli_s *pc = (camera_cli_s *)camera;
4914 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
4916 if (!pc || !pc->cb_info || !min || !max) {
4917 LOGE("NULL pointer %p %p %p", pc, min, max);
4918 return CAMERA_ERROR_INVALID_PARAMETER;
4923 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4925 if (ret == CAMERA_ERROR_NONE) {
4926 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][0];
4927 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_ZOOM_RANGE][1];
4930 LOGD("ret : 0x%x", ret);
4936 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
4938 int ret = CAMERA_ERROR_NONE;
4939 camera_cli_s *pc = (camera_cli_s *)camera;
4940 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
4942 if (!pc || !pc->cb_info || !mode) {
4943 LOGE("NULL pointer %p %p", pc, mode);
4944 return CAMERA_ERROR_INVALID_PARAMETER;
4949 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4951 if (ret == CAMERA_ERROR_NONE)
4952 *mode = (camera_attr_af_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_AF_MODE];
4954 LOGD("ret : 0x%x", ret);
4960 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
4962 int ret = CAMERA_ERROR_NONE;
4963 camera_cli_s *pc = (camera_cli_s *)camera;
4964 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
4966 if (!pc || !pc->cb_info || !mode) {
4967 LOGE("NULL pointer %p %p", pc, mode);
4968 return CAMERA_ERROR_INVALID_PARAMETER;
4973 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4975 if (ret == CAMERA_ERROR_NONE)
4976 *mode = (camera_attr_exposure_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE_MODE];
4978 LOGD("ret : 0x%x", ret);
4984 int camera_attr_get_exposure(camera_h camera, int *value)
4986 int ret = CAMERA_ERROR_NONE;
4987 camera_cli_s *pc = (camera_cli_s *)camera;
4988 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
4990 if (!pc || !pc->cb_info || !value) {
4991 LOGE("NULL pointer %p %p", pc, value);
4992 return CAMERA_ERROR_INVALID_PARAMETER;
4997 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
4999 if (ret == CAMERA_ERROR_NONE)
5000 *value = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EXPOSURE];
5002 LOGD("ret : 0x%x", ret);
5008 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
5010 int ret = CAMERA_ERROR_NONE;
5011 camera_cli_s *pc = (camera_cli_s *)camera;
5012 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
5014 if (!pc || !pc->cb_info || !min || !max) {
5015 LOGE("NULL pointer %p %p %p", pc, min, max);
5016 return CAMERA_ERROR_INVALID_PARAMETER;
5021 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5023 if (ret == CAMERA_ERROR_NONE) {
5024 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][0];
5025 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_EXPOSURE_RANGE][1];
5028 LOGD("ret : 0x%x", ret);
5034 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
5036 int ret = CAMERA_ERROR_NONE;
5037 camera_cli_s *pc = (camera_cli_s *)camera;
5038 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
5040 if (!pc || !pc->cb_info || !iso) {
5041 LOGE("NULL pointer %p %p", pc, iso);
5042 return CAMERA_ERROR_INVALID_PARAMETER;
5047 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5049 if (ret == CAMERA_ERROR_NONE)
5050 *iso = (camera_attr_iso_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ISO];
5052 LOGD("ret : 0x%x", ret);
5058 int camera_attr_get_brightness(camera_h camera, int *level)
5060 int ret = CAMERA_ERROR_NONE;
5061 camera_cli_s *pc = (camera_cli_s *)camera;
5062 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
5064 if (!pc || !pc->cb_info || !level) {
5065 LOGE("NULL pointer %p %p", pc, level);
5066 return CAMERA_ERROR_INVALID_PARAMETER;
5071 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5073 if (ret == CAMERA_ERROR_NONE)
5074 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_BRIGHTNESS];
5076 LOGD("ret : 0x%x", ret);
5082 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
5084 int ret = CAMERA_ERROR_NONE;
5085 camera_cli_s *pc = (camera_cli_s *)camera;
5086 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
5088 if (!pc || !pc->cb_info || !min || !max) {
5089 LOGE("NULL pointer %p %p %p", pc, min, max);
5090 return CAMERA_ERROR_INVALID_PARAMETER;
5095 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5097 if (ret == CAMERA_ERROR_NONE) {
5098 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][0];
5099 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_BRIGHTNESS_RANGE][1];
5102 LOGD("ret : 0x%x", ret);
5108 int camera_attr_get_contrast(camera_h camera, int *level)
5110 int ret = CAMERA_ERROR_NONE;
5111 camera_cli_s *pc = (camera_cli_s *)camera;
5112 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
5114 if (!pc || !pc->cb_info || !level) {
5115 LOGE("NULL pointer %p %p", pc, level);
5116 return CAMERA_ERROR_INVALID_PARAMETER;
5121 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5123 if (ret == CAMERA_ERROR_NONE)
5124 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_CONTRAST];
5126 LOGD("ret : 0x%x", ret);
5132 int camera_attr_get_contrast_range(camera_h camera, int *min, int *max)
5134 int ret = CAMERA_ERROR_NONE;
5135 camera_cli_s *pc = (camera_cli_s *)camera;
5136 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
5138 if (!pc || !pc->cb_info || !min || !max) {
5139 LOGE("NULL pointer %p %p %p", pc, min, max);
5140 return CAMERA_ERROR_INVALID_PARAMETER;
5145 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5147 if (ret == CAMERA_ERROR_NONE) {
5148 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][0];
5149 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_CONTRAST_RANGE][1];
5150 LOGD("min %d, max %d", *min, *max);
5153 LOGD("ret : 0x%x", ret);
5159 int camera_attr_get_hue(camera_h camera, int *level)
5161 int ret = CAMERA_ERROR_NONE;
5162 camera_cli_s *pc = (camera_cli_s *)camera;
5163 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE;
5165 if (!pc || !pc->cb_info || !level) {
5166 LOGE("NULL pointer %p %p", pc, level);
5167 return CAMERA_ERROR_INVALID_PARAMETER;
5172 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5174 if (ret == CAMERA_ERROR_NONE)
5175 *level = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HUE];
5177 LOGD("ret : 0x%x", ret);
5183 int camera_attr_get_hue_range(camera_h camera, int *min, int *max)
5185 int ret = CAMERA_ERROR_NONE;
5186 camera_cli_s *pc = (camera_cli_s *)camera;
5187 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HUE_RANGE;
5189 if (!pc || !pc->cb_info || !min || !max) {
5190 LOGE("NULL pointer %p %p %p", pc, min, max);
5191 return CAMERA_ERROR_INVALID_PARAMETER;
5196 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5198 if (ret == CAMERA_ERROR_NONE) {
5199 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][0];
5200 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_HUE_RANGE][1];
5201 LOGD("min %d, max %d", *min, *max);
5204 LOGD("ret : 0x%x", ret);
5210 int camera_attr_get_whitebalance(camera_h camera, camera_attr_whitebalance_e *wb)
5212 int ret = CAMERA_ERROR_NONE;
5213 camera_cli_s *pc = (camera_cli_s *)camera;
5214 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
5216 if (!pc || !pc->cb_info || !wb) {
5217 LOGE("NULL pointer %p %p", pc, wb);
5218 return CAMERA_ERROR_INVALID_PARAMETER;
5223 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5225 if (ret == CAMERA_ERROR_NONE)
5226 *wb = (camera_attr_whitebalance_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_WHITE_BALANCE];
5228 LOGD("ret : 0x%x", ret);
5234 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5236 int ret = CAMERA_ERROR_NONE;
5237 camera_cli_s *pc = (camera_cli_s *)camera;
5238 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5240 if (!pc || !pc->cb_info || !effect) {
5241 LOGE("NULL pointer %p %p", pc, effect);
5242 return CAMERA_ERROR_INVALID_PARAMETER;
5247 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5249 if (ret == CAMERA_ERROR_NONE)
5250 *effect = (camera_attr_effect_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_EFFECT];
5252 LOGD("ret : 0x%x", ret);
5258 int camera_attr_get_scene_mode(camera_h camera, camera_attr_scene_mode_e *mode)
5260 int ret = CAMERA_ERROR_NONE;
5261 camera_cli_s *pc = (camera_cli_s *)camera;
5262 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5264 if (!pc || !pc->cb_info || !mode) {
5265 LOGE("NULL pointer %p %p", pc, mode);
5266 return CAMERA_ERROR_INVALID_PARAMETER;
5271 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5273 if (ret == CAMERA_ERROR_NONE)
5274 *mode = (camera_attr_scene_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_SCENE_MODE];
5276 LOGD("ret : 0x%x", ret);
5282 int camera_attr_is_enabled_tag(camera_h camera, bool *enable)
5284 int ret = CAMERA_ERROR_NONE;
5285 camera_cli_s *pc = (camera_cli_s *)camera;
5286 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5288 if (!pc || !pc->cb_info || !enable) {
5289 LOGE("NULL pointer %p %p", pc, enable);
5290 return CAMERA_ERROR_INVALID_PARAMETER;
5295 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5297 if (ret == CAMERA_ERROR_NONE)
5298 *enable = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_TAG];
5300 LOGD("ret : 0x%x", ret);
5306 int camera_attr_get_tag_image_description(camera_h camera, char **description)
5308 int ret = CAMERA_ERROR_NONE;
5309 camera_cli_s *pc = (camera_cli_s *)camera;
5310 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5312 if (!pc || !pc->cb_info || !description) {
5313 LOGE("NULL pointer %p %p", pc, description);
5314 return CAMERA_ERROR_INVALID_PARAMETER;
5319 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5321 if (ret == CAMERA_ERROR_NONE)
5322 *description = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_IMAGE_DESCRIPTION]);
5324 LOGD("ret : 0x%x", ret);
5330 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5332 int ret = CAMERA_ERROR_NONE;
5333 camera_cli_s *pc = (camera_cli_s *)camera;
5334 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5336 if (!pc || !pc->cb_info || !orientation) {
5337 LOGE("NULL pointer %p %p", pc, orientation);
5338 return CAMERA_ERROR_INVALID_PARAMETER;
5343 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5345 if (ret == CAMERA_ERROR_NONE)
5346 *orientation = (camera_attr_tag_orientation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TAG_ORIENTATION];
5348 LOGD("ret : 0x%x", ret);
5354 int camera_attr_get_tag_software(camera_h camera, char **software)
5356 int ret = CAMERA_ERROR_NONE;
5357 camera_cli_s *pc = (camera_cli_s *)camera;
5358 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5360 if (!pc || !pc->cb_info || !software) {
5361 LOGE("NULL pointer %p %p", pc, software);
5362 return CAMERA_ERROR_INVALID_PARAMETER;
5367 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5369 if (ret == CAMERA_ERROR_NONE)
5370 *software = strdup(pc->cb_info->get_string[MUSE_CAMERA_GET_STRING_TAG_SOFTWARE]);
5372 LOGD("ret : 0x%x", ret);
5378 int camera_attr_get_geotag(camera_h camera, double *latitude, double *longitude, double *altitude)
5380 int ret = CAMERA_ERROR_NONE;
5381 camera_cli_s *pc = (camera_cli_s *)camera;
5382 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5384 if (!pc || !pc->cb_info || !latitude || !longitude || !altitude) {
5385 LOGE("NULL pointer %p %p %p %p", pc, latitude, longitude, altitude);
5386 return CAMERA_ERROR_INVALID_PARAMETER;
5391 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5393 if (ret == CAMERA_ERROR_NONE) {
5394 *latitude = pc->cb_info->get_geotag[0];
5395 *longitude = pc->cb_info->get_geotag[1];
5396 *altitude = pc->cb_info->get_geotag[2];
5399 LOGD("ret : 0x%x", ret);
5405 int camera_attr_get_flash_mode(camera_h camera, camera_attr_flash_mode_e *mode)
5407 int ret = CAMERA_ERROR_NONE;
5408 camera_cli_s *pc = (camera_cli_s *)camera;
5409 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5411 if (!pc || !pc->cb_info || !mode) {
5412 LOGE("NULL pointer %p %p", pc, mode);
5413 return CAMERA_ERROR_INVALID_PARAMETER;
5418 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5420 if (ret == CAMERA_ERROR_NONE)
5421 *mode = (camera_attr_flash_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_FLASH_MODE];
5423 LOGD("ret : 0x%x", ret);
5429 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5431 int ret = CAMERA_ERROR_NONE;
5432 int get_flash_state = 0;
5435 LOGE("NULL pointer");
5436 return CAMERA_ERROR_INVALID_PARAMETER;
5439 ret = _camera_independent_request(MUSE_CAMERA_API_GET_FLASH_STATE,
5440 (int)device, "get_flash_state", &get_flash_state);
5442 if (ret == CAMERA_ERROR_NONE) {
5443 *state = (camera_flash_state_e)get_flash_state;
5444 LOGD("flash state %d", *state);
5446 LOGE("failed 0x%x", ret);
5453 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5455 int ret = CAMERA_ERROR_NONE;
5456 camera_cli_s *pc = (camera_cli_s *)camera;
5457 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5459 if (!pc || !pc->cb_info || !foreach_cb) {
5460 LOGE("NULL pointer %p %p", pc, foreach_cb);
5461 return CAMERA_ERROR_INVALID_PARAMETER;
5466 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5467 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5469 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5471 LOGD("ret : 0x%x", ret);
5477 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb, void *user_data)
5479 int ret = CAMERA_ERROR_NONE;
5480 camera_cli_s *pc = (camera_cli_s *)camera;
5481 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5483 if (!pc || !pc->cb_info || !foreach_cb) {
5484 LOGE("NULL pointer %p %p", pc, foreach_cb);
5485 return CAMERA_ERROR_INVALID_PARAMETER;
5490 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5491 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5493 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5495 LOGD("ret : 0x%x", ret);
5501 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5503 int ret = CAMERA_ERROR_NONE;
5504 camera_cli_s *pc = (camera_cli_s *)camera;
5505 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5507 if (!pc || !pc->cb_info || !foreach_cb) {
5508 LOGE("NULL pointer %p %p", pc, foreach_cb);
5509 return CAMERA_ERROR_INVALID_PARAMETER;
5514 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5515 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5517 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5519 LOGD("ret : 0x%x", ret);
5525 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb, void *user_data)
5527 int ret = CAMERA_ERROR_NONE;
5528 camera_cli_s *pc = (camera_cli_s *)camera;
5529 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5531 if (!pc || !pc->cb_info || !foreach_cb) {
5532 LOGE("NULL pointer %p %p", pc, foreach_cb);
5533 return CAMERA_ERROR_INVALID_PARAMETER;
5538 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5539 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5541 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5543 LOGD("ret : 0x%x", ret);
5549 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb, void *user_data)
5551 int ret = CAMERA_ERROR_NONE;
5552 camera_cli_s *pc = (camera_cli_s *)camera;
5553 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5555 if (!pc || !pc->cb_info || !foreach_cb) {
5556 LOGE("NULL pointer %p %p", pc, foreach_cb);
5557 return CAMERA_ERROR_INVALID_PARAMETER;
5562 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5563 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5565 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5567 LOGD("ret : 0x%x", ret);
5573 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb, void *user_data)
5575 int ret = CAMERA_ERROR_NONE;
5576 camera_cli_s *pc = (camera_cli_s *)camera;
5577 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5579 if (!pc || !pc->cb_info || !foreach_cb) {
5580 LOGE("NULL pointer %p %p", pc, foreach_cb);
5581 return CAMERA_ERROR_INVALID_PARAMETER;
5586 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5587 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5589 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5591 LOGD("ret : 0x%x", ret);
5597 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb, void *user_data)
5599 int ret = CAMERA_ERROR_NONE;
5600 camera_cli_s *pc = (camera_cli_s *)camera;
5601 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5603 if (!pc || !pc->cb_info || !foreach_cb) {
5604 LOGE("NULL pointer %p %p", pc, foreach_cb);
5605 return CAMERA_ERROR_INVALID_PARAMETER;
5610 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5611 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5613 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5615 LOGD("ret : 0x%x", ret);
5621 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb, void *user_data)
5623 int ret = CAMERA_ERROR_NONE;
5624 camera_cli_s *pc = (camera_cli_s *)camera;
5625 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5627 if (!pc || !pc->cb_info || !foreach_cb) {
5628 LOGE("NULL pointer %p %p", pc, foreach_cb);
5629 return CAMERA_ERROR_INVALID_PARAMETER;
5634 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5635 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5637 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5639 LOGD("Enter, handle :%x", pc->remote_handle);
5645 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)
5647 int ret = CAMERA_ERROR_NONE;
5648 camera_cli_s *pc = (camera_cli_s *)camera;
5649 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5650 camera_msg_param param;
5653 if (!pc || !pc->cb_info || !foreach_cb) {
5654 LOGE("NULL pointer %p %p", pc, foreach_cb);
5655 return CAMERA_ERROR_INVALID_PARAMETER;
5660 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5661 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5663 value = (width << 16) | height;
5664 CAMERA_MSG_PARAM_SET(param, INT, value);
5666 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5668 LOGD("ret : 0x%x", ret);
5674 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5676 int ret = CAMERA_ERROR_NONE;
5677 camera_cli_s *pc = (camera_cli_s *)camera;
5678 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5680 if (!pc || !pc->cb_info || !foreach_cb) {
5681 LOGE("NULL pointer %p %p", pc, foreach_cb);
5682 return CAMERA_ERROR_INVALID_PARAMETER;
5687 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5688 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5690 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5692 LOGD("ret : 0x%x", ret);
5698 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5700 int ret = CAMERA_ERROR_NONE;
5701 camera_cli_s *pc = (camera_cli_s *)camera;
5702 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5704 if (!pc || !pc->cb_info || !foreach_cb) {
5705 LOGE("NULL pointer %p %p", pc, foreach_cb);
5706 return CAMERA_ERROR_INVALID_PARAMETER;
5711 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5712 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5714 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5716 LOGD("ret : 0x%x", ret);
5722 int camera_attr_set_stream_rotation(camera_h camera, camera_rotation_e rotation)
5724 int ret = CAMERA_ERROR_NONE;
5725 camera_cli_s *pc = (camera_cli_s *)camera;
5726 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5727 camera_msg_param param;
5728 int set_rotation = (int)rotation;
5730 if (!pc || !pc->cb_info) {
5731 LOGE("NULL handle");
5732 return CAMERA_ERROR_INVALID_PARAMETER;
5737 CAMERA_MSG_PARAM_SET(param, INT, set_rotation);
5739 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5741 LOGD("ret : 0x%x", ret);
5747 int camera_attr_get_stream_rotation(camera_h camera, camera_rotation_e *rotation)
5749 int ret = CAMERA_ERROR_NONE;
5750 camera_cli_s *pc = (camera_cli_s *)camera;
5751 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5753 if (!pc || !pc->cb_info || !rotation) {
5754 LOGE("NULL pointer %p %p", pc, rotation);
5755 return CAMERA_ERROR_INVALID_PARAMETER;
5760 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5762 if (ret == CAMERA_ERROR_NONE)
5763 *rotation = (camera_rotation_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_ROTATION];
5765 LOGD("ret : 0x%x", ret);
5771 int camera_attr_set_stream_flip(camera_h camera, camera_flip_e flip)
5773 int ret = CAMERA_ERROR_NONE;
5774 camera_cli_s *pc = (camera_cli_s *)camera;
5775 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5776 camera_msg_param param;
5777 int set_flip = (int)flip;
5779 if (!pc || !pc->cb_info) {
5780 LOGE("NULL handle");
5781 return CAMERA_ERROR_INVALID_PARAMETER;
5786 CAMERA_MSG_PARAM_SET(param, INT, set_flip);
5788 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5790 LOGD("ret : 0x%x", ret);
5796 int camera_attr_get_stream_flip(camera_h camera, camera_flip_e *flip)
5798 int ret = CAMERA_ERROR_NONE;
5799 camera_cli_s *pc = (camera_cli_s *)camera;
5800 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5802 if (!pc || !pc->cb_info || !flip) {
5803 LOGE("NULL pointer %p %p", pc, flip);
5804 return CAMERA_ERROR_INVALID_PARAMETER;
5809 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5811 if (ret == CAMERA_ERROR_NONE)
5812 *flip = (camera_flip_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_STREAM_FLIP];
5814 LOGD("ret : 0x%x", ret);
5819 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
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_SET_HDR_MODE;
5824 camera_msg_param param;
5825 int set_mode = (int)mode;
5827 if (!pc || !pc->cb_info) {
5828 LOGE("NULL handle");
5829 return CAMERA_ERROR_INVALID_PARAMETER;
5834 CAMERA_MSG_PARAM_SET(param, INT, set_mode);
5836 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5838 LOGD("ret : 0x%x", ret);
5844 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5846 int ret = CAMERA_ERROR_NONE;
5847 camera_cli_s *pc = (camera_cli_s *)camera;
5848 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5850 if (!pc || !pc->cb_info || !mode) {
5851 LOGE("NULL pointer %p %p", pc, mode);
5852 return CAMERA_ERROR_INVALID_PARAMETER;
5857 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5859 if (ret == CAMERA_ERROR_NONE)
5860 *mode = (camera_attr_hdr_mode_e)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_HDR_MODE];
5862 LOGD("ret : 0x%x", ret);
5868 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5870 int ret = CAMERA_ERROR_NONE;
5871 camera_cli_s *pc = (camera_cli_s *)camera;
5872 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
5874 if (!pc || !pc->cb_info) {
5875 LOGE("NULL handle");
5876 return CAMERA_ERROR_INVALID_PARAMETER;
5881 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5884 LOGE("error is occurred 0x%x", ret);
5888 LOGD("ret : %d", ret);
5894 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5896 int ret = CAMERA_ERROR_NONE;
5897 camera_cli_s *pc = (camera_cli_s *)camera;
5898 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5900 if (!pc || !pc->cb_info) {
5901 LOGE("NULL handle");
5902 return CAMERA_ERROR_INVALID_PARAMETER;
5907 if (!camera_attr_is_supported_hdr_capture(camera)) {
5908 LOGE("HDR not supported");
5909 return CAMERA_ERROR_NOT_SUPPORTED;
5913 LOGE("NULL callback");
5914 return CAMERA_ERROR_INVALID_PARAMETER;
5917 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5919 if (ret == CAMERA_ERROR_NONE) {
5920 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5922 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5923 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5925 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5928 LOGD("ret : 0x%x", ret);
5934 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5936 int ret = CAMERA_ERROR_NONE;
5937 camera_cli_s *pc = (camera_cli_s *)camera;
5938 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5940 if (!pc || !pc->cb_info) {
5941 LOGE("NULL handle");
5942 return CAMERA_ERROR_INVALID_PARAMETER;
5947 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
5949 if (ret == CAMERA_ERROR_NONE) {
5950 g_mutex_lock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5952 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5953 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = NULL;
5955 g_mutex_unlock(&pc->cb_info->user_cb_mutex[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS]);
5958 LOGD("ret : 0x%x", ret);
5964 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
5966 int ret = CAMERA_ERROR_NONE;
5967 camera_cli_s *pc = (camera_cli_s *)camera;
5968 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
5969 camera_msg_param param;
5970 int set_enable = (int)enable;
5972 if (!pc || !pc->cb_info) {
5973 LOGE("NULL handle");
5974 return CAMERA_ERROR_INVALID_PARAMETER;
5979 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
5981 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
5983 LOGD("ret : 0x%x", ret);
5989 int camera_attr_is_enabled_anti_shake(camera_h camera, bool *enabled)
5991 int ret = CAMERA_ERROR_NONE;
5992 camera_cli_s *pc = (camera_cli_s *)camera;
5993 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
5995 if (!pc || !pc->cb_info || !enabled) {
5996 LOGE("NULL pointer %p %p", pc, enabled);
5997 return CAMERA_ERROR_INVALID_PARAMETER;
6002 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6004 if (ret == CAMERA_ERROR_NONE)
6005 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_ANTI_SHAKE];
6007 LOGD("ret : 0x%x", ret);
6013 bool camera_attr_is_supported_anti_shake(camera_h camera)
6015 int ret = CAMERA_ERROR_NONE;
6016 camera_cli_s *pc = (camera_cli_s *)camera;
6017 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
6019 if (!pc || !pc->cb_info) {
6020 LOGE("NULL handle");
6021 return CAMERA_ERROR_INVALID_PARAMETER;
6026 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6029 LOGE("error is occurred 0x%x", ret);
6033 LOGD("ret : %d", ret);
6039 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
6041 int ret = CAMERA_ERROR_NONE;
6042 camera_cli_s *pc = (camera_cli_s *)camera;
6043 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
6044 camera_msg_param param;
6045 int set_enable = (int)enable;
6047 if (!pc || !pc->cb_info) {
6048 LOGE("NULL handle");
6049 return CAMERA_ERROR_INVALID_PARAMETER;
6054 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6056 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6058 LOGD("ret : 0x%x", ret);
6064 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
6066 int ret = CAMERA_ERROR_NONE;
6067 camera_cli_s *pc = (camera_cli_s *)camera;
6068 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
6070 if (!pc || !pc->cb_info || !enabled) {
6071 LOGE("NULL pointer %p %p", pc, enabled);
6072 return CAMERA_ERROR_INVALID_PARAMETER;
6077 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6079 if (ret == CAMERA_ERROR_NONE)
6080 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_VIDEO_STABILIZATION];
6082 LOGD("ret : 0x%x", ret);
6088 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6090 int ret = CAMERA_ERROR_NONE;
6091 camera_cli_s *pc = (camera_cli_s *)camera;
6092 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6094 if (!pc || !pc->cb_info) {
6095 LOGE("NULL handle");
6096 return CAMERA_ERROR_INVALID_PARAMETER;
6101 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6104 LOGE("error is occurred 0x%x", ret);
6108 LOGD("ret : %d", ret);
6114 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6116 int ret = CAMERA_ERROR_NONE;
6117 camera_cli_s *pc = (camera_cli_s *)camera;
6118 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6119 camera_msg_param param;
6120 int set_enable = (int)enable;
6122 if (!pc || !pc->cb_info) {
6123 LOGE("NULL handle");
6124 return CAMERA_ERROR_INVALID_PARAMETER;
6129 CAMERA_MSG_PARAM_SET(param, INT, set_enable);
6131 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6133 LOGD("ret : 0x%x", ret);
6139 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6141 int ret = CAMERA_ERROR_NONE;
6142 camera_cli_s *pc = (camera_cli_s *)camera;
6143 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6145 if (!pc || !pc->cb_info || !enabled) {
6146 LOGE("NULL pointer %p %p", pc, enabled);
6147 return CAMERA_ERROR_INVALID_PARAMETER;
6152 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6154 if (ret == CAMERA_ERROR_NONE)
6155 *enabled = (bool)pc->cb_info->get_int[MUSE_CAMERA_GET_INT_ENABLED_AUTO_CONTRAST];
6157 LOGD("ret : 0x%x", ret);
6163 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6165 int ret = CAMERA_ERROR_NONE;
6166 camera_cli_s *pc = (camera_cli_s *)camera;
6167 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6169 if (!pc || !pc->cb_info) {
6170 LOGE("NULL handle");
6171 return CAMERA_ERROR_INVALID_PARAMETER;
6176 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6179 LOGE("error is occurred 0x%x", ret);
6183 LOGD("ret : %d", ret);
6189 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6191 int ret = CAMERA_ERROR_NONE;
6192 camera_cli_s *pc = (camera_cli_s *)camera;
6193 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6194 camera_msg_param param;
6195 int set_disable = (int)disable;
6197 if (!pc || !pc->cb_info) {
6198 LOGE("NULL handle");
6199 return CAMERA_ERROR_INVALID_PARAMETER;
6204 CAMERA_MSG_PARAM_SET(param, INT, set_disable);
6206 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6208 LOGD("ret : 0x%x", ret);
6214 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6216 int ret = CAMERA_ERROR_NONE;
6217 camera_cli_s *pc = (camera_cli_s *)camera;
6218 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6219 camera_msg_param param;
6220 int set_move_type = (int)move_type;
6223 if (!pc || !pc->cb_info) {
6224 LOGE("NULL handle");
6225 return CAMERA_ERROR_INVALID_PARAMETER;
6230 value = (set_move_type << 16) | pan_step;
6231 CAMERA_MSG_PARAM_SET(param, INT, value);
6233 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6235 LOGD("ret : 0x%x", ret);
6241 int camera_attr_get_pan(camera_h camera, int *pan_step)
6243 int ret = CAMERA_ERROR_NONE;
6244 camera_cli_s *pc = (camera_cli_s *)camera;
6245 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6247 if (!pc || !pc->cb_info || !pan_step) {
6248 LOGE("NULL pointer %p %p", pc, pan_step);
6249 return CAMERA_ERROR_INVALID_PARAMETER;
6254 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6256 if (ret == CAMERA_ERROR_NONE)
6257 *pan_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_PAN];
6259 LOGD("ret : 0x%x", ret);
6265 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6267 int ret = CAMERA_ERROR_NONE;
6268 camera_cli_s *pc = (camera_cli_s *)camera;
6269 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6271 if (!pc || !pc->cb_info || !min || !max) {
6272 LOGE("NULL pointer %p %p %p", pc, min, max);
6273 return CAMERA_ERROR_INVALID_PARAMETER;
6278 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6280 if (ret == CAMERA_ERROR_NONE) {
6281 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][0];
6282 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_PAN_RANGE][1];
6285 LOGD("ret : 0x%x", ret);
6291 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6293 int ret = CAMERA_ERROR_NONE;
6294 camera_cli_s *pc = (camera_cli_s *)camera;
6295 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6296 camera_msg_param param;
6297 int set_move_type = (int)move_type;
6300 if (!pc || !pc->cb_info) {
6301 LOGE("NULL handle");
6302 return CAMERA_ERROR_INVALID_PARAMETER;
6307 value = (set_move_type << 16) | tilt_step;
6308 CAMERA_MSG_PARAM_SET(param, INT, value);
6310 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6312 LOGD("ret : 0x%x", ret);
6318 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6320 int ret = CAMERA_ERROR_NONE;
6321 camera_cli_s *pc = (camera_cli_s *)camera;
6322 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6324 if (!pc || !pc->cb_info || !tilt_step) {
6325 LOGE("NULL pointer %p %p", pc, tilt_step);
6326 return CAMERA_ERROR_INVALID_PARAMETER;
6331 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6333 if (ret == CAMERA_ERROR_NONE)
6334 *tilt_step = pc->cb_info->get_int[MUSE_CAMERA_GET_INT_TILT];
6336 LOGD("ret : 0x%x", ret);
6342 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6344 int ret = CAMERA_ERROR_NONE;
6345 camera_cli_s *pc = (camera_cli_s *)camera;
6346 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6348 if (!pc || !pc->cb_info || !min || !max) {
6349 LOGE("NULL pointer %p %p %p", pc, min, max);
6350 return CAMERA_ERROR_INVALID_PARAMETER;
6355 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6357 if (ret == CAMERA_ERROR_NONE) {
6358 *min = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][0];
6359 *max = pc->cb_info->get_int_pair[MUSE_CAMERA_GET_INT_PAIR_TILT_RANGE][1];
6362 LOGD("ret : 0x%x", ret);
6368 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6370 int ret = CAMERA_ERROR_NONE;
6371 camera_cli_s *pc = (camera_cli_s *)camera;
6372 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6373 camera_msg_param param;
6374 int set_ptz_type = (int)ptz_type;
6376 if (!pc || !pc->cb_info) {
6377 LOGE("NULL handle");
6378 return CAMERA_ERROR_INVALID_PARAMETER;
6383 CAMERA_MSG_PARAM_SET(param, INT, set_ptz_type);
6385 _camera_msg_send_param1(api, pc->cb_info, &ret, ¶m, CAMERA_CB_TIMEOUT);
6387 LOGD("ret : 0x%x", ret);
6393 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6395 int ret = CAMERA_ERROR_NONE;
6396 camera_cli_s *pc = (camera_cli_s *)camera;
6397 muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6399 if (!pc || !pc->cb_info || !foreach_cb) {
6400 LOGE("NULL pointer %p %p", pc, foreach_cb);
6401 return CAMERA_ERROR_INVALID_PARAMETER;
6406 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6407 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6409 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6411 LOGD("ret : 0x%x", ret);
6417 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6419 int ret = CAMERA_ERROR_NONE;
6420 camera_cli_s *pc = (camera_cli_s *)camera;
6421 muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6422 int set_display_roi_area[4] = {x, y, width, height};
6427 if (!pc || !pc->cb_info) {
6428 LOGE("NULL handle");
6429 return CAMERA_ERROR_INVALID_PARAMETER;
6434 if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6435 ret = mm_display_interface_evas_set_roi_area(pc->cb_info->dp_interface, x, y, width, height);
6436 if (ret != MM_ERROR_NONE) {
6437 LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6438 return CAMERA_ERROR_INVALID_OPERATION;
6442 length = sizeof(set_display_roi_area) / sizeof(int) + \
6443 (sizeof(set_display_roi_area) % sizeof(int) ? 1 : 0);
6445 msg = muse_core_msg_new(api,
6446 MUSE_TYPE_ARRAY, "set_display_roi_area", length, (int *)set_display_roi_area,
6449 LOGE("msg creation failed: api %d", api);
6450 return CAMERA_ERROR_OUT_OF_MEMORY;
6453 if (pc->cb_info->is_server_connected) {
6454 __camera_update_api_waiting(pc->cb_info, api, 1);
6456 g_mutex_lock(&pc->cb_info->fd_lock);
6457 send_ret = muse_core_msg_send(pc->cb_info->fd, msg);
6458 g_mutex_unlock(&pc->cb_info->fd_lock);
6462 LOGE("message send failed");
6463 ret = CAMERA_ERROR_INVALID_OPERATION;
6465 ret = _camera_client_wait_for_cb_return(api, pc->cb_info, CAMERA_CB_TIMEOUT);
6468 __camera_update_api_waiting(pc->cb_info, api, -1);
6470 muse_core_msg_free(msg);
6472 LOGD("ret : 0x%x", ret);
6478 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6480 camera_cli_s *pc = (camera_cli_s *)camera;
6481 int ret = CAMERA_ERROR_NONE;
6482 muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6484 if (!pc || !pc->cb_info || !x || !y || !width || !height) {
6485 LOGE("NULL pointer %p %p %p %p %p", pc, x, y, width, height);
6486 return CAMERA_ERROR_INVALID_PARAMETER;
6491 _camera_msg_send(api, pc->cb_info, &ret, CAMERA_CB_TIMEOUT);
6493 if (ret == CAMERA_ERROR_NONE) {
6494 *x = pc->cb_info->get_display_roi_area[0];
6495 *y = pc->cb_info->get_display_roi_area[1];
6496 *width = pc->cb_info->get_display_roi_area[2];
6497 *height = pc->cb_info->get_display_roi_area[3];
6500 LOGD("ret : 0x%x", ret);
6506 int camera_get_device_state(camera_device_e device, camera_device_state_e *state)
6508 int ret = CAMERA_ERROR_NONE;
6509 int get_device_state = 0;
6512 LOGE("NULL pointer");
6513 return CAMERA_ERROR_INVALID_PARAMETER;
6516 ret = _camera_independent_request(MUSE_CAMERA_API_GET_DEVICE_STATE,
6517 (int)device, "get_device_state", &get_device_state);
6519 if (ret == CAMERA_ERROR_NONE) {
6520 *state = (camera_device_state_e)get_device_state;
6521 LOGD("device state %d", *state);
6523 LOGE("failed 0x%x", ret);
6530 int camera_add_device_state_changed_cb(camera_device_state_changed_cb callback, void *user_data, int *cb_id)
6532 int ret = CAMERA_ERROR_NONE;
6533 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6534 camera_cb_info *info = NULL;
6536 if (!callback || !cb_id) {
6537 LOGE("invalid pointer %p %p", callback, cb_id);
6538 return CAMERA_ERROR_INVALID_PARAMETER;
6541 /* check camera support */
6542 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6543 if (ret != CAMERA_ERROR_NONE) {
6544 LOGE("get device state failed");
6548 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6550 info = g_new0(camera_cb_info, 1);
6552 LOGE("info failed");
6553 ret = CAMERA_ERROR_OUT_OF_MEMORY;
6557 info->id = ++g_cam_dev_state_changed_cb_id;
6558 info->callback = (void *)callback;
6559 info->user_data = user_data;
6563 /* subscribe dbus signal for camera state change */
6564 if (!g_cam_dev_state_changed_cb_conn) {
6565 g_cam_dev_state_changed_cb_conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
6566 if (!g_cam_dev_state_changed_cb_conn) {
6567 LOGE("failed to get gdbus connection");
6568 ret = CAMERA_ERROR_INVALID_OPERATION;
6572 LOGD("subscribe signal %s - %s - %s",
6573 MM_CAMCORDER_DBUS_OBJECT,
6574 MM_CAMCORDER_DBUS_INTERFACE_CAMERA,
6575 MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED);
6577 g_cam_dev_state_changed_cb_subscribe_id = g_dbus_connection_signal_subscribe(g_cam_dev_state_changed_cb_conn,
6578 NULL, MM_CAMCORDER_DBUS_INTERFACE_CAMERA, MM_CAMCORDER_DBUS_SIGNAL_STATE_CHANGED, MM_CAMCORDER_DBUS_OBJECT, NULL,
6579 G_DBUS_SIGNAL_FLAGS_NONE, (GDBusSignalCallback)__camera_device_state_changed_cb, NULL, NULL);
6580 if (!g_cam_dev_state_changed_cb_subscribe_id) {
6581 LOGE("failed to get gdbus connection");
6582 ret = CAMERA_ERROR_INVALID_OPERATION;
6586 LOGD("signal subscribe id %u", g_cam_dev_state_changed_cb_subscribe_id);
6589 g_cam_dev_state_changed_cb_list = g_list_prepend(g_cam_dev_state_changed_cb_list, (gpointer)info);
6591 LOGD("callback id %d", info->id);
6594 if (ret != CAMERA_ERROR_NONE) {
6600 if (g_cam_dev_state_changed_cb_conn) {
6601 g_object_unref(g_cam_dev_state_changed_cb_conn);
6602 g_cam_dev_state_changed_cb_conn = NULL;
6606 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);
6612 int camera_remove_device_state_changed_cb(int cb_id)
6614 int ret = CAMERA_ERROR_NONE;
6615 camera_device_state_e state = CAMERA_DEVICE_STATE_NULL;
6616 GList *tmp_list = NULL;
6617 camera_cb_info *info = NULL;
6619 /* check camera support */
6620 ret = camera_get_device_state(CAMERA_DEVICE_CAMERA0, &state);
6621 if (ret != CAMERA_ERROR_NONE) {
6622 LOGE("get device state failed");
6626 g_mutex_lock(&g_cam_dev_state_changed_cb_lock);
6628 if (!g_cam_dev_state_changed_cb_list) {
6629 LOGE("there is no callback info");
6630 ret = CAMERA_ERROR_INVALID_OPERATION;
6634 tmp_list = g_cam_dev_state_changed_cb_list;
6637 info = tmp_list->data;
6638 tmp_list = tmp_list->next;
6645 if (info->id == cb_id) {
6646 g_cam_dev_state_changed_cb_list = g_list_remove(g_cam_dev_state_changed_cb_list, info);
6651 if (!g_cam_dev_state_changed_cb_list) {
6652 /* no remained callback */
6653 if (g_cam_dev_state_changed_cb_conn) {
6654 /* unsubscribe signal */
6655 g_dbus_connection_signal_unsubscribe(g_cam_dev_state_changed_cb_conn, g_cam_dev_state_changed_cb_subscribe_id);
6656 g_cam_dev_state_changed_cb_subscribe_id = 0;
6658 /* unref connection */
6659 g_object_unref(g_cam_dev_state_changed_cb_conn);
6660 g_cam_dev_state_changed_cb_conn = NULL;
6664 LOGD("id %d callback removed", cb_id);
6665 ret = CAMERA_ERROR_NONE;
6671 LOGE("id %d callback not found", cb_id);
6672 ret = CAMERA_ERROR_INVALID_PARAMETER;
6675 g_mutex_unlock(&g_cam_dev_state_changed_cb_lock);