Release version 0.2.30
[platform/core/api/camera.git] / src / camera.c
1 /*
2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <mm.h>
22 #include <mm_types.h>
23 #include <camera.h>
24 #include <muse_camera.h>
25 #include <muse_camera_msg.h>
26 #include <muse_core_ipc.h>
27 #include <camera_private.h>
28 #include <muse_core.h>
29 #include <dlog.h>
30 #include <Elementary.h>
31 #include <tbm_surface_internal.h>
32 #include <gst/gst.h>
33 #include <mm_camcorder.h>
34 #include <mm_camcorder_client.h>
35 #include <Evas.h>
36 #ifdef HAVE_WAYLAND
37 #include <Ecore_Wayland.h>
38 #else
39 #include <Ecore.h>
40 #endif
41
42 #ifdef LOG_TAG
43 #undef LOG_TAG
44 #endif
45 #define LOG_TAG "TIZEN_N_CAMERA_CLIENT"
46
47
48 int __convert_camera_error_code(const char *func, int code)
49 {
50         int ret = CAMERA_ERROR_NONE;
51         const char *errorstr = NULL;
52
53         switch (code) {
54         case MM_ERROR_NONE:
55                 ret = CAMERA_ERROR_NONE;
56                 errorstr = "ERROR_NONE";
57                 break;
58         case MM_ERROR_CAMCORDER_INVALID_ARGUMENT:
59         case MM_ERROR_COMMON_INVALID_ATTRTYPE:
60                 ret = CAMERA_ERROR_INVALID_PARAMETER;
61                 errorstr = "INVALID_PARAMETER";
62                 break;
63         case MM_ERROR_CAMCORDER_NOT_INITIALIZED:
64         case MM_ERROR_CAMCORDER_INVALID_STATE:
65                 ret = CAMERA_ERROR_INVALID_STATE;
66                 errorstr = "INVALID_STATE";
67                 break;
68         case MM_ERROR_CAMCORDER_DEVICE_NOT_FOUND:
69                 ret = CAMERA_ERROR_DEVICE_NOT_FOUND;
70                 errorstr = "DEVICE_NOT_FOUND";
71                 break;
72         case MM_ERROR_CAMCORDER_DEVICE_BUSY:
73         case MM_ERROR_CAMCORDER_DEVICE_OPEN:
74         case MM_ERROR_CAMCORDER_CMD_IS_RUNNING:
75                 ret = CAMERA_ERROR_DEVICE_BUSY;
76                 errorstr = "DEVICE_BUSY";
77                 break;
78         case MM_ERROR_CAMCORDER_DEVICE:
79         case MM_ERROR_CAMCORDER_DEVICE_IO:
80         case MM_ERROR_CAMCORDER_DEVICE_TIMEOUT:
81         case MM_ERROR_CAMCORDER_DEVICE_WRONG_JPEG:
82         case MM_ERROR_CAMCORDER_DEVICE_LACK_BUFFER:
83                 ret = CAMERA_ERROR_DEVICE;
84                 errorstr = "ERROR_DEVICE";
85                 break;
86         case MM_ERROR_CAMCORDER_GST_CORE:
87         case MM_ERROR_CAMCORDER_GST_LIBRARY:
88         case MM_ERROR_CAMCORDER_GST_RESOURCE:
89         case MM_ERROR_CAMCORDER_GST_STREAM:
90         case MM_ERROR_CAMCORDER_GST_STATECHANGE:
91         case MM_ERROR_CAMCORDER_GST_NEGOTIATION:
92         case MM_ERROR_CAMCORDER_GST_LINK:
93         case MM_ERROR_CAMCORDER_GST_FLOW_ERROR:
94         case MM_ERROR_CAMCORDER_ENCODER:
95         case MM_ERROR_CAMCORDER_ENCODER_BUFFER:
96         case MM_ERROR_CAMCORDER_ENCODER_WRONG_TYPE:
97         case MM_ERROR_CAMCORDER_ENCODER_WORKING:
98         case MM_ERROR_CAMCORDER_INTERNAL:
99         case MM_ERROR_CAMCORDER_RESPONSE_TIMEOUT:
100         case MM_ERROR_CAMCORDER_DSP_FAIL:
101         case MM_ERROR_CAMCORDER_AUDIO_EMPTY:
102         case MM_ERROR_CAMCORDER_CREATE_CONFIGURE:
103         case MM_ERROR_CAMCORDER_FILE_SIZE_OVER:
104         case MM_ERROR_CAMCORDER_DISPLAY_DEVICE_OFF:
105         case MM_ERROR_CAMCORDER_INVALID_CONDITION:
106                 ret = CAMERA_ERROR_INVALID_OPERATION;
107                 errorstr = "INVALID_OPERATION";
108                 break;
109         case MM_ERROR_CAMCORDER_RESOURCE_CREATION:
110         case MM_ERROR_COMMON_OUT_OF_MEMORY:
111                 ret = CAMERA_ERROR_OUT_OF_MEMORY;
112                 errorstr = "OUT_OF_MEMORY";
113                 break;
114         case MM_ERROR_POLICY_BLOCKED:
115                 ret = CAMERA_ERROR_SOUND_POLICY;
116                 errorstr = "ERROR_SOUND_POLICY";
117                 break;
118         case MM_ERROR_POLICY_BLOCKED_BY_CALL:
119                 ret = CAMERA_ERROR_SOUND_POLICY_BY_CALL;
120                 errorstr = "ERROR_SOUND_POLICY_BY_CALL";
121                 break;
122         case MM_ERROR_POLICY_BLOCKED_BY_ALARM:
123                 ret = CAMERA_ERROR_SOUND_POLICY_BY_ALARM;
124                 errorstr = "ERROR_SOUND_POLICY_BY_ALARM";
125                 break;
126         case MM_ERROR_POLICY_RESTRICTED:
127                 ret = CAMERA_ERROR_SECURITY_RESTRICTED;
128                 errorstr = "ERROR_RESTRICTED";
129                 break;
130         case MM_ERROR_CAMCORDER_DEVICE_REG_TROUBLE:
131                 ret = CAMERA_ERROR_ESD;
132                 errorstr = "ERROR_ESD";
133                 break;
134         case MM_ERROR_COMMON_INVALID_PERMISSION:
135                 ret = CAMERA_ERROR_PERMISSION_DENIED;
136                 errorstr = "ERROR_PERMISSION_DENIED";
137                 break;
138         case MM_ERROR_COMMON_OUT_OF_ARRAY:
139         case MM_ERROR_COMMON_OUT_OF_RANGE:
140         case MM_ERROR_COMMON_ATTR_NOT_EXIST:
141         case MM_ERROR_CAMCORDER_NOT_SUPPORTED:
142                 ret = CAMERA_ERROR_NOT_SUPPORTED;
143                 errorstr = "ERROR_NOT_SUPPORTED";
144                 break;
145         default:
146                 ret = CAMERA_ERROR_INVALID_OPERATION;
147                 errorstr = "INVALID_OPERATION";
148         }
149
150         if (code != MM_ERROR_NONE)
151                 LOGE("[%s] %s(0x%08x) : core frameworks error code(0x%08x)", func ? func : "NULL_FUNC", errorstr, ret, code);
152
153         return ret;
154 }
155
156 #ifdef HAVE_WAYLAND
157 static MMCamWaylandInfo *_get_wl_info(Evas_Object *obj)
158 {
159         MMCamWaylandInfo *wl_info = NULL;
160
161         if (obj == NULL) {
162                 LOGE("evas object is NULL");
163                 return NULL;
164         }
165
166         wl_info = g_new0(MMCamWaylandInfo, 1);
167         if (wl_info == NULL) {
168                 LOGE("wl_info alloc failed : %d", sizeof(MMCamWaylandInfo));
169                 return NULL;
170         }
171
172         wl_info->evas_obj = (void *)obj;
173         wl_info->window = (void *)elm_win_wl_window_get(obj);
174         wl_info->surface = (void *)ecore_wl_window_surface_get(wl_info->window);
175         wl_info->display = (void *)ecore_wl_display_get();
176
177         if (wl_info->window == NULL || wl_info->surface == NULL || wl_info->display == NULL) {
178                 LOGE("something is NULL %p, %p, %p", wl_info->window, wl_info->surface, wl_info->display);
179                 g_free(wl_info);
180                 return NULL;
181         }
182
183         evas_object_geometry_get(obj, &wl_info->window_x, &wl_info->window_y,
184                 &wl_info->window_width, &wl_info->window_height);
185
186         LOGD("wayland obj %p, window %p, surface %p, display %p, size %d,%d,%dx%d",
187              wl_info->evas_obj, wl_info->window, wl_info->surface, wl_info->display,
188              wl_info->window_x, wl_info->window_y, wl_info->window_width, wl_info->window_height);
189
190         return wl_info;
191 }
192 #endif /* HAVE_WAYLAND */
193
194 static int _import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle)
195 {
196         tbm_bo tmp_bo = NULL;
197         tbm_bo_handle tmp_bo_handle = {NULL, };
198
199         if (bufmgr == NULL || bo == NULL || bo_handle == NULL || tbm_key == 0) {
200                 LOGE("invalid parameter - bufmgr %p, bo %p, bo_handle %p, key %d",
201                      bufmgr, bo, bo_handle, tbm_key);
202                 return false;
203         }
204
205         tmp_bo = tbm_bo_import(bufmgr, tbm_key);
206         if (tmp_bo == NULL) {
207                 LOGE("bo import failed - bufmgr %p, key %d", bufmgr, tbm_key);
208                 return false;
209         }
210
211         tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
212         if (tmp_bo_handle.ptr == NULL) {
213                 LOGE("bo map failed %p", tmp_bo);
214                 tbm_bo_unref(tmp_bo);
215                 tmp_bo = NULL;
216                 return false;
217         }
218
219         /* set bo and bo_handle */
220         *bo = tmp_bo;
221         *bo_handle = tmp_bo_handle;
222
223         return true;
224 }
225
226 static void _release_imported_bo(tbm_bo *bo)
227 {
228         if (bo == NULL || *bo == NULL) {
229                 LOGW("NULL bo");
230                 return;
231         }
232
233         tbm_bo_unmap(*bo);
234         tbm_bo_unref(*bo);
235         *bo = NULL;
236
237         return;
238 }
239
240 static int _client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
241 {
242         int ret = CAMERA_ERROR_NONE;
243         gint64 end_time;
244
245         LOGD("Enter api : %d", api);
246
247         g_mutex_lock(&(cb_info->api_mutex[api]));
248
249         if (cb_info->api_activating[api] == 0) {
250                 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
251                 if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
252                         ret = cb_info->api_ret[api];
253                         cb_info->api_activating[api] = 0;
254
255                         LOGD("return value : 0x%x", ret);
256                 } else {
257                         ret = CAMERA_ERROR_INVALID_OPERATION;
258
259                         LOGE("api %d was TIMED OUT!", api);
260                 }
261         } else {
262                 ret = cb_info->api_ret[api];
263                 cb_info->api_activating[api] = 0;
264
265                 LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);
266         }
267
268         g_mutex_unlock(&(cb_info->api_mutex[api]));
269
270         return ret;
271 }
272
273 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
274 {
275         if (in_format <= MM_PIXEL_FORMAT_INVALID ||
276             in_format >= MM_PIXEL_FORMAT_NUM ||
277             out_format == NULL) {
278                 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
279                 return CAMERA_ERROR_INVALID_PARAMETER;
280         }
281
282         switch (in_format) {
283         case MM_PIXEL_FORMAT_NV12:
284         case MM_PIXEL_FORMAT_NV12T:
285                 *out_format = TBM_FORMAT_NV12;
286                 break;
287         case MM_PIXEL_FORMAT_NV16:
288                 *out_format = TBM_FORMAT_NV16;
289                 break;
290         case MM_PIXEL_FORMAT_NV21:
291                 *out_format = TBM_FORMAT_NV21;
292                 break;
293         case MM_PIXEL_FORMAT_YUYV:
294                 *out_format = TBM_FORMAT_YUYV;
295                 break;
296         case MM_PIXEL_FORMAT_UYVY:
297         case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
298                 *out_format = TBM_FORMAT_UYVY;
299                 break;
300         case MM_PIXEL_FORMAT_422P:
301                 *out_format = TBM_FORMAT_YUV422;
302                 break;
303         case MM_PIXEL_FORMAT_I420:
304                 *out_format = TBM_FORMAT_YUV420;
305                 break;
306         case MM_PIXEL_FORMAT_YV12:
307                 *out_format = TBM_FORMAT_YVU420;
308                 break;
309         case MM_PIXEL_FORMAT_RGB565:
310                 *out_format = TBM_FORMAT_RGB565;
311                 break;
312         case MM_PIXEL_FORMAT_RGB888:
313                 *out_format = TBM_FORMAT_RGB888;
314                 break;
315         case MM_PIXEL_FORMAT_RGBA:
316                 *out_format = TBM_FORMAT_RGBA8888;
317                 break;
318         case MM_PIXEL_FORMAT_ARGB:
319                 *out_format = TBM_FORMAT_ARGB8888;
320                 break;
321         default:
322                 LOGE("invalid in_format %d", in_format);
323                 return CAMERA_ERROR_INVALID_PARAMETER;
324         }
325
326         return CAMERA_ERROR_NONE;
327 }
328
329
330 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
331 {
332         if (in_format <= MM_PIXEL_FORMAT_INVALID ||
333             in_format >= MM_PIXEL_FORMAT_NUM ||
334             mimetype == NULL) {
335                 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
336                 return CAMERA_ERROR_INVALID_PARAMETER;
337         }
338
339         switch (in_format) {
340         case MM_PIXEL_FORMAT_NV12:
341         case MM_PIXEL_FORMAT_NV12T:
342                 *mimetype = MEDIA_FORMAT_NV12;
343                 break;
344         case MM_PIXEL_FORMAT_NV16:
345                 *mimetype = MEDIA_FORMAT_NV16;
346                 break;
347         case MM_PIXEL_FORMAT_NV21:
348                 *mimetype = MEDIA_FORMAT_NV21;
349                 break;
350         case MM_PIXEL_FORMAT_YUYV:
351                 *mimetype = MEDIA_FORMAT_YUYV;
352                 break;
353         case MM_PIXEL_FORMAT_UYVY:
354         case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
355                 *mimetype = MEDIA_FORMAT_UYVY;
356                 break;
357         case MM_PIXEL_FORMAT_422P:
358                 *mimetype = MEDIA_FORMAT_422P;
359                 break;
360         case MM_PIXEL_FORMAT_I420:
361                 *mimetype = MEDIA_FORMAT_I420;
362                 break;
363         case MM_PIXEL_FORMAT_YV12:
364                 *mimetype = MEDIA_FORMAT_YV12;
365                 break;
366         case MM_PIXEL_FORMAT_RGB565:
367                 *mimetype = MEDIA_FORMAT_RGB565;
368                 break;
369         case MM_PIXEL_FORMAT_RGB888:
370                 *mimetype = MEDIA_FORMAT_RGB888;
371                 break;
372         case MM_PIXEL_FORMAT_RGBA:
373                 *mimetype = MEDIA_FORMAT_RGBA;
374                 break;
375         case MM_PIXEL_FORMAT_ARGB:
376                 *mimetype = MEDIA_FORMAT_ARGB;
377                 break;
378         default:
379                 LOGE("invalid in_format %d", in_format);
380                 return CAMERA_ERROR_INVALID_PARAMETER;
381         }
382
383         return CAMERA_ERROR_NONE;
384 }
385
386 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
387 {
388         int i = 0;
389         int ret = 0;
390         camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
391         camera_media_packet_data *mp_data = NULL;
392         tbm_surface_h tsurf = NULL;
393
394         if (pkt == NULL || cb_info == NULL) {
395                 LOGE("invalid parameter buffer %p, cb_info %p", pkt, cb_info);
396                 return MEDIA_PACKET_FINALIZE;
397         }
398
399         ret = media_packet_get_extra(pkt, (void **)&mp_data);
400         if (ret != MEDIA_PACKET_ERROR_NONE) {
401                 LOGE("media_packet_get_extra failed 0x%x", ret);
402                 return MEDIA_PACKET_FINALIZE;
403         }
404
405         /*LOGD("mp_data %p", mp_data);*/
406
407         if (mp_data) {
408                 int tbm_key = mp_data->tbm_key;
409
410                 /* release imported bo */
411                 for (i = 0 ; i < mp_data->num_buffer_key ; i++) {
412                         tbm_bo_unref(mp_data->buffer_bo[i]);
413                         mp_data->buffer_bo[i] = NULL;
414                 }
415
416                 /* unmap and unref tbm bo */
417                 _release_imported_bo(&mp_data->bo);
418
419                 /* return buffer */
420                 muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER,
421                         cb_info->fd, cb_info, INT, tbm_key);
422                 g_free(mp_data);
423                 mp_data = NULL;
424         }
425
426         ret = media_packet_get_tbm_surface(pkt, &tsurf);
427         if (ret != MEDIA_PACKET_ERROR_NONE) {
428                 LOGE("media_packet_get_tbm_surface failed 0x%x", ret);
429                 return MEDIA_PACKET_FINALIZE;
430         }
431
432         if (tsurf) {
433                 tbm_surface_destroy(tsurf);
434                 tsurf = NULL;
435         }
436
437         return MEDIA_PACKET_FINALIZE;
438 }
439
440 static void _client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event)
441 {
442         int param1 = 0;
443         int param2 = 0;
444         int tbm_key = 0;
445         tbm_bo bo = NULL;
446         tbm_bo_handle bo_handle = {NULL, };
447
448         if (recv_msg == NULL || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
449                 LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event);
450                 return;
451         }
452
453         LOGD("get camera msg %s, event %d", recv_msg, event);
454
455         if (cb_info->user_cb[event] == NULL) {
456                 LOGW("user callback for event %d is not set", event);
457                 return;
458         }
459
460         switch (event) {
461         case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
462                 {
463                         int previous = 0;
464                         int current = 0;
465                         int by_policy = 0;
466
467                         muse_camera_msg_get(previous, recv_msg);
468                         muse_camera_msg_get(current, recv_msg);
469                         muse_camera_msg_get(by_policy, recv_msg);
470
471                         LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
472                              previous, current, by_policy);
473
474                         ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
475                                 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
476                 }
477                 break;
478         case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
479                 {
480                         int state = 0;
481
482                         muse_camera_msg_get(state, recv_msg);
483
484                         LOGD("FOCUS state - %d", state);
485
486                         ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
487                 }
488                 break;
489         case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
490                 LOGD("CAPTURE_COMPLETED");
491                 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
492                 break;
493         case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
494         case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
495                 {
496                         camera_preview_data_s frame;
497                         unsigned char *buf_pos = NULL;
498                         MMCamcorderVideoStreamDataType *stream = NULL;
499                         int i = 0;
500                         int total_size = 0;
501                         int num_buffer_key = 0;
502                         int buffer_key[BUFFER_MAX_PLANE_NUM] = {0, };
503                         tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
504                         tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
505                         camera_media_packet_data *mp_data = NULL;
506
507                         muse_camera_msg_get(tbm_key, recv_msg);
508                         muse_camera_msg_get(num_buffer_key, recv_msg);
509                         muse_camera_msg_get_array(buffer_key, recv_msg);
510
511                         memset(&frame, 0x0, sizeof(camera_preview_data_s));
512
513                         if (tbm_key <= 0) {
514                                 LOGE("invalid key %d", tbm_key);
515                                 break;
516                         }
517
518                         /* import tbm bo and get virtual address */
519                         if (!_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
520                                 LOGE("failed to import key %d", tbm_key);
521
522                                 muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER,
523                                         cb_info->fd, cb_info, INT, tbm_key);
524                                 break;
525                         }
526
527                         buf_pos = (unsigned char *)bo_handle.ptr;
528
529                         /* get stream info */
530                         stream = (MMCamcorderVideoStreamDataType *)buf_pos;
531
532                         for (i = 0 ; i < num_buffer_key ; i++) {
533                                 /* import buffer bo and get virtual address */
534                                 if (!_import_tbm_key(cb_info->bufmgr, buffer_key[i], &buffer_bo[i], &buffer_bo_handle[i])) {
535                                         LOGE("failed to import buffer key %d", buffer_key[i]);
536
537                                         /* release imported bo */
538                                         for (i -= 1 ; i >= 0 ; i--)
539                                                 _release_imported_bo(&buffer_bo[i]);
540
541                                         _release_imported_bo(&bo);
542
543                                         /* send return buffer */
544                                         muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER,
545                                                 cb_info->fd, cb_info, INT, tbm_key);
546                                         return;
547                                 }
548                         }
549
550                         if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
551                                 /* set frame info */
552                                 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
553                                         frame.format  = MM_PIXEL_FORMAT_UYVY;
554                                 else
555                                         frame.format = stream->format;
556                                 frame.width = stream->width;
557                                 frame.height = stream->height;
558                                 frame.timestamp = stream->timestamp;
559                                 frame.num_of_planes = stream->num_planes;
560
561                                 if (num_buffer_key == 0) {
562                                         /* non-zero copy */
563                                         buf_pos += sizeof(MMCamcorderVideoStreamDataType);
564                                         switch (stream->num_planes) {
565                                         case 1:
566                                                 frame.data.single_plane.yuv = buf_pos;
567                                                 frame.data.single_plane.size = stream->data.yuv420.length_yuv;
568                                                 total_size = stream->data.yuv420.length_yuv;
569                                                 break;
570                                         case 2:
571                                                 frame.data.double_plane.y = buf_pos;
572                                                 frame.data.double_plane.y_size = stream->data.yuv420sp.length_y;
573                                                 buf_pos += stream->data.yuv420sp.length_y;
574                                                 frame.data.double_plane.uv = buf_pos;
575                                                 frame.data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
576                                                 total_size = stream->data.yuv420sp.length_y + \
577                                                         stream->data.yuv420sp.length_uv;
578                                                 break;
579                                         case 3:
580                                                 frame.data.triple_plane.y = buf_pos;
581                                                 frame.data.triple_plane.y_size = stream->data.yuv420p.length_y;
582                                                 buf_pos += stream->data.yuv420p.length_y;
583                                                 frame.data.triple_plane.u = buf_pos;
584                                                 frame.data.triple_plane.u_size = stream->data.yuv420p.length_u;
585                                                 buf_pos += stream->data.yuv420p.length_u;
586                                                 frame.data.triple_plane.v = buf_pos;
587                                                 frame.data.triple_plane.v_size = stream->data.yuv420p.length_v;
588                                                 total_size = stream->data.yuv420p.length_y + \
589                                                         stream->data.yuv420p.length_u + \
590                                                         stream->data.yuv420p.length_v;
591                                                 break;
592                                         default:
593                                                 break;
594                                         }
595                                 } else {
596                                         /* zero copy */
597                                         switch (stream->num_planes) {
598                                         case 1:
599                                                 frame.data.single_plane.yuv = buffer_bo_handle[0].ptr;
600                                                 frame.data.single_plane.size = stream->data.yuv420.length_yuv;
601                                                 total_size = stream->data.yuv420.length_yuv;
602                                                 break;
603                                         case 2:
604                                                 frame.data.double_plane.y = buffer_bo_handle[0].ptr;
605                                                 if (stream->num_planes == (unsigned int)num_buffer_key)
606                                                         frame.data.double_plane.uv = buffer_bo_handle[1].ptr;
607                                                 else
608                                                         frame.data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
609                                                 frame.data.double_plane.y_size = stream->data.yuv420sp.length_y;
610                                                 frame.data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
611                                                 total_size = stream->data.yuv420sp.length_y + \
612                                                         stream->data.yuv420sp.length_uv;
613                                                 break;
614                                         case 3:
615                                                 frame.data.triple_plane.y = buffer_bo_handle[0].ptr;
616                                                 if (stream->num_planes == (unsigned int)num_buffer_key) {
617                                                         frame.data.triple_plane.u = buffer_bo_handle[1].ptr;
618                                                         frame.data.triple_plane.v = buffer_bo_handle[2].ptr;
619                                                 } else {
620                                                         frame.data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y;
621                                                         frame.data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u;
622                                                 }
623                                                 frame.data.triple_plane.y_size = stream->data.yuv420p.length_y;
624                                                 frame.data.triple_plane.u_size = stream->data.yuv420p.length_u;
625                                                 frame.data.triple_plane.v_size = stream->data.yuv420p.length_v;
626                                                 total_size = stream->data.yuv420p.length_y + \
627                                                         stream->data.yuv420p.length_u + \
628                                                         stream->data.yuv420p.length_v;
629                                                 break;
630                                         default:
631                                                 break;
632                                         }
633                                 }
634
635                                 /*
636                                 LOGD("PREVIEW_CB - format %d, %dx%d, size %d plane num %d",
637                                      frame.format, frame.width, frame.height, total_size, frame.num_of_planes);
638                                 */
639
640                                 ((camera_preview_cb)cb_info->user_cb[event])(&frame, cb_info->user_data[event]);
641
642                                 /*LOGD("PREVIEW_CB retuned");*/
643                         }
644
645                         if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
646                                 media_packet_h pkt = NULL;
647                                 tbm_surface_h tsurf = NULL;
648                                 uint32_t bo_format = 0;
649                                 int ret = 0;
650                                 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
651                                 bool make_pkt_fmt = false;
652                                 tbm_surface_info_s tsurf_info;
653
654                                 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
655
656                                 /* unmap buffer bo */
657                                 for (i = 0 ; i < num_buffer_key ; i++) {
658                                         if (buffer_bo[i])
659                                                 tbm_bo_unmap(buffer_bo[i]);
660                                 }
661
662                                 /* create tbm surface */
663                                 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
664                                         tsurf_info.planes[i].stride = stream->stride[i];
665
666                                 /* get tbm surface format */
667                                 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
668                                 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
669
670                                 if (num_buffer_key > 0 && ret == CAMERA_ERROR_NONE) {
671                                         tsurf_info.width = stream->width;
672                                         tsurf_info.height = stream->height;
673                                         tsurf_info.format = bo_format;
674                                         tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
675                                         tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
676
677                                         switch (bo_format) {
678                                         case TBM_FORMAT_NV12:
679                                         case TBM_FORMAT_NV21:
680                                                 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
681                                                 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
682                                                 tsurf_info.planes[0].offset = 0;
683                                                 if (num_buffer_key == 1)
684                                                         tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
685                                                 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
686                                                 break;
687                                         case TBM_FORMAT_YUV420:
688                                         case TBM_FORMAT_YVU420:
689                                                 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
690                                                 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
691                                                 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
692                                                 tsurf_info.planes[0].offset = 0;
693                                                 if (num_buffer_key == 1) {
694                                                         tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
695                                                         tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
696                                                 }
697                                                 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
698                                                 break;
699                                         case TBM_FORMAT_UYVY:
700                                         case TBM_FORMAT_YUYV:
701                                                 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
702                                                 tsurf_info.planes[0].offset = 0;
703                                                 tsurf_info.size = tsurf_info.planes[0].size;
704                                                 break;
705                                         default:
706                                                 break;
707                                         }
708
709                                         tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_key);
710                                         /*LOGD("tbm surface %p", tsurf);*/
711                                 }
712
713                                 if (tsurf) {
714                                         /* check media packet format */
715                                         if (cb_info->pkt_fmt) {
716                                                 int pkt_fmt_width = 0;
717                                                 int pkt_fmt_height = 0;
718                                                 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
719
720                                                 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
721                                                 if (pkt_fmt_mimetype != mimetype ||
722                                                     pkt_fmt_width != stream->width ||
723                                                     pkt_fmt_height != stream->height) {
724                                                         LOGW("different format. current 0x%x, %dx%d, new 0x%x, %dx%d",
725                                                              pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height, mimetype, stream->width, stream->height);
726                                                         media_format_unref(cb_info->pkt_fmt);
727                                                         cb_info->pkt_fmt = NULL;
728                                                         make_pkt_fmt = true;
729                                                 }
730                                         } else {
731                                                 make_pkt_fmt = true;
732                                         }
733
734                                         /* create packet format */
735                                         if (make_pkt_fmt) {
736                                                 LOGW("make new pkt_fmt - mimetype 0x%x, %dx%d", mimetype, stream->width, stream->height);
737                                                 ret = media_format_create(&cb_info->pkt_fmt);
738                                                 if (ret == MEDIA_FORMAT_ERROR_NONE) {
739                                                         ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
740                                                         ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
741                                                         ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
742                                                         LOGW("media_format_set_video_mime,width,height ret : 0x%x", ret);
743                                                 } else {
744                                                         LOGW("media_format_create failed");
745                                                 }
746                                         }
747
748                                         /* create media packet */
749                                         ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt,
750                                                 tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
751                                                 (void *)cb_info, &pkt);
752                                         if (ret != MEDIA_PACKET_ERROR_NONE) {
753                                                 LOGE("media_packet_create_from_tbm_surface failed");
754
755                                                 tbm_surface_destroy(tsurf);
756                                                 tsurf = NULL;
757                                         }
758                                 } else {
759                                         LOGE("failed to create tbm surface %dx%d, format %d, num_buffer_key %d",
760                                              stream->width, stream->height, stream->format, num_buffer_key);
761                                 }
762
763                                 if (pkt) {
764                                         /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
765
766                                         mp_data = g_new0(camera_media_packet_data, 1);
767                                         if (mp_data) {
768                                                 mp_data->tbm_key = tbm_key;
769                                                 mp_data->num_buffer_key = num_buffer_key;
770                                                 mp_data->bo = bo;
771                                                 for (i = 0 ; i < num_buffer_key ; i++)
772                                                         mp_data->buffer_bo[i] = buffer_bo[i];
773
774                                                 /* set media packet data */
775                                                 ret = media_packet_set_extra(pkt, (void *)mp_data);
776                                                 if (ret != MEDIA_PACKET_ERROR_NONE) {
777                                                         LOGE("media_packet_set_extra failed");
778
779                                                         if (mp_data) {
780                                                                 g_free(mp_data);
781                                                                 mp_data = NULL;
782                                                         }
783
784                                                         media_packet_destroy(pkt);
785                                                         pkt = NULL;
786                                                 } else {
787                                                         int e_type = MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW;
788
789                                                         /* set timestamp : msec -> nsec */
790                                                         if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
791                                                                 LOGW("media_packet_set_pts failed");
792
793                                                         /* call media packet callback */
794                                                         ((camera_media_packet_preview_cb)cb_info->user_cb[e_type])(pkt, cb_info->user_data[e_type]);
795                                                 }
796                                         } else {
797                                                 LOGE("failed to alloc media packet data");
798                                         }
799                                 }
800                         }
801
802                         /* send message for preview callback return */
803                         muse_camera_msg_send_no_return(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info->fd, cb_info);
804
805                         if (mp_data == NULL) {
806                                 /* release imported bo */
807                                 for (i = 0 ; i < num_buffer_key ; i++)
808                                         _release_imported_bo(&buffer_bo[i]);
809
810                                 /* unmap and unref tbm bo */
811                                 _release_imported_bo(&bo);
812
813                                 /* return buffer */
814                                 muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER,
815                                         cb_info->fd, cb_info, INT, tbm_key);
816
817                                 /*LOGD("return buffer Done");*/
818                         }
819                 }
820                 break;
821         case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
822                 {
823                         int percent = 0;
824
825                         muse_camera_msg_get(percent, recv_msg);
826
827                         LOGD("HDR progress - %d \%", percent);
828
829                         ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
830                 }
831                 break;
832         case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
833                 {
834                         int policy = 0;
835                         int previous = 0;
836                         int current = 0;
837
838                         muse_camera_msg_get(policy, recv_msg);
839                         muse_camera_msg_get(previous, recv_msg);
840                         muse_camera_msg_get(current, recv_msg);
841
842                         LOGD("INTERRUPTED - policy %d, state previous %d, current %d",
843                              policy, previous, current);
844
845                         ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
846                                 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
847                 }
848                 break;
849         case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
850                 {
851                         int count = 0;
852                         camera_detected_face_s *faces = NULL;
853
854                         muse_camera_msg_get(count, recv_msg);
855                         muse_camera_msg_get(tbm_key, recv_msg);
856
857                         if (count > 0 && tbm_key > 0) {
858                                 LOGD("FACE_DETECTION - count %d, tbm_key %d", count, tbm_key);
859
860                                 if (!_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle))
861                                         break;
862
863                                 /* set face info */
864                                 faces = bo_handle.ptr;
865
866                                 ((camera_face_detected_cb)cb_info->user_cb[event])(faces, count, cb_info->user_data[event]);
867
868 #if 0
869                                 {
870                                         int i = 0;
871
872                                         for (i = 0 ; i < count ; i++) {
873                                                 LOGD("id[%2d] - score %d, position (%d,%d,%dx%d)",
874                                                      i, faces[i].score, faces[i].x, faces[i].y, faces[i].width, faces[i].height);
875                                         }
876                                 }
877 #endif
878
879                                 /* release bo */
880                                 _release_imported_bo(&bo);
881
882                                 /* return buffer */
883                                 muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER,
884                                         cb_info->fd, cb_info, INT, tbm_key);
885
886                                 LOGD("return buffer done");
887                         } else {
888                                 LOGE("invalid message - count %d, key %d", count, tbm_key);
889                         }
890                 }
891                 break;
892         case MUSE_CAMERA_EVENT_TYPE_ERROR:
893                 {
894                         int error = 0;
895                         int current_state = 0;
896
897                         muse_camera_msg_get(error, recv_msg);
898                         muse_camera_msg_get(current_state, recv_msg);
899
900                         LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
901
902                         ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
903                                 (camera_state_e)current_state, cb_info->user_data[event]);
904                 }
905                 break;
906         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
907                 muse_camera_msg_get(param1, recv_msg);
908                 muse_camera_msg_get(param2, recv_msg);
909
910                 LOGD("SUPPORTED_PREVIEW_RESOLUTION - %d x %d", param1, param2);
911
912                 ((camera_supported_preview_resolution_cb)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]);
913                 break;
914         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
915                 muse_camera_msg_get(param1, recv_msg);
916                 muse_camera_msg_get(param2, recv_msg);
917
918                 LOGD("SUPPORTED_CAPTURE_RESOLUTION - %d x %d", param1, param2);
919
920                 ((camera_supported_capture_resolution_cb)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]);
921                 break;
922         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
923                 muse_camera_msg_get(param1, recv_msg);
924
925                 LOGD("SUPPORTED_CAPTURE_FORMAT - %d ", param1);
926
927                 ((camera_supported_capture_format_cb)cb_info->user_cb[event])((camera_pixel_format_e)param1, cb_info->user_data[event]);
928                 break;
929         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
930                 muse_camera_msg_get(param1, recv_msg);
931
932                 LOGD("SUPPORTED_PREVIEW_FORMAT - %d ", param1);
933
934                 ((camera_supported_preview_format_cb)cb_info->user_cb[event])((camera_pixel_format_e)param1, cb_info->user_data[event]);
935                 break;
936         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
937                 muse_camera_msg_get(param1, recv_msg);
938
939                 LOGD("SUPPORTED_AF_MODE - %d ", param1);
940
941                 ((camera_attr_supported_af_mode_cb)cb_info->user_cb[event])((camera_attr_af_mode_e)param1, cb_info->user_data[event]);
942                 break;
943         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
944                 muse_camera_msg_get(param1, recv_msg);
945
946                 LOGD("SUPPORTED_EXPOSURE_MODE - %d ", param1);
947
948                 ((camera_attr_supported_exposure_mode_cb)cb_info->user_cb[event])((camera_attr_exposure_mode_e)param1, cb_info->user_data[event]);
949                 break;
950         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
951                 muse_camera_msg_get(param1, recv_msg);
952
953                 LOGD("SUPPORTED_ISO - %d ", param1);
954
955                 ((camera_attr_supported_iso_cb)cb_info->user_cb[event])((camera_attr_iso_e)param1, cb_info->user_data[event]);
956                 break;
957         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
958                 muse_camera_msg_get(param1, recv_msg);
959
960                 LOGD("SUPPORTED_WHITEBALANCE - %d ", param1);
961
962                 ((camera_attr_supported_whitebalance_cb)cb_info->user_cb[event])((camera_attr_whitebalance_e)param1, cb_info->user_data[event]);
963                 break;
964         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
965                 muse_camera_msg_get(param1, recv_msg);
966
967                 LOGD("SUPPORTED_EFFECT - %d ", param1);
968
969                 ((camera_attr_supported_effect_cb)cb_info->user_cb[event])((camera_attr_effect_mode_e)param1, cb_info->user_data[event]);
970                 break;
971         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
972                 muse_camera_msg_get(param1, recv_msg);
973
974                 LOGD("SUPPORTED_SCENE_MODE - %d ", param1);
975
976                 ((camera_attr_supported_scene_mode_cb)cb_info->user_cb[event])((camera_attr_scene_mode_e)param1, cb_info->user_data[event]);
977                 break;
978         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
979                 muse_camera_msg_get(param1, recv_msg);
980
981                 LOGD("SUPPORTED_FLASH_MODE - %d ", param1);
982
983                 ((camera_attr_supported_flash_mode_cb)cb_info->user_cb[event])((camera_attr_flash_mode_e)param1, cb_info->user_data[event]);
984                 break;
985         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
986                 muse_camera_msg_get(param1, recv_msg);
987
988                 LOGD("SUPPORTED_FPS - %d ", param1);
989
990                 ((camera_attr_supported_fps_cb)cb_info->user_cb[event])((camera_attr_fps_e)param1, cb_info->user_data[event]);
991                 break;
992         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
993                 muse_camera_msg_get(param1, recv_msg);
994
995                 LOGD("SUPPORTED_FPS_BY_RESOLUTION - %d ", param1);
996
997                 ((camera_attr_supported_fps_cb)cb_info->user_cb[event])((camera_attr_fps_e)param1, cb_info->user_data[event]);
998                 break;
999         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1000                 muse_camera_msg_get(param1, recv_msg);
1001
1002                 LOGD("SUPPORTED_STREAM_FLIP - %d ", param1);
1003
1004                 ((camera_attr_supported_stream_flip_cb)cb_info->user_cb[event])((camera_flip_e)param1, cb_info->user_data[event]);
1005                 break;
1006         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1007                 muse_camera_msg_get(param1, recv_msg);
1008
1009                 LOGD("SUPPORTED_STREAM_ROTATION - %d ", param1);
1010
1011                 ((camera_attr_supported_stream_rotation_cb)cb_info->user_cb[event])((camera_rotation_e)param1, cb_info->user_data[event]);
1012                 break;
1013         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1014                 muse_camera_msg_get(param1, recv_msg);
1015
1016                 LOGD("SUPPORTED_THEATER_MODE - %d ", param1);
1017
1018                 ((camera_attr_supported_theater_mode_cb)cb_info->user_cb[event])((camera_attr_theater_mode_e)param1, cb_info->user_data[event]);
1019                 break;
1020         case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1021                 {
1022                         camera_image_data_s *rImage = NULL;
1023                         camera_image_data_s *rPostview = NULL;
1024                         camera_image_data_s *rThumbnail = NULL;
1025                         unsigned char *buf_pos = NULL;
1026                         int is_postview = 0;
1027                         int is_thumbnail = 0;
1028
1029                         muse_camera_msg_get(tbm_key, recv_msg);
1030                         muse_camera_msg_get(is_postview, recv_msg);
1031                         muse_camera_msg_get(is_thumbnail, recv_msg);
1032
1033                         LOGD("camera capture callback came in. key %d, postview %d, thumbnail %d",
1034                              tbm_key, is_postview, is_thumbnail);
1035
1036                         if (tbm_key <= 0) {
1037                                 LOGE("invalid key %d", tbm_key);
1038                                 break;
1039                         }
1040
1041                         /* import tbm bo and get virtual address */
1042                         if (!_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle))
1043                                 break;
1044
1045                         buf_pos = (unsigned char *)bo_handle.ptr;
1046                         rImage = (camera_image_data_s *)buf_pos;
1047                         rImage->data = buf_pos + sizeof(camera_image_data_s);
1048                         buf_pos += sizeof(camera_image_data_s) + rImage->size;
1049
1050                         if (is_postview) {
1051                                 rPostview = (camera_image_data_s *)buf_pos;
1052                                 LOGD("rPostview->size : %d", rPostview->size);
1053                                 rPostview->data = buf_pos + sizeof(camera_image_data_s);
1054                                 buf_pos += sizeof(camera_image_data_s) + rPostview->size;
1055                         }
1056
1057                         if (is_thumbnail) {
1058                                 rThumbnail = (camera_image_data_s *)buf_pos;
1059                                 LOGD("rThumbnail->size : %d", rThumbnail->size);
1060                                 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
1061                                 buf_pos += sizeof(camera_image_data_s) + rThumbnail->size;
1062                         }
1063
1064                         LOGD("image info %dx%d, size : %d", rImage->height, rImage->width, rImage->size);
1065
1066                         ((camera_capturing_cb)cb_info->user_cb[event])(rImage, rPostview, rThumbnail, cb_info->user_data[event]);
1067
1068                         /* unmap and unref tbm bo */
1069                         _release_imported_bo(&bo);
1070
1071                         /* return buffer */
1072                         muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER,
1073                                 cb_info->fd, cb_info, INT, tbm_key);
1074
1075                         LOGD("return buffer done");
1076                 }
1077                 break;
1078         case MUSE_CAMERA_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR:
1079                 break;
1080         default:
1081                 LOGW("Unknown event : %d", event);
1082                 break;
1083         }
1084
1085         return;
1086 }
1087
1088 static bool _camera_idle_event_callback(void *data)
1089 {
1090         camera_cb_info_s *cb_info = NULL;
1091         camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1092
1093         if (cam_idle_event == NULL) {
1094                 LOGE("cam_idle_event is NULL");
1095                 return false;
1096         }
1097
1098         /* lock event */
1099         g_mutex_lock(&cam_idle_event->event_mutex);
1100
1101         cb_info = cam_idle_event->cb_info;
1102         if (cb_info == NULL) {
1103                 LOGW("camera cb_info is NULL. event %d", cam_idle_event->event);
1104                 goto IDLE_EVENT_CALLBACK_DONE;
1105         }
1106
1107         /* remove event from list */
1108         g_mutex_lock(&cb_info->idle_event_mutex);
1109         if (cb_info->idle_event_list)
1110                 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1111
1112         /*LOGD("remove camera idle event %p, %p", cam_idle_event, cb_info->idle_event_list);*/
1113         g_mutex_unlock(&cb_info->idle_event_mutex);
1114
1115         /* user callback */
1116         _client_user_callback(cam_idle_event->cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
1117
1118         /* send signal for waiting thread */
1119         g_cond_signal(&cb_info->idle_event_cond);
1120
1121 IDLE_EVENT_CALLBACK_DONE:
1122         /* unlock and release event */
1123         g_mutex_unlock(&cam_idle_event->event_mutex);
1124         g_mutex_clear(&cam_idle_event->event_mutex);
1125
1126         free(cam_idle_event);
1127         cam_idle_event = NULL;
1128
1129         return false;
1130 }
1131
1132 static void *_camera_msg_handler_func(gpointer data)
1133 {
1134         int ret = 0;
1135         int api = 0;
1136         int event = 0;
1137         int event_class = 0;
1138         camera_message_s *cam_msg = NULL;
1139         camera_idle_event_s *cam_idle_event = NULL;
1140         camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
1141
1142         if (cb_info == NULL) {
1143                 LOGE("cb_info NULL");
1144                 return NULL;
1145         }
1146
1147         LOGD("start");
1148
1149         g_mutex_lock(&cb_info->msg_handler_mutex);
1150
1151         while (g_atomic_int_get(&cb_info->msg_handler_running)) {
1152                 if (g_queue_is_empty(cb_info->msg_queue)) {
1153                         LOGD("signal wait...");
1154                         g_cond_wait(&cb_info->msg_handler_cond, &cb_info->msg_handler_mutex);
1155                         LOGD("signal received");
1156
1157                         if (g_atomic_int_get(&cb_info->msg_handler_running) == 0) {
1158                                 LOGD("stop event thread");
1159                                 break;
1160                         }
1161                 }
1162
1163                 cam_msg = (camera_message_s *)g_queue_pop_head(cb_info->msg_queue);
1164
1165                 g_mutex_unlock(&cb_info->msg_handler_mutex);
1166
1167                 if (cam_msg == NULL) {
1168                         LOGE("NULL message");
1169                         g_mutex_lock(&cb_info->msg_handler_mutex);
1170                         continue;
1171                 }
1172
1173                 api = cam_msg->api;
1174
1175                 if (api < MUSE_CAMERA_API_MAX) {
1176                         g_mutex_lock(&cb_info->api_mutex[api]);
1177
1178                         if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1179                                 cb_info->api_ret[api] = ret;
1180                                 cb_info->api_activating[api] = 1;
1181
1182                                 LOGD("camera api %d - return 0x%x", ret);
1183
1184                                 g_cond_signal(&cb_info->api_cond[api]);
1185                         } else {
1186                                 LOGE("failed to get camera ret for api %d, msg %s", api, cam_msg->recv_msg);
1187                         }
1188
1189                         g_mutex_unlock(&cb_info->api_mutex[api]);
1190                 } else if (api == MUSE_CAMERA_CB_EVENT) {
1191                         event = -1;
1192                         event_class = -1;
1193
1194                         if (!muse_camera_msg_get(event, cam_msg->recv_msg) ||
1195                             !muse_camera_msg_get(event_class, cam_msg->recv_msg)) {
1196                                 LOGE("failed to get camera event %d, class %d", event, event_class);
1197
1198                                 g_free(cam_msg);
1199                                 cam_msg = NULL;
1200
1201                                 g_mutex_lock(&cb_info->msg_handler_mutex);
1202                                 continue;
1203                         }
1204
1205                         switch (event_class) {
1206                         case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1207                                 _client_user_callback(cb_info, cam_msg->recv_msg, event);
1208                                 break;
1209                         case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1210                                 cam_idle_event = (camera_idle_event_s *)malloc(sizeof(camera_idle_event_s));
1211                                 if (cam_idle_event == NULL) {
1212                                         LOGE("cam_idle_event alloc failed");
1213                                         break;
1214                                 }
1215
1216                                 cam_idle_event->event = event;
1217                                 cam_idle_event->cb_info = cb_info;
1218                                 g_mutex_init(&cam_idle_event->event_mutex);
1219                                 memcpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg));
1220
1221                                 LOGD("add camera event[%d, %p] to IDLE", event, cam_idle_event);
1222
1223                                 g_mutex_lock(&cb_info->idle_event_mutex);
1224                                 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1225                                 g_mutex_unlock(&cb_info->idle_event_mutex);
1226
1227                                 g_idle_add_full(G_PRIORITY_DEFAULT,
1228                                         (GSourceFunc)_camera_idle_event_callback,
1229                                         (gpointer)cam_idle_event,
1230                                         NULL);
1231                                 break;
1232                         default:
1233                                 LOGE("unknown camera event class %d", event_class);
1234                                 break;
1235                         }
1236                 } else {
1237                         LOGE("unknown camera api[%d] message[%s]", api, cam_msg->recv_msg);
1238                 }
1239
1240                 free(cam_msg);
1241                 cam_msg = NULL;
1242
1243                 g_mutex_lock(&cb_info->msg_handler_mutex);
1244         }
1245
1246         /* remove remained event */
1247         while (!g_queue_is_empty(cb_info->msg_queue)) {
1248                 cam_msg = (camera_message_s *)g_queue_pop_head(cb_info->msg_queue);
1249                 if (cam_msg) {
1250                         LOGD("remove camera message %p", cam_msg);
1251                         free(cam_msg);
1252                         cam_msg = NULL;
1253                 } else {
1254                         LOGW("NULL camera message");
1255                 }
1256         }
1257
1258         g_mutex_unlock(&cb_info->msg_handler_mutex);
1259
1260         LOGD("return");
1261
1262         return NULL;
1263 }
1264
1265 static void _camera_remove_idle_event_all(camera_cb_info_s *cb_info)
1266 {
1267         camera_idle_event_s *cam_idle_event = NULL;
1268         gboolean ret = TRUE;
1269         GList *list = NULL;
1270         gint64 end_time = 0;
1271
1272         if (cb_info == NULL) {
1273                 LOGE("cb_info is NULL");
1274                 return;
1275         }
1276
1277         g_mutex_lock(&cb_info->idle_event_mutex);
1278
1279         if (cb_info->idle_event_list == NULL) {
1280                 LOGD("No idle event is remained.");
1281         } else {
1282                 list = cb_info->idle_event_list;
1283
1284                 while (list) {
1285                         cam_idle_event = list->data;
1286                         list = g_list_next(list);
1287
1288                         if (!cam_idle_event) {
1289                                 LOGW("Fail to remove idle event. The event is NULL");
1290                         } else {
1291                                 if (g_mutex_trylock(&cam_idle_event->event_mutex)) {
1292                                         ret = g_idle_remove_by_data(cam_idle_event);
1293
1294                                         LOGD("remove idle event [%p], ret[%d]", cam_idle_event, ret);
1295
1296                                         if (ret == FALSE) {
1297                                                 cam_idle_event->cb_info = NULL;
1298                                                 LOGW("idle callback for event %p will be called later", cam_idle_event);
1299                                         }
1300
1301                                         cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1302
1303                                         g_mutex_unlock(&cam_idle_event->event_mutex);
1304
1305                                         if (ret == TRUE) {
1306                                                 g_mutex_clear(&cam_idle_event->event_mutex);
1307
1308                                                 free(cam_idle_event);
1309                                                 cam_idle_event = NULL;
1310
1311                                                 LOGD("remove idle event done");
1312                                         }
1313                                 } else {
1314                                         LOGW("event lock failed. it's being called...");
1315
1316                                         end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
1317
1318                                         if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
1319                                                 LOGW("signal received");
1320                                         else
1321                                                 LOGW("timeout");
1322                                 }
1323                         }
1324                 }
1325
1326                 g_list_free(cb_info->idle_event_list);
1327                 cb_info->idle_event_list = NULL;
1328         }
1329
1330         g_mutex_unlock(&cb_info->idle_event_mutex);
1331
1332         return;
1333 }
1334
1335 static void *_camera_msg_recv_func(gpointer data)
1336 {
1337         int i = 0;
1338         int ret = 0;
1339         int api = 0;
1340         int api_class = 0;
1341         int num_token = 0;
1342         int str_pos = 0;
1343         int prev_pos = 0;
1344         int prev_state = CAMERA_STATE_NONE;
1345         char *recv_msg = NULL;
1346         char **parse_str = NULL;
1347         camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
1348
1349         if (cb_info == NULL) {
1350                 LOGE("cb_info NULL");
1351                 return NULL;
1352         }
1353
1354         LOGD("start");
1355
1356         parse_str = (char **)malloc(sizeof(char *) * CAMERA_PARSE_STRING_SIZE);
1357         if (parse_str == NULL) {
1358                 LOGE("parse_str malloc failed");
1359                 return NULL;
1360         }
1361
1362         for (i = 0 ; i < CAMERA_PARSE_STRING_SIZE ; i++) {
1363                 parse_str[i] = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
1364                 if (parse_str[i] == NULL) {
1365                         LOGE("parse_str[%d] malloc failed", i);
1366                         goto CB_HANDLER_EXIT;
1367                 }
1368         }
1369
1370         recv_msg = cb_info->recv_msg;
1371
1372         while (g_atomic_int_get(&cb_info->msg_recv_running)) {
1373                 ret = muse_core_ipc_recv_msg(cb_info->fd, recv_msg);
1374                 if (ret <= 0)
1375                         break;
1376                 recv_msg[ret] = '\0';
1377
1378                 str_pos = 0;
1379                 prev_pos = 0;
1380                 num_token = 0;
1381
1382                 /*LOGD("recvMSg : %s, length : %d", recv_msg, ret);*/
1383
1384                 /* Need to split the combined entering msgs.
1385                     This module supports up to 200 combined msgs. */
1386                 for (str_pos = 0; str_pos < ret; str_pos++) {
1387                         if (recv_msg[str_pos] == '}') {
1388                                 memset(parse_str[num_token], 0x0, sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
1389                                 strncpy(parse_str[num_token], recv_msg + prev_pos, str_pos - prev_pos + 1);
1390                                 LOGD("splitted msg : [%s], Index : %d", parse_str[num_token], num_token);
1391                                 prev_pos = str_pos+1;
1392                                 num_token++;
1393                         }
1394                 }
1395
1396                 /*LOGD("num_token : %d", num_token);*/
1397
1398                 /* Re-construct to the useful single msg. */
1399                 for (i = 0; i < num_token; i++) {
1400                         if (i >= CAMERA_PARSE_STRING_SIZE) {
1401                                 LOGE("invalid token index %d", i);
1402                                 break;
1403                         }
1404
1405                         api = -1;
1406                         api_class = -1;
1407
1408                         if (!muse_camera_msg_get(api, parse_str[i])) {
1409                                 LOGE("failed to get camera api");
1410                                 continue;
1411                         }
1412
1413                         if (muse_camera_msg_get(api_class, parse_str[i]))
1414                                 LOGD("camera api_class[%d]", api_class);
1415
1416                         if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1417                                 g_mutex_lock(&cb_info->api_mutex[api]);
1418
1419                                 if (!muse_camera_msg_get(ret, parse_str[i])) {
1420                                         LOGE("failed to get camera ret");
1421                                         g_mutex_unlock(&cb_info->api_mutex[api]);
1422                                         continue;
1423                                 }
1424
1425                                 cb_info->api_ret[api] = ret;
1426                                 cb_info->api_activating[api] = 1;
1427
1428                                 if (api == MUSE_CAMERA_API_CREATE) {
1429                                         if (ret != CAMERA_ERROR_NONE) {
1430                                                 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1431                                                 LOGE("camera create error 0x%x. close client cb handler", ret);
1432                                         }
1433                                 } else if (api == MUSE_CAMERA_API_DESTROY) {
1434                                         if (ret == CAMERA_ERROR_NONE) {
1435                                                 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1436                                                 LOGD("camera destroy done. close client cb handler");
1437                                         }
1438                                 } else if (api == MUSE_CAMERA_API_START_PREVIEW) {
1439                                         muse_camera_msg_get(prev_state, parse_str[i]);
1440                                         cb_info->prev_state = prev_state;
1441                                 }
1442
1443                                 g_cond_signal(&cb_info->api_cond[api]);
1444                                 g_mutex_unlock(&cb_info->api_mutex[api]);
1445                         } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
1446                                 camera_message_s *cam_msg = g_new0(camera_message_s, 1);
1447                                 if (cam_msg == NULL) {
1448                                         LOGE("failed to alloc cam_msg");
1449                                         continue;
1450                                 }
1451
1452                                 cam_msg->api = api;
1453                                 memcpy(cam_msg->recv_msg, parse_str[i], sizeof(cam_msg->recv_msg));
1454
1455                                 LOGD("add camera message to queue : api %d", api);
1456
1457                                 g_mutex_lock(&cb_info->msg_handler_mutex);
1458                                 g_queue_push_tail(cb_info->msg_queue, (gpointer)cam_msg);
1459                                 g_cond_signal(&cb_info->msg_handler_cond);
1460                                 g_mutex_unlock(&cb_info->msg_handler_mutex);
1461                         } else {
1462                                 LOGW("unknown camera api %d and api_class %d", api, api_class);
1463                         }
1464                 }
1465
1466         }
1467
1468         LOGD("client cb exit");
1469
1470 CB_HANDLER_EXIT:
1471         if (parse_str) {
1472                 for (i = 0 ; i < CAMERA_PARSE_STRING_SIZE ; i++) {
1473                         if (parse_str[i]) {
1474                                 free(parse_str[i]);
1475                                 parse_str[i] = NULL;
1476                         }
1477                 }
1478
1479                 free(parse_str);
1480                 parse_str = NULL;
1481         }
1482
1483         return NULL;
1484 }
1485
1486 static camera_cb_info_s *_client_callback_new(gint sockfd)
1487 {
1488         camera_cb_info_s *cb_info = NULL;
1489         GCond *tmp_cond = NULL;
1490         GMutex *tmp_mutex = NULL;
1491         gint *tmp_activating = NULL;
1492         gint *tmp_ret = NULL;
1493
1494         g_return_val_if_fail(sockfd > 0, NULL);
1495
1496         cb_info = g_new0(camera_cb_info_s, 1);
1497         if (cb_info == NULL) {
1498                 LOGE("cb_info failed");
1499                 goto ErrorExit;
1500         }
1501
1502         g_mutex_init(&cb_info->msg_handler_mutex);
1503         g_cond_init(&cb_info->msg_handler_cond);
1504         g_mutex_init(&cb_info->idle_event_mutex);
1505         g_cond_init(&cb_info->idle_event_cond);
1506
1507         tmp_cond = g_new0(GCond, MUSE_CAMERA_API_MAX);
1508         if (tmp_cond == NULL) {
1509                 LOGE("tmp_cond failed");
1510                 goto ErrorExit;
1511         }
1512
1513         tmp_mutex = g_new0(GMutex, MUSE_CAMERA_API_MAX);
1514         if (tmp_mutex == NULL) {
1515                 LOGE("tmp_mutex failed");
1516                 goto ErrorExit;
1517         }
1518
1519         tmp_activating = g_new0(gint, MUSE_CAMERA_API_MAX);
1520         if (tmp_activating == NULL) {
1521                 LOGE("tmp_activating failed");
1522                 goto ErrorExit;
1523         }
1524
1525         tmp_ret = g_new0(gint, MUSE_CAMERA_API_MAX);
1526         if (tmp_ret == NULL) {
1527                 LOGE("tmp_ret failed");
1528                 goto ErrorExit;
1529         }
1530
1531         cb_info->msg_queue = g_queue_new();
1532         if (cb_info->msg_queue == NULL) {
1533                 LOGE("msg_queue new failed");
1534                 goto ErrorExit;
1535         }
1536
1537         g_atomic_int_set(&cb_info->msg_handler_running, 1);
1538         cb_info->msg_handler_thread = g_thread_try_new("camera_msg_handler",
1539                 _camera_msg_handler_func, (gpointer)cb_info, NULL);
1540         if (cb_info->msg_handler_thread == NULL) {
1541                 LOGE("message handler thread creation failed");
1542                 goto ErrorExit;
1543         }
1544
1545         cb_info->fd = sockfd;
1546         cb_info->api_cond = tmp_cond;
1547         cb_info->api_mutex = tmp_mutex;
1548         cb_info->api_activating = tmp_activating;
1549         cb_info->api_ret = tmp_ret;
1550
1551         g_atomic_int_set(&cb_info->msg_recv_running, 1);
1552         cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
1553                 _camera_msg_recv_func, (gpointer)cb_info, NULL);
1554         if (cb_info->msg_recv_thread == NULL) {
1555                 LOGE("message receive thread creation failed");
1556                 goto ErrorExit;
1557         }
1558
1559         return cb_info;
1560
1561 ErrorExit:
1562         if (cb_info) {
1563                 if (cb_info->msg_handler_thread) {
1564                         g_mutex_lock(&cb_info->msg_handler_mutex);
1565                         g_atomic_int_set(&cb_info->msg_handler_running, 0);
1566                         g_cond_signal(&cb_info->msg_handler_cond);
1567                         g_mutex_unlock(&cb_info->msg_handler_mutex);
1568
1569                         g_thread_join(cb_info->msg_handler_thread);
1570                         g_thread_unref(cb_info->msg_handler_thread);
1571                         cb_info->msg_handler_thread = NULL;
1572                 }
1573
1574                 g_mutex_clear(&cb_info->msg_handler_mutex);
1575                 g_cond_clear(&cb_info->msg_handler_cond);
1576                 g_mutex_clear(&cb_info->idle_event_mutex);
1577                 g_cond_clear(&cb_info->idle_event_cond);
1578
1579                 if (cb_info->msg_queue) {
1580                         g_queue_free(cb_info->msg_queue);
1581                         cb_info->msg_queue = NULL;
1582                 }
1583
1584                 g_free(cb_info);
1585                 cb_info = NULL;
1586         }
1587
1588         if (tmp_cond) {
1589                 g_free(tmp_cond);
1590                 tmp_cond = NULL;
1591         }
1592         if (tmp_mutex) {
1593                 g_free(tmp_mutex);
1594                 tmp_mutex = NULL;
1595         }
1596         if (tmp_activating) {
1597                 g_free(tmp_activating);
1598                 tmp_activating = NULL;
1599         }
1600         if (tmp_ret) {
1601                 g_free(tmp_ret);
1602                 tmp_ret = NULL;
1603         }
1604
1605         return NULL;
1606 }
1607
1608 static void _client_callback_destroy(camera_cb_info_s *cb_info)
1609 {
1610         g_return_if_fail(cb_info != NULL);
1611
1612         LOGD("MSG receive thread[%p] destroy", cb_info->msg_recv_thread);
1613
1614         g_thread_join(cb_info->msg_recv_thread);
1615         g_thread_unref(cb_info->msg_recv_thread);
1616         cb_info->msg_recv_thread = NULL;
1617
1618         LOGD("msg thread removed");
1619
1620         g_mutex_lock(&cb_info->msg_handler_mutex);
1621         g_atomic_int_set(&cb_info->msg_handler_running, 0);
1622         g_cond_signal(&cb_info->msg_handler_cond);
1623         g_mutex_unlock(&cb_info->msg_handler_mutex);
1624
1625         g_thread_join(cb_info->msg_handler_thread);
1626         g_thread_unref(cb_info->msg_handler_thread);
1627         cb_info->msg_handler_thread = NULL;
1628
1629         g_queue_free(cb_info->msg_queue);
1630         cb_info->msg_queue = NULL;
1631         g_mutex_clear(&cb_info->msg_handler_mutex);
1632         g_cond_clear(&cb_info->msg_handler_cond);
1633         g_mutex_clear(&cb_info->idle_event_mutex);
1634         g_cond_clear(&cb_info->idle_event_cond);
1635
1636         LOGD("event thread removed");
1637
1638         if (cb_info->bufmgr) {
1639                 tbm_bufmgr_deinit(cb_info->bufmgr);
1640                 cb_info->bufmgr = NULL;
1641         }
1642         if (cb_info->api_cond) {
1643                 g_free(cb_info->api_cond);
1644                 cb_info->api_cond = NULL;
1645         }
1646         if (cb_info->api_mutex) {
1647                 g_free(cb_info->api_mutex);
1648                 cb_info->api_mutex = NULL;
1649         }
1650         if (cb_info->api_activating) {
1651                 g_free(cb_info->api_activating);
1652                 cb_info->api_activating = NULL;
1653         }
1654         if (cb_info->api_ret) {
1655                 g_free(cb_info->api_ret);
1656                 cb_info->api_ret = NULL;
1657         }
1658         if (cb_info->pkt_fmt) {
1659                 media_format_unref(cb_info->pkt_fmt);
1660                 cb_info->pkt_fmt = NULL;
1661         }
1662
1663         g_free(cb_info);
1664         cb_info = NULL;
1665
1666         return;
1667 }
1668
1669 int camera_create(camera_device_e device, camera_h* camera)
1670 {
1671         int sock_fd = -1;
1672         char *sndMsg;
1673         int ret = CAMERA_ERROR_NONE;
1674         int pid = 0;
1675         camera_cli_s *pc = NULL;
1676         tbm_bufmgr bufmgr = NULL;
1677
1678         muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
1679         muse_core_api_module_e muse_module = MUSE_CAMERA;
1680         int device_type = (int)device;
1681
1682         if (camera == NULL) {
1683                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1684                 return CAMERA_ERROR_INVALID_PARAMETER;
1685         }
1686
1687         bufmgr = tbm_bufmgr_init(-1);
1688         if (bufmgr == NULL) {
1689                 LOGE("get tbm bufmgr failed");
1690                 return CAMERA_ERROR_INVALID_OPERATION;
1691         }
1692
1693         sock_fd = muse_core_client_new();
1694         if (sock_fd < 0) {
1695                 LOGE("muse_core_client_new failed - returned fd %d", sock_fd);
1696                 ret = CAMERA_ERROR_INVALID_OPERATION;
1697                 goto ErrorExit;
1698         }
1699
1700         pid = getpid();
1701
1702         sndMsg = muse_core_msg_json_factory_new(api,
1703                 MUSE_TYPE_INT, "module", muse_module,
1704                 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
1705                 MUSE_TYPE_INT, "pid", pid,
1706                 0);
1707
1708         muse_core_ipc_send_msg(sock_fd, sndMsg);
1709         muse_core_msg_json_factory_free(sndMsg);
1710
1711         pc = g_new0(camera_cli_s, 1);
1712         if (pc == NULL) {
1713                 LOGE("camera_cli_s alloc failed");
1714                 ret = CAMERA_ERROR_OUT_OF_MEMORY;
1715                 goto ErrorExit;
1716         }
1717
1718         pc->cb_info = _client_callback_new(sock_fd);
1719         if (pc->cb_info == NULL) {
1720                 LOGE("cb_info alloc failed");
1721                 ret = CAMERA_ERROR_OUT_OF_MEMORY;
1722                 goto ErrorExit;
1723         }
1724
1725         LOGD("cb info : %d", pc->cb_info->fd);
1726
1727         ret = _client_wait_for_cb_return(api, pc->cb_info, CALLBACK_TIME_OUT);
1728         if (ret == CAMERA_ERROR_NONE) {
1729                 intptr_t handle = 0;
1730                 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
1731                 if (handle == 0) {
1732                         LOGE("Receiving Handle Failed!!");
1733                         ret = CAMERA_ERROR_INVALID_OPERATION;
1734                         goto ErrorExit;
1735                 }
1736
1737                 pc->remote_handle = handle;
1738                 pc->cb_info->bufmgr = bufmgr;
1739
1740                 LOGD("camera create 0x%x", pc->remote_handle);
1741                 *camera = (camera_h) pc;
1742         } else {
1743                 goto ErrorExit;
1744         }
1745
1746         return ret;
1747
1748 ErrorExit:
1749         tbm_bufmgr_deinit(bufmgr);
1750         bufmgr = NULL;
1751
1752         if (pc) {
1753                 _client_callback_destroy(pc->cb_info);
1754                 pc->cb_info = NULL;
1755                 g_free(pc);
1756                 pc = NULL;
1757         }
1758
1759         LOGE("camera create error : 0x%x", ret);
1760
1761         return ret;
1762 }
1763
1764 int camera_destroy(camera_h camera)
1765 {
1766         if (camera == NULL) {
1767                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1768                 return CAMERA_ERROR_INVALID_PARAMETER;
1769         }
1770
1771         int ret = CAMERA_ERROR_NONE;
1772         muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
1773         camera_cli_s *pc = (camera_cli_s *)camera;
1774         int sock_fd = 0;
1775
1776         LOGD("ENTER");
1777
1778         if (pc->cb_info == NULL) {
1779                 LOGE("cb_info NULL, INVALID_PARAMETER");
1780                 return CAMERA_ERROR_INVALID_PARAMETER;
1781         }
1782
1783         sock_fd = pc->cb_info->fd;
1784
1785         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
1786         if (ret == CAMERA_ERROR_NONE) {
1787                 if (pc->client_handle) {
1788                         mm_camcorder_client_destroy(pc->client_handle);
1789                         pc->client_handle = NULL;
1790                 }
1791                 _camera_remove_idle_event_all(pc->cb_info);
1792                 _client_callback_destroy(pc->cb_info);
1793                 pc->cb_info = NULL;
1794
1795 #ifdef HAVE_WAYLAND
1796                 if (pc->wl_info) {
1797                         g_free(pc->wl_info);
1798                         pc->wl_info = NULL;
1799                 }
1800 #endif /* HAVE_WAYLAND */
1801
1802                 g_free(pc);
1803                 pc = NULL;
1804         } else {
1805                 LOGE("camera destroy error : 0x%x", ret);
1806         }
1807
1808         return ret;
1809 }
1810
1811 int camera_start_preview(camera_h camera)
1812 {
1813         int ret = CAMERA_ERROR_NONE;
1814         muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
1815         camera_cli_s *pc = (camera_cli_s *)camera;
1816         int sock_fd = 0;
1817         char caps[MUSE_CAMERA_MSG_MAX_LENGTH] = {0};
1818
1819         if (camera == NULL) {
1820                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1821                 return CAMERA_ERROR_INVALID_PARAMETER;
1822         }
1823
1824         if (pc->cb_info == NULL) {
1825                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1826                 return CAMERA_ERROR_INVALID_PARAMETER;
1827         }
1828
1829         LOGD("start");
1830
1831         sock_fd = pc->cb_info->fd;
1832
1833         if (pc->client_handle == NULL) {
1834                 LOGW("set display is not called by application. set NONE type internally");
1835                 ret = camera_set_display(camera, CAMERA_DISPLAY_TYPE_NONE, NULL);
1836                 if (ret != CAMERA_ERROR_NONE) {
1837                         LOGE("Internal camera_set_display failed 0x%x", ret);
1838                         return ret;
1839                 }
1840         }
1841
1842         muse_camera_msg_send_longtime(api, sock_fd, pc->cb_info, ret);
1843
1844         if (ret != CAMERA_ERROR_NONE) {
1845                 LOGE("start preview failed 0x%x", ret);
1846                 return ret;
1847         }
1848
1849         if (pc->cb_info->prev_state == CAMERA_STATE_CREATED) {
1850                 if (muse_camera_msg_get_string(caps, pc->cb_info->recv_msg) == FALSE) {
1851                         LOGE("failed to get caps string");
1852                         goto _START_PREVIEW_ERROR;
1853                 }
1854
1855                 LOGD("caps : %s", caps);
1856
1857                 ret = mm_camcorder_client_realize(pc->client_handle, caps);
1858                 if (ret != MM_ERROR_NONE) {
1859                         LOGE("client realize failed 0x%x", ret);
1860                         goto _START_PREVIEW_ERROR;
1861                 }
1862         }
1863
1864         LOGD("ret : 0x%x", ret);
1865
1866         return CAMERA_ERROR_NONE;
1867
1868 _START_PREVIEW_ERROR:
1869         muse_camera_msg_send_longtime(MUSE_CAMERA_API_STOP_PREVIEW, sock_fd, pc->cb_info, ret);
1870
1871         return CAMERA_ERROR_INVALID_OPERATION;
1872 }
1873
1874 int camera_stop_preview(camera_h camera)
1875 {
1876         if (camera == NULL) {
1877                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1878                 return CAMERA_ERROR_INVALID_PARAMETER;
1879         }
1880         int ret = CAMERA_ERROR_NONE;
1881         camera_cli_s *pc = (camera_cli_s *)camera;
1882         int sock_fd;
1883         muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
1884
1885         if (pc->cb_info == NULL) {
1886                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1887                 return CAMERA_ERROR_INVALID_PARAMETER;
1888         }
1889
1890         sock_fd = pc->cb_info->fd;
1891         LOGD("Enter");
1892         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
1893
1894         if (ret != CAMERA_ERROR_NONE) {
1895                 LOGE("stop preview failed 0x%x", ret);
1896                 return ret;
1897         }
1898
1899         if (pc->client_handle != NULL) {
1900                 if (mm_camcorder_client_unrealize(pc->client_handle) == MM_ERROR_NONE) {
1901                         LOGD("client unrealize done");
1902                 } else {
1903                         LOGE("client unrealize failed. restart preview...");
1904                         muse_camera_msg_send_longtime(MUSE_CAMERA_API_START_PREVIEW, sock_fd, pc->cb_info, ret);
1905                         return CAMERA_ERROR_INVALID_OPERATION;
1906                 }
1907         } else {
1908                 LOGW("client handle is NULL");
1909         }
1910
1911         LOGD("ret : 0x%x", ret);
1912
1913         return ret;
1914 }
1915
1916 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
1917 {
1918         if (camera == NULL) {
1919                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1920                 return CAMERA_ERROR_INVALID_PARAMETER;
1921         }
1922         int ret = CAMERA_ERROR_NONE;
1923
1924         camera_cli_s *pc = (camera_cli_s *)camera;
1925         muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
1926         int sock_fd;
1927         int is_capturing_cb = 0;
1928         int is_completed_cb = 0;
1929         LOGD("Enter, handle :%x", pc->remote_handle);
1930
1931         if (pc->cb_info == NULL) {
1932                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1933                 return CAMERA_ERROR_INVALID_PARAMETER;
1934         }
1935
1936         sock_fd = pc->cb_info->fd;
1937
1938         if (capturing_cb != NULL) {
1939                 is_capturing_cb = 1;
1940                 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
1941                 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
1942         }
1943
1944         if (completed_cb != NULL) {
1945                 is_completed_cb = 1;
1946                 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
1947                 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
1948         }
1949
1950         muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, is_capturing_cb, INT, is_completed_cb);
1951         LOGD("is_capturing_cb :%d, is_completed_cb : %d", is_capturing_cb, is_completed_cb);
1952         LOGD("ret : 0x%x", ret);
1953         return ret;
1954 }
1955
1956 bool camera_is_supported_continuous_capture(camera_h camera)
1957 {
1958         if (camera == NULL) {
1959                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1960                 return false;
1961         }
1962
1963         int ret = CAMERA_ERROR_NONE;
1964         camera_cli_s *pc = (camera_cli_s *)camera;
1965         muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
1966         int sock_fd;
1967
1968         if (pc->cb_info == NULL) {
1969                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1970                 return CAMERA_ERROR_INVALID_PARAMETER;
1971         }
1972
1973         sock_fd = pc->cb_info->fd;
1974
1975         LOGD("Enter, remote_handle : %x", pc->remote_handle);
1976         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
1977         LOGD("ret : 0x%x", ret);
1978         return (bool)ret;
1979 }
1980
1981 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)
1982 {
1983         if (camera == NULL) {
1984                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1985                 return CAMERA_ERROR_INVALID_PARAMETER;
1986         }
1987
1988         int ret = CAMERA_ERROR_NONE;
1989
1990         camera_cli_s *pc = (camera_cli_s *)camera;
1991         muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
1992
1993         LOGD("Enter, handle :%x", pc->remote_handle);
1994
1995         int sock_fd;
1996         if (pc->cb_info == NULL) {
1997                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1998                 return CAMERA_ERROR_INVALID_PARAMETER;
1999         }
2000         sock_fd = pc->cb_info->fd;
2001
2002         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2003         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2004         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2005
2006         muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, count, INT, interval);
2007
2008         LOGD("ret : 0x%x", ret);
2009
2010         return ret;
2011 }
2012
2013 int camera_stop_continuous_capture(camera_h camera)
2014 {
2015         if (camera == NULL) {
2016                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2017                 return CAMERA_ERROR_INVALID_PARAMETER;
2018         }
2019
2020
2021         int ret = CAMERA_ERROR_NONE;
2022
2023         camera_cli_s *pc = (camera_cli_s *)camera;
2024         muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2025         LOGD("Enter,  handle :%x", pc->remote_handle);
2026         int sock_fd;
2027         if (pc->cb_info == NULL) {
2028                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2029                 return CAMERA_ERROR_INVALID_PARAMETER;
2030         }
2031         sock_fd = pc->cb_info->fd;
2032         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2033         LOGD("ret : 0x%x", ret);
2034         return ret;
2035 }
2036
2037 bool camera_is_supported_face_detection(camera_h camera)
2038 {
2039         if (camera == NULL) {
2040                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2041                 return false;
2042         }
2043         int ret = CAMERA_ERROR_NONE;
2044
2045         camera_cli_s *pc = (camera_cli_s *)camera;
2046         muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2047         int sock_fd;
2048         if (pc->cb_info == NULL) {
2049                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2050                 return CAMERA_ERROR_INVALID_PARAMETER;
2051         }
2052         sock_fd = pc->cb_info->fd;
2053
2054         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2055         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2056         LOGD("ret : 0x%x", ret);
2057         return (bool)ret;
2058 }
2059
2060 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2061 {
2062         if (camera == NULL) {
2063                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2064                 return false;
2065         }
2066         int ret = CAMERA_ERROR_NONE;
2067
2068         camera_cli_s *pc = (camera_cli_s *)camera;
2069         muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2070         int sock_fd;
2071         if (pc->cb_info == NULL) {
2072                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2073                 return CAMERA_ERROR_INVALID_PARAMETER;
2074         }
2075         sock_fd = pc->cb_info->fd;
2076
2077         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2078         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2079         LOGD("ret : 0x%x", ret);
2080         return (bool)ret;
2081 }
2082
2083 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2084 {
2085         if (camera == NULL) {
2086                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2087                 return false;
2088         }
2089
2090         int ret = CAMERA_ERROR_NONE;
2091
2092         camera_cli_s *pc = (camera_cli_s *)camera;
2093         muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2094         int sock_fd;
2095         if (pc->cb_info == NULL) {
2096                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2097                 return CAMERA_ERROR_INVALID_PARAMETER;
2098         }
2099         sock_fd = pc->cb_info->fd;
2100
2101         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2102         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2103         LOGD("ret : 0x%x", ret);
2104         return (bool)ret;
2105 }
2106
2107 int camera_get_device_count(camera_h camera, int *device_count)
2108 {
2109         if (camera == NULL || device_count == NULL) {
2110                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2111                 return CAMERA_ERROR_INVALID_PARAMETER;
2112         }
2113         int ret = CAMERA_ERROR_NONE;
2114
2115         camera_cli_s *pc = (camera_cli_s *)camera;
2116         muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2117         int sock_fd;
2118         if (pc->cb_info == NULL) {
2119                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2120                 return CAMERA_ERROR_INVALID_PARAMETER;
2121         }
2122         sock_fd = pc->cb_info->fd;
2123         int get_device_count;
2124
2125         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2126         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2127
2128         if (ret == CAMERA_ERROR_NONE) {
2129                 muse_camera_msg_get(get_device_count, pc->cb_info->recv_msg);
2130                 *device_count = get_device_count;
2131         }
2132         LOGD("ret : 0x%x", ret);
2133         return ret;
2134 }
2135
2136 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void * user_data)
2137 {
2138         if (camera == NULL) {
2139                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2140                 return CAMERA_ERROR_INVALID_PARAMETER;
2141         }
2142
2143         int ret = CAMERA_ERROR_NONE;
2144
2145         camera_cli_s *pc = (camera_cli_s *)camera;
2146         muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2147
2148         LOGD("Enter, handle :%x", pc->remote_handle);
2149         int sock_fd;
2150         if (pc->cb_info == NULL) {
2151                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2152                 return CAMERA_ERROR_INVALID_PARAMETER;
2153         }
2154         sock_fd = pc->cb_info->fd;
2155         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2156         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2157
2158         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2159         LOGD("ret : 0x%x", ret);
2160         return ret;
2161 }
2162
2163 int camera_stop_face_detection(camera_h camera)
2164 {
2165         if (camera == NULL) {
2166                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2167                 return CAMERA_ERROR_INVALID_PARAMETER;
2168         }
2169
2170         int ret = CAMERA_ERROR_NONE;
2171
2172         camera_cli_s *pc = (camera_cli_s *)camera;
2173         muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
2174         LOGD("Enter,  handle :%x", pc->remote_handle);
2175         int sock_fd;
2176         if (pc->cb_info == NULL) {
2177                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2178                 return CAMERA_ERROR_INVALID_PARAMETER;
2179         }
2180         sock_fd = pc->cb_info->fd;
2181         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2182         LOGD("ret : 0x%x", ret);
2183         return ret;
2184 }
2185
2186 int camera_get_state(camera_h camera, camera_state_e * state)
2187 {
2188         if (camera == NULL || state == NULL) {
2189                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2190                 return CAMERA_ERROR_INVALID_PARAMETER;
2191         }
2192         int ret = CAMERA_ERROR_NONE;
2193
2194         camera_cli_s *pc = (camera_cli_s *)camera;
2195         muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
2196         int sock_fd;
2197         if (pc->cb_info == NULL) {
2198                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2199                 return CAMERA_ERROR_INVALID_PARAMETER;
2200         }
2201         sock_fd = pc->cb_info->fd;
2202         int get_state;
2203
2204         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2205         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2206
2207         if (ret == CAMERA_ERROR_NONE) {
2208                 muse_camera_msg_get(get_state, pc->cb_info->recv_msg);
2209                 *state = (camera_state_e)get_state;
2210         }
2211         LOGD("ret : 0x%x", ret);
2212         return ret;
2213 }
2214
2215 int camera_start_focusing(camera_h camera, bool continuous)
2216 {
2217         if (camera == NULL) {
2218                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2219                 return CAMERA_ERROR_INVALID_PARAMETER;
2220         }
2221
2222         int ret = CAMERA_ERROR_NONE;
2223
2224         camera_cli_s *pc = (camera_cli_s *)camera;
2225         muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
2226         int sock_fd;
2227         if (pc->cb_info == NULL) {
2228                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2229                 return CAMERA_ERROR_INVALID_PARAMETER;
2230         }
2231         sock_fd = pc->cb_info->fd;
2232         int is_continuous = (int)continuous;
2233
2234         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2235         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, is_continuous);
2236         LOGD("ret : 0x%x", ret);
2237         return ret;
2238 }
2239
2240 int camera_cancel_focusing(camera_h camera)
2241 {
2242         if (camera == NULL) {
2243                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2244                 return CAMERA_ERROR_INVALID_PARAMETER;
2245         }
2246
2247         int ret = CAMERA_ERROR_NONE;
2248
2249         camera_cli_s *pc = (camera_cli_s *)camera;
2250         muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
2251         int sock_fd;
2252         if (pc->cb_info == NULL) {
2253                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2254                 return CAMERA_ERROR_INVALID_PARAMETER;
2255         }
2256         sock_fd = pc->cb_info->fd;
2257
2258         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2259         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2260         LOGD("ret : 0x%x", ret);
2261         return ret;
2262 }
2263
2264 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
2265 {
2266         int ret = CAMERA_ERROR_NONE;
2267         void *set_display_handle = NULL;
2268         int set_surface = MM_DISPLAY_SURFACE_X;
2269         Evas_Object *obj = NULL;
2270         const char *object_type = NULL;
2271         char socket_path[MUSE_CAMERA_MSG_MAX_LENGTH] = {0,};
2272 #ifdef HAVE_WAYLAND
2273         MMCamWaylandInfo *wl_info = NULL;
2274 #endif /* HAVE_WAYLAND */
2275
2276         if (camera == NULL) {
2277                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2278                 return CAMERA_ERROR_INVALID_PARAMETER;
2279         }
2280
2281         if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
2282                 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
2283                 return CAMERA_ERROR_INVALID_PARAMETER;
2284         }
2285
2286         camera_cli_s *pc = (camera_cli_s *)camera;
2287         muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
2288         int sock_fd;
2289         if (pc->cb_info == NULL) {
2290                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2291                 return CAMERA_ERROR_INVALID_PARAMETER;
2292         }
2293         sock_fd = pc->cb_info->fd;
2294
2295         LOGD("Enter, remote_handle : %x display : 0x%x", pc->remote_handle, display);
2296
2297         if (type == CAMERA_DISPLAY_TYPE_NONE) {
2298                 set_display_handle = 0;
2299                 set_surface = MM_DISPLAY_SURFACE_NULL;
2300                 LOGD("display type NONE");
2301         } else {
2302                 obj = (Evas_Object *)display;
2303                 object_type = evas_object_type_get(obj);
2304                 if (object_type) {
2305                         if (type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
2306 #ifdef HAVE_WAYLAND
2307                                 /* set wayland info */
2308                                 wl_info = _get_wl_info(obj);
2309                                 if (wl_info == NULL) {
2310                                         LOGE("failed to get wl_info");
2311                                         return CAMERA_ERROR_INVALID_OPERATION;
2312                                 }
2313
2314                                 set_display_handle = (void *)wl_info;
2315 #else /* HAVE_WAYLAND */
2316                                 /* x window overlay surface */
2317                                 set_display_handle = (void *)elm_win_xwindow_get(obj);
2318 #endif
2319                                 set_surface = MM_DISPLAY_SURFACE_X;
2320                                 LOGD("display type OVERLAY : handle %p", set_display_handle);
2321                         } else if (type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
2322                                 /* evas object surface */
2323                                 set_display_handle = (void *)display;
2324                                 set_surface = MM_DISPLAY_SURFACE_EVAS;
2325                                 LOGD("display type EVAS : handle %p", set_display_handle);
2326                         } else {
2327                                 LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type);
2328                                 return CAMERA_ERROR_INVALID_PARAMETER;
2329                         }
2330                 } else {
2331                         LOGE("failed to get evas object type from %p", obj);
2332                         return CAMERA_ERROR_INVALID_PARAMETER;
2333                 }
2334         }
2335
2336         pc->display_handle = (intptr_t)set_display_handle;
2337
2338         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2339
2340         if (ret == CAMERA_ERROR_NONE) {
2341                 if (pc->client_handle == NULL) {
2342                         ret = mm_camcorder_client_create(&pc->client_handle);
2343                         if (ret != MM_ERROR_NONE) {
2344                                 LOGE("camera client create Failed 0x%x", ret);
2345                                 goto _SET_DISPLAY_ERROR;
2346                         }
2347                 }
2348
2349                 if (muse_camera_msg_get_string(socket_path, pc->cb_info->recv_msg) == FALSE) {
2350                         LOGE("failed to get socket path");
2351                         goto _SET_DISPLAY_ERROR;
2352                 }
2353
2354                 LOGD("shmsrc socket path : %s", socket_path);
2355
2356                 ret = mm_camcorder_client_set_shm_socket_path(pc->client_handle, socket_path);
2357                 if (ret != MM_ERROR_NONE) {
2358                         LOGE("failed to set socket path 0x%x", ret);
2359                         goto _SET_DISPLAY_ERROR;
2360                 }
2361
2362                 ret = mm_camcorder_set_attributes(pc->client_handle, NULL,
2363                         MMCAM_DISPLAY_SURFACE, set_surface,
2364                         NULL);
2365                 if (ret != MM_ERROR_NONE) {
2366                         LOGE("set display surface failed 0x%x", ret);
2367                         goto _SET_DISPLAY_ERROR;
2368                 }
2369
2370                 if (type != CAMERA_DISPLAY_TYPE_NONE) {
2371                         ret = mm_camcorder_set_attributes(pc->client_handle, NULL,
2372                                 MMCAM_DISPLAY_HANDLE, set_display_handle, sizeof(void *),
2373                                 NULL);
2374                         if (ret != MM_ERROR_NONE) {
2375                                 LOGE("set display handle failed 0x%x", ret);
2376                                 goto _SET_DISPLAY_ERROR;
2377                         }
2378                 }
2379
2380 #ifdef HAVE_WAYLAND
2381                 if (pc->wl_info) {
2382                         g_free(pc->wl_info);
2383                         pc->wl_info = NULL;
2384                 }
2385
2386                 pc->wl_info = wl_info;
2387 #endif /* HAVE_WAYLAND */
2388
2389                 return CAMERA_ERROR_NONE;;
2390         } else {
2391                 LOGE("set display error - 0x%x");
2392                 return ret;
2393         }
2394
2395 _SET_DISPLAY_ERROR:
2396 #ifdef HAVE_WAYLAND
2397         if (wl_info) {
2398                 g_free(wl_info);
2399                 wl_info = NULL;
2400         }
2401 #endif /* HAVE_WAYLAND */
2402
2403         return __convert_camera_error_code(__func__, ret);
2404 }
2405
2406 int camera_set_preview_resolution(camera_h camera,  int width, int height)
2407 {
2408         if (camera == NULL) {
2409                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2410                 return CAMERA_ERROR_INVALID_PARAMETER;
2411         }
2412         int ret = CAMERA_ERROR_NONE;
2413
2414         camera_cli_s *pc = (camera_cli_s *)camera;
2415         muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
2416         int sock_fd;
2417         if (pc->cb_info == NULL) {
2418                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2419                 return CAMERA_ERROR_INVALID_PARAMETER;
2420         }
2421         sock_fd = pc->cb_info->fd;
2422
2423         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2424         muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, width, INT, height);
2425         LOGD("ret : 0x%x", ret);
2426         return ret;
2427 }
2428
2429
2430 int camera_set_capture_resolution(camera_h camera,  int width, int height)
2431 {
2432         if (camera == NULL) {
2433                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2434                 return CAMERA_ERROR_INVALID_PARAMETER;
2435         }
2436
2437         int ret = CAMERA_ERROR_NONE;
2438
2439         camera_cli_s *pc = (camera_cli_s *)camera;
2440         muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
2441         int sock_fd;
2442         if (pc->cb_info == NULL) {
2443                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2444                 return CAMERA_ERROR_INVALID_PARAMETER;
2445         }
2446         sock_fd = pc->cb_info->fd;
2447
2448         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2449         muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, width, INT, height);
2450         LOGD("ret : 0x%x", ret);
2451         return ret;
2452 }
2453
2454 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
2455 {
2456         if (camera == NULL) {
2457                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2458                 return CAMERA_ERROR_INVALID_PARAMETER;
2459         }
2460
2461         int ret = CAMERA_ERROR_NONE;
2462         int set_format = (int)format;
2463
2464         camera_cli_s *pc = (camera_cli_s *)camera;
2465         muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
2466         int sock_fd;
2467         if (pc->cb_info == NULL) {
2468                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2469                 return CAMERA_ERROR_INVALID_PARAMETER;
2470         }
2471         sock_fd = pc->cb_info->fd;
2472
2473         LOGD("Enter, remote_handle : %x, capture_format: %d", pc->remote_handle, set_format);
2474         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_format);
2475         LOGD("ret : 0x%x", ret);
2476         return ret;
2477 }
2478
2479 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
2480 {
2481         if (camera == NULL) {
2482                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2483                 return CAMERA_ERROR_INVALID_PARAMETER;
2484         }
2485
2486         int ret = CAMERA_ERROR_NONE;
2487         int set_format = (int)format;
2488
2489         camera_cli_s *pc = (camera_cli_s *)camera;
2490         muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
2491         int sock_fd;
2492         if (pc->cb_info == NULL) {
2493                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2494                 return CAMERA_ERROR_INVALID_PARAMETER;
2495         }
2496         sock_fd = pc->cb_info->fd;
2497
2498         LOGD("Enter, remote_handle : %x, capture_format: %d", pc->remote_handle, set_format);
2499         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_format);
2500         LOGD("ret : 0x%x", ret);
2501         return ret;
2502 }
2503
2504 int camera_get_preview_resolution(camera_h camera,  int *width, int *height)
2505 {
2506         if (camera == NULL || width == NULL || height == NULL) {
2507                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2508                 return CAMERA_ERROR_INVALID_PARAMETER;
2509         }
2510
2511
2512         int ret = CAMERA_ERROR_NONE;
2513
2514         camera_cli_s *pc = (camera_cli_s *)camera;
2515         muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
2516         int sock_fd;
2517         if (pc->cb_info == NULL) {
2518                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2519                 return CAMERA_ERROR_INVALID_PARAMETER;
2520         }
2521         sock_fd = pc->cb_info->fd;
2522         int get_width;
2523         int get_height;
2524
2525         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2526         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2527
2528         if (ret == CAMERA_ERROR_NONE) {
2529                 muse_camera_msg_get(get_width, pc->cb_info->recv_msg);
2530                 muse_camera_msg_get(get_height, pc->cb_info->recv_msg);
2531                 *width = get_width;
2532                 *height = get_height;
2533         }
2534         LOGD("ret : 0x%x", ret);
2535         return ret;
2536 }
2537
2538 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
2539 {
2540         if (camera == NULL) {
2541                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2542                 return CAMERA_ERROR_INVALID_PARAMETER;
2543         }
2544
2545         int ret = CAMERA_ERROR_NONE;
2546         camera_cli_s *pc = (camera_cli_s *)camera;
2547         muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROTATION;
2548         int sock_fd;
2549         if (pc->cb_info == NULL) {
2550                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2551                 return CAMERA_ERROR_INVALID_PARAMETER;
2552         }
2553         sock_fd = pc->cb_info->fd;
2554         int set_rotation = (int)rotation;
2555
2556         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2557         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_rotation);
2558         LOGD("ret : 0x%x", ret);
2559         return ret;
2560 }
2561
2562 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
2563 {
2564         if (camera == NULL || rotation == NULL) {
2565                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2566                 return CAMERA_ERROR_INVALID_PARAMETER;
2567         }
2568
2569         int ret = CAMERA_ERROR_NONE;
2570
2571         camera_cli_s *pc = (camera_cli_s *)camera;
2572         muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROTATION;
2573         int sock_fd;
2574         if (pc->cb_info == NULL) {
2575                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2576                 return CAMERA_ERROR_INVALID_PARAMETER;
2577         }
2578         sock_fd = pc->cb_info->fd;
2579         int get_rotation;
2580
2581         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2582         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2583
2584         if (ret == CAMERA_ERROR_NONE) {
2585                 muse_camera_msg_get(get_rotation, pc->cb_info->recv_msg);
2586                 *rotation = (camera_rotation_e)get_rotation;
2587         }
2588         LOGD("ret : 0x%x", ret);
2589         return ret;
2590 }
2591
2592 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
2593 {
2594         if (camera == NULL) {
2595                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2596                 return CAMERA_ERROR_INVALID_PARAMETER;
2597         }
2598
2599         int ret = CAMERA_ERROR_NONE;
2600
2601         camera_cli_s *pc = (camera_cli_s *)camera;
2602         muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_FLIP;
2603         int sock_fd;
2604         if (pc->cb_info == NULL) {
2605                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2606                 return CAMERA_ERROR_INVALID_PARAMETER;
2607         }
2608         sock_fd = pc->cb_info->fd;
2609         int set_flip = (int)flip;
2610
2611         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2612         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_flip);
2613         LOGD("ret : 0x%x", ret);
2614         return ret;
2615 }
2616
2617 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
2618 {
2619         if (camera == NULL || flip == NULL) {
2620                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2621                 return CAMERA_ERROR_INVALID_PARAMETER;
2622         }
2623
2624         int ret = CAMERA_ERROR_NONE;
2625
2626         camera_cli_s *pc = (camera_cli_s *)camera;
2627         muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_FLIP;
2628         int sock_fd;
2629         if (pc->cb_info == NULL) {
2630                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2631                 return CAMERA_ERROR_INVALID_PARAMETER;
2632         }
2633         sock_fd = pc->cb_info->fd;
2634         int get_flip;
2635
2636         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2637         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2638
2639         if (ret == CAMERA_ERROR_NONE) {
2640                 muse_camera_msg_get(get_flip, pc->cb_info->recv_msg);
2641                 *flip = (camera_flip_e)get_flip;
2642         }
2643         LOGD("ret : 0x%x", ret);
2644         return ret;
2645 }
2646
2647 int camera_set_display_visible(camera_h camera, bool visible)
2648 {
2649         if (camera == NULL) {
2650                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2651                 return CAMERA_ERROR_INVALID_PARAMETER;
2652         }
2653
2654         int ret = CAMERA_ERROR_NONE;
2655
2656         camera_cli_s *pc = (camera_cli_s *)camera;
2657         muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_VISIBLE;
2658         int set_visible = (int)visible;
2659         int sock_fd;
2660         if (pc->cb_info == NULL) {
2661                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2662                 return CAMERA_ERROR_INVALID_PARAMETER;
2663         }
2664         sock_fd = pc->cb_info->fd;
2665
2666         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2667         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_visible);
2668         LOGD("ret : 0x%x", ret);
2669         return ret;
2670 }
2671
2672 int camera_is_display_visible(camera_h camera, bool* visible)
2673 {
2674         if (camera == NULL || visible == NULL) {
2675                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2676                 return CAMERA_ERROR_INVALID_PARAMETER;
2677         }
2678
2679         int ret = CAMERA_ERROR_NONE;
2680
2681         camera_cli_s *pc = (camera_cli_s *)camera;
2682         muse_camera_api_e api = MUSE_CAMERA_API_IS_DISPLAY_VISIBLE;
2683         int sock_fd;
2684         if (pc->cb_info == NULL) {
2685                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2686                 return CAMERA_ERROR_INVALID_PARAMETER;
2687         }
2688         sock_fd = pc->cb_info->fd;
2689         int get_visible;
2690
2691         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2692         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2693
2694         if (ret == CAMERA_ERROR_NONE) {
2695                 muse_camera_msg_get(get_visible, pc->cb_info->recv_msg);
2696                 *visible = (bool)get_visible;
2697         }
2698         LOGD("ret : 0x%x", ret);
2699         return ret;
2700 }
2701
2702 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
2703 {
2704         if (camera == NULL) {
2705                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2706                 return CAMERA_ERROR_INVALID_PARAMETER;
2707         }
2708
2709         int ret = CAMERA_ERROR_NONE;
2710         int set_mode = (int)mode;
2711
2712         camera_cli_s *pc = (camera_cli_s *)camera;
2713         muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_MODE;
2714         int sock_fd;
2715         if (pc->cb_info == NULL) {
2716                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2717                 return CAMERA_ERROR_INVALID_PARAMETER;
2718         }
2719         sock_fd = pc->cb_info->fd;
2720
2721         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2722         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
2723         LOGD("ret : 0x%x", ret);
2724         return ret;
2725 }
2726
2727 int camera_get_display_mode(camera_h camera, camera_display_mode_e* mode)
2728 {
2729         if (camera == NULL || mode == NULL) {
2730                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2731                 return CAMERA_ERROR_INVALID_PARAMETER;
2732         }
2733
2734         int ret = CAMERA_ERROR_NONE;
2735
2736         camera_cli_s *pc = (camera_cli_s *)camera;
2737         muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_MODE;
2738         int sock_fd;
2739         if (pc->cb_info == NULL) {
2740                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2741                 return CAMERA_ERROR_INVALID_PARAMETER;
2742         }
2743         sock_fd = pc->cb_info->fd;
2744         int get_mode;
2745
2746         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2747         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2748
2749         if (ret == CAMERA_ERROR_NONE) {
2750                 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
2751                 *mode = (camera_display_mode_e)get_mode;
2752         }
2753         LOGD("ret : 0x%x", ret);
2754         return ret;
2755 }
2756
2757 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
2758 {
2759         if (camera == NULL || width == NULL || height == NULL) {
2760                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2761                 return CAMERA_ERROR_INVALID_PARAMETER;
2762         }
2763         int ret = CAMERA_ERROR_NONE;
2764
2765         camera_cli_s *pc = (camera_cli_s *)camera;
2766         muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
2767         int sock_fd;
2768         if (pc->cb_info == NULL) {
2769                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2770                 return CAMERA_ERROR_INVALID_PARAMETER;
2771         }
2772         sock_fd = pc->cb_info->fd;
2773         int get_width;
2774         int get_height;
2775
2776         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2777         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2778
2779         if (ret == CAMERA_ERROR_NONE) {
2780                 muse_camera_msg_get(get_width, pc->cb_info->recv_msg);
2781                 muse_camera_msg_get(get_height, pc->cb_info->recv_msg);
2782                 *width = get_width;
2783                 *height = get_height;
2784         }
2785         LOGD("ret : 0x%x", ret);
2786         return ret;
2787 }
2788
2789 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
2790 {
2791         if (camera == NULL || format == NULL) {
2792                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2793                 return CAMERA_ERROR_INVALID_PARAMETER;
2794         }
2795         int ret = CAMERA_ERROR_NONE;
2796
2797         camera_cli_s *pc = (camera_cli_s *)camera;
2798         muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
2799         int get_format;
2800         int sock_fd;
2801         if (pc->cb_info == NULL) {
2802                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2803                 return CAMERA_ERROR_INVALID_PARAMETER;
2804         }
2805         sock_fd = pc->cb_info->fd;
2806
2807         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2808         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2809
2810         if (ret == CAMERA_ERROR_NONE) {
2811                 muse_camera_msg_get(get_format, pc->cb_info->recv_msg);
2812                 *format = (camera_pixel_format_e)get_format;
2813         }
2814         LOGD("ret : 0x%x", ret);
2815         return ret;
2816 }
2817
2818 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
2819 {
2820         if (camera == NULL || format == NULL) {
2821                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2822                 return CAMERA_ERROR_INVALID_PARAMETER;
2823         }
2824
2825         int ret = CAMERA_ERROR_NONE;
2826
2827         camera_cli_s *pc = (camera_cli_s *)camera;
2828         muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
2829         int get_format;
2830         int sock_fd;
2831         if (pc->cb_info == NULL) {
2832                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2833                 return CAMERA_ERROR_INVALID_PARAMETER;
2834         }
2835         sock_fd = pc->cb_info->fd;
2836
2837         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2838         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2839
2840         if (ret == CAMERA_ERROR_NONE) {
2841                 muse_camera_msg_get(get_format, pc->cb_info->recv_msg);
2842                 *format = (camera_pixel_format_e)get_format;
2843         }
2844         LOGD("ret : 0x%x", ret);
2845         return ret;
2846 }
2847
2848 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direciton)
2849 {
2850         if (camera == NULL || facing_direciton == NULL) {
2851                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2852                 return CAMERA_ERROR_INVALID_PARAMETER;
2853         }
2854
2855         int ret = CAMERA_ERROR_NONE;
2856
2857         camera_cli_s *pc = (camera_cli_s *)camera;
2858         muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
2859         int sock_fd;
2860         if (pc->cb_info == NULL) {
2861                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2862                 return CAMERA_ERROR_INVALID_PARAMETER;
2863         }
2864         sock_fd = pc->cb_info->fd;
2865         int get_facing_direction;
2866
2867         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2868         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2869
2870         if (ret == CAMERA_ERROR_NONE) {
2871                 muse_camera_msg_get(get_facing_direction, pc->cb_info->recv_msg);
2872                 *facing_direciton = (camera_facing_direction_e)get_facing_direction;
2873         }
2874         LOGD("ret : 0x%x", ret);
2875         return ret;
2876 }
2877
2878 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void* user_data)
2879 {
2880         if (camera == NULL || callback == NULL) {
2881                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2882                 return CAMERA_ERROR_INVALID_PARAMETER;
2883         }
2884         int ret = CAMERA_ERROR_NONE;
2885
2886         camera_cli_s *pc = (camera_cli_s *)camera;
2887         int sock_fd;
2888         if (pc->cb_info == NULL) {
2889                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2890                 return CAMERA_ERROR_INVALID_PARAMETER;
2891         }
2892         sock_fd = pc->cb_info->fd;
2893         muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
2894
2895         LOGD("Enter, handle :%x", pc->remote_handle);
2896
2897         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
2898         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
2899
2900         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2901         LOGD("ret : 0x%x", ret);
2902         return ret;
2903 }
2904
2905 int camera_unset_preview_cb(camera_h camera)
2906 {
2907         if (camera == NULL) {
2908                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2909                 return CAMERA_ERROR_INVALID_PARAMETER;
2910         }
2911
2912         int ret = CAMERA_ERROR_NONE;
2913
2914         camera_cli_s *pc = (camera_cli_s *)camera;
2915         muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
2916
2917         LOGD("Enter, handle :%x", pc->remote_handle);
2918
2919         int sock_fd;
2920         if (pc->cb_info == NULL) {
2921                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2922                 return CAMERA_ERROR_INVALID_PARAMETER;
2923         }
2924         sock_fd = pc->cb_info->fd;
2925         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = (void *)NULL;
2926         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = (void *)NULL;
2927
2928         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2929         LOGD("ret : 0x%x", ret);
2930         return ret;
2931 }
2932
2933 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void* user_data)
2934 {
2935         if (camera == NULL) {
2936                 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
2937                 return CAMERA_ERROR_INVALID_PARAMETER;
2938         }
2939
2940         if (camera_is_supported_media_packet_preview_cb(camera) == false) {
2941                 LOGE("NOT SUPPORTED");
2942                 return CAMERA_ERROR_NOT_SUPPORTED;
2943         }
2944
2945         if (callback == NULL) {
2946                 LOGE("INVALID_PARAMETER(0x%08x) - callback", CAMERA_ERROR_INVALID_PARAMETER);
2947                 return CAMERA_ERROR_INVALID_PARAMETER;
2948         }
2949
2950         int ret = CAMERA_ERROR_NONE;
2951
2952         camera_cli_s *pc = (camera_cli_s *)camera;
2953         muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
2954
2955         LOGD("Enter, handle :%x", pc->remote_handle);
2956
2957         int sock_fd;
2958         if (pc->cb_info == NULL) {
2959                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2960                 return CAMERA_ERROR_INVALID_PARAMETER;
2961         }
2962         sock_fd = pc->cb_info->fd;
2963         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
2964         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
2965
2966         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2967         LOGD("ret : 0x%x", ret);
2968         return ret;
2969 }
2970
2971 int camera_unset_media_packet_preview_cb(camera_h camera)
2972 {
2973         if (camera == NULL) {
2974                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2975                 return CAMERA_ERROR_INVALID_PARAMETER;
2976         }
2977
2978         int ret = CAMERA_ERROR_NONE;
2979
2980         camera_cli_s *pc = (camera_cli_s *)camera;
2981         muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
2982
2983         LOGD("Enter, handle :%x", pc->remote_handle);
2984
2985         int sock_fd;
2986         if (pc->cb_info == NULL) {
2987                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2988                 return CAMERA_ERROR_INVALID_PARAMETER;
2989         }
2990         sock_fd = pc->cb_info->fd;
2991         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)NULL;
2992         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)NULL;
2993
2994         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2995         LOGD("ret : 0x%x", ret);
2996         return ret;
2997 }
2998
2999 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void* user_data)
3000 {
3001         if (camera == NULL || callback == NULL) {
3002                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3003                 return CAMERA_ERROR_INVALID_PARAMETER;
3004         }
3005         int ret = CAMERA_ERROR_NONE;
3006
3007         camera_cli_s *pc = (camera_cli_s *)camera;
3008         muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3009
3010         LOGD("Enter, handle :%x", pc->remote_handle);
3011
3012         int sock_fd;
3013         if (pc->cb_info == NULL) {
3014                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3015                 return CAMERA_ERROR_INVALID_PARAMETER;
3016         }
3017         sock_fd = pc->cb_info->fd;
3018         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3019         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3020
3021         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3022         LOGD("ret : 0x%x", ret);
3023         return ret;
3024 }
3025 int camera_unset_state_changed_cb(camera_h camera)
3026 {
3027         if (camera == NULL) {
3028                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3029                 return CAMERA_ERROR_INVALID_PARAMETER;
3030         }
3031         int ret = CAMERA_ERROR_NONE;
3032
3033         camera_cli_s *pc = (camera_cli_s *)camera;
3034         muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3035
3036         LOGD("Enter, handle :%x", pc->remote_handle);
3037
3038         int sock_fd;
3039         if (pc->cb_info == NULL) {
3040                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3041                 return CAMERA_ERROR_INVALID_PARAMETER;
3042         }
3043         sock_fd = pc->cb_info->fd;
3044         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void *)NULL;
3045         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void *)NULL;
3046
3047         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3048         LOGD("ret : 0x%x", ret);
3049         return ret;
3050 }
3051
3052 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3053 {
3054         if (camera == NULL || callback == NULL) {
3055                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3056                 return CAMERA_ERROR_INVALID_PARAMETER;
3057         }
3058         int ret = CAMERA_ERROR_NONE;
3059
3060         camera_cli_s *pc = (camera_cli_s *)camera;
3061         muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3062
3063         LOGD("Enter, handle :%x", pc->remote_handle);
3064
3065         int sock_fd;
3066         if (pc->cb_info == NULL) {
3067                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3068                 return CAMERA_ERROR_INVALID_PARAMETER;
3069         }
3070         sock_fd = pc->cb_info->fd;
3071         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3072         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3073
3074         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3075         LOGD("ret : 0x%x", ret);
3076         return ret;
3077 }
3078
3079 int camera_unset_interrupted_cb(camera_h camera)
3080 {
3081         if (camera == NULL) {
3082                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3083                 return CAMERA_ERROR_INVALID_PARAMETER;
3084         }
3085         int ret = CAMERA_ERROR_NONE;
3086
3087         camera_cli_s *pc = (camera_cli_s *)camera;
3088         muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3089
3090         LOGD("Enter, handle :%x", pc->remote_handle);
3091
3092         int sock_fd;
3093         if (pc->cb_info == NULL) {
3094                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3095                 return CAMERA_ERROR_INVALID_PARAMETER;
3096         }
3097         sock_fd = pc->cb_info->fd;
3098         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = (void *)NULL;
3099         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = (void *)NULL;
3100
3101         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3102         LOGD("ret : 0x%x", ret);
3103         return ret;
3104 }
3105
3106 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void* user_data)
3107 {
3108         if (camera == NULL || callback == NULL) {
3109                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3110                 return CAMERA_ERROR_INVALID_PARAMETER;
3111         }
3112         int ret = CAMERA_ERROR_NONE;
3113
3114         camera_cli_s *pc = (camera_cli_s *)camera;
3115         muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3116
3117         LOGD("Enter, handle :%x", pc->remote_handle);
3118
3119         int sock_fd;
3120         if (pc->cb_info == NULL) {
3121                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3122                 return CAMERA_ERROR_INVALID_PARAMETER;
3123         }
3124         sock_fd = pc->cb_info->fd;
3125         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3126         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3127
3128         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3129         LOGD("ret : 0x%x", ret);
3130         return ret;
3131 }
3132
3133 int camera_unset_focus_changed_cb(camera_h camera)
3134 {
3135         if (camera == NULL) {
3136                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3137                 return CAMERA_ERROR_INVALID_PARAMETER;
3138         }
3139         int ret = CAMERA_ERROR_NONE;
3140
3141         camera_cli_s *pc = (camera_cli_s *)camera;
3142         muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
3143
3144         LOGD("Enter, handle :%x", pc->remote_handle);
3145
3146         int sock_fd;
3147         if (pc->cb_info == NULL) {
3148                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3149                 return CAMERA_ERROR_INVALID_PARAMETER;
3150         }
3151         sock_fd = pc->cb_info->fd;
3152         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void *)NULL;
3153         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void *)NULL;
3154
3155         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3156         LOGD("ret : 0x%x", ret);
3157         return ret;
3158 }
3159
3160 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
3161 {
3162         if (camera == NULL || callback == NULL) {
3163                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3164                 return CAMERA_ERROR_INVALID_PARAMETER;
3165         }
3166         int ret = CAMERA_ERROR_NONE;
3167
3168         camera_cli_s *pc = (camera_cli_s *)camera;
3169         muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
3170
3171         LOGD("Enter, handle :%x", pc->remote_handle);
3172
3173         int sock_fd;
3174         if (pc->cb_info == NULL) {
3175                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3176                 return CAMERA_ERROR_INVALID_PARAMETER;
3177         }
3178         sock_fd = pc->cb_info->fd;
3179         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
3180         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
3181
3182         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3183         LOGD("ret : 0x%x", ret);
3184         return ret;
3185 }
3186
3187 int camera_unset_error_cb(camera_h camera)
3188 {
3189         if (camera == NULL) {
3190                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3191                 return CAMERA_ERROR_INVALID_PARAMETER;
3192         }
3193         int ret = CAMERA_ERROR_NONE;
3194
3195         camera_cli_s *pc = (camera_cli_s *)camera;
3196         muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
3197
3198         LOGD("Enter, handle :%x", pc->remote_handle);
3199
3200         int sock_fd;
3201         if (pc->cb_info == NULL) {
3202                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3203                 return CAMERA_ERROR_INVALID_PARAMETER;
3204         }
3205         sock_fd = pc->cb_info->fd;
3206         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = (void *)NULL;
3207         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = (void *)NULL;
3208
3209         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3210         LOGD("ret : 0x%x", ret);
3211         return ret;
3212 }
3213
3214 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb , void *user_data)
3215 {
3216         if (camera == NULL || foreach_cb == NULL) {
3217                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3218                 return CAMERA_ERROR_INVALID_PARAMETER;
3219         }
3220         int ret = CAMERA_ERROR_NONE;
3221
3222         camera_cli_s *pc = (camera_cli_s *)camera;
3223         muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
3224
3225         LOGD("Enter, handle :%x", pc->remote_handle);
3226
3227         int sock_fd;
3228         if (pc->cb_info == NULL) {
3229                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3230                 return CAMERA_ERROR_INVALID_PARAMETER;
3231         }
3232         sock_fd = pc->cb_info->fd;
3233         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
3234         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
3235
3236         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3237         LOGD("ret : 0x%x", ret);
3238         return ret;
3239 }
3240
3241 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb , void *user_data)
3242 {
3243         if (camera == NULL || foreach_cb == NULL) {
3244                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3245                 return CAMERA_ERROR_INVALID_PARAMETER;
3246         }
3247         int ret = CAMERA_ERROR_NONE;
3248
3249         camera_cli_s *pc = (camera_cli_s *)camera;
3250         muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
3251
3252         LOGD("Enter, handle :%x", pc->remote_handle);
3253
3254         int sock_fd;
3255         if (pc->cb_info == NULL) {
3256                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3257                 return CAMERA_ERROR_INVALID_PARAMETER;
3258         }
3259         sock_fd = pc->cb_info->fd;
3260         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
3261         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
3262
3263         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3264         LOGD("ret : 0x%x", ret);
3265         return ret;
3266 }
3267
3268 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb , void *user_data)
3269 {
3270         if (camera == NULL || foreach_cb == NULL) {
3271                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3272                 return CAMERA_ERROR_INVALID_PARAMETER;
3273         }
3274         int ret = CAMERA_ERROR_NONE;
3275
3276         camera_cli_s *pc = (camera_cli_s *)camera;
3277         muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
3278
3279         LOGD("Enter, handle :%x", pc->remote_handle);
3280
3281         int sock_fd;
3282         if (pc->cb_info == NULL) {
3283                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3284                 return CAMERA_ERROR_INVALID_PARAMETER;
3285         }
3286         sock_fd = pc->cb_info->fd;
3287         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
3288         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
3289
3290         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3291         LOGD("ret : 0x%x", ret);
3292         return ret;
3293 }
3294
3295
3296 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb , void *user_data)
3297 {
3298         if (camera == NULL || foreach_cb == NULL) {
3299                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3300                 return CAMERA_ERROR_INVALID_PARAMETER;
3301         }
3302         int ret = CAMERA_ERROR_NONE;
3303
3304         camera_cli_s *pc = (camera_cli_s *)camera;
3305         muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
3306
3307         LOGD("Enter, handle :%x", pc->remote_handle);
3308
3309         int sock_fd;
3310         if (pc->cb_info == NULL) {
3311                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3312                 return CAMERA_ERROR_INVALID_PARAMETER;
3313         }
3314         sock_fd = pc->cb_info->fd;
3315         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
3316         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
3317
3318         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3319         LOGD("ret : 0x%x", ret);
3320         return ret;
3321 }
3322
3323
3324 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
3325 {
3326         if (camera == NULL || width == NULL || height == NULL) {
3327                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3328                 return CAMERA_ERROR_INVALID_PARAMETER;
3329         }
3330         int ret = CAMERA_ERROR_NONE;
3331
3332         camera_cli_s *pc = (camera_cli_s *)camera;
3333         muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
3334         int sock_fd;
3335         if (pc->cb_info == NULL) {
3336                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3337                 return CAMERA_ERROR_INVALID_PARAMETER;
3338         }
3339         sock_fd = pc->cb_info->fd;
3340         int get_width;
3341         int get_height;
3342
3343         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3344         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3345
3346         if (ret == CAMERA_ERROR_NONE) {
3347                 muse_camera_msg_get(get_width, pc->cb_info->recv_msg);
3348                 muse_camera_msg_get(get_height, pc->cb_info->recv_msg);
3349                 *width = get_width;
3350                 *height = get_height;
3351         }
3352         LOGD("ret : 0x%x", ret);
3353         return ret;
3354 }
3355
3356
3357 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
3358 {
3359         if (camera == NULL || angle == NULL) {
3360                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3361                 return CAMERA_ERROR_INVALID_PARAMETER;
3362         }
3363         int ret = CAMERA_ERROR_NONE;
3364
3365         camera_cli_s *pc = (camera_cli_s *)camera;
3366         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
3367         int sock_fd;
3368         if (pc->cb_info == NULL) {
3369                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3370                 return CAMERA_ERROR_INVALID_PARAMETER;
3371         }
3372         sock_fd = pc->cb_info->fd;
3373         int get_angle;
3374
3375         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3376         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3377
3378         if (ret == CAMERA_ERROR_NONE) {
3379                 muse_camera_msg_get(get_angle, pc->cb_info->recv_msg);
3380                 *angle = get_angle;
3381         }
3382         LOGD("ret : 0x%x", ret);
3383         return ret;
3384 }
3385
3386 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
3387 {
3388         if (camera == NULL) {
3389                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3390                 return CAMERA_ERROR_INVALID_PARAMETER;
3391         }
3392         int ret = CAMERA_ERROR_NONE;
3393         camera_cli_s *pc = (camera_cli_s *)camera;
3394         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
3395         int sock_fd;
3396         if (pc->cb_info == NULL) {
3397                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3398                 return CAMERA_ERROR_INVALID_PARAMETER;
3399         }
3400         sock_fd = pc->cb_info->fd;
3401         int set_mode = (int)mode;
3402         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3403         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
3404         LOGD("ret : 0x%x", ret);
3405         return ret;
3406 }
3407
3408 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
3409 {
3410         if (camera == NULL || mode == NULL) {
3411                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3412                 return CAMERA_ERROR_INVALID_PARAMETER;
3413         }
3414
3415         int ret = CAMERA_ERROR_NONE;
3416         camera_cli_s *pc = (camera_cli_s *)camera;
3417         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
3418         int sock_fd;
3419         if (pc->cb_info == NULL) {
3420                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3421                 return CAMERA_ERROR_INVALID_PARAMETER;
3422         }
3423         sock_fd = pc->cb_info->fd;
3424         int get_mode;
3425         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3426         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3427
3428         if (ret == CAMERA_ERROR_NONE) {
3429                 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
3430                 *mode = (camera_attr_theater_mode_e)get_mode;
3431         }
3432         LOGD("ret : 0x%x", ret);
3433         return ret;
3434 }
3435
3436 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
3437 {
3438         if (camera == NULL || foreach_cb == NULL) {
3439                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3440                 return CAMERA_ERROR_INVALID_PARAMETER;
3441         }
3442         int ret = CAMERA_ERROR_NONE;
3443
3444         camera_cli_s *pc = (camera_cli_s *)camera;
3445         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
3446
3447         LOGD("Enter, handle :%x", pc->remote_handle);
3448
3449         int sock_fd;
3450         if (pc->cb_info == NULL) {
3451                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3452                 return CAMERA_ERROR_INVALID_PARAMETER;
3453         }
3454         sock_fd = pc->cb_info->fd;
3455         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
3456         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
3457
3458         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3459
3460         LOGD("Finish, return :%x", ret);
3461
3462         return ret;
3463 }
3464
3465 int camera_attr_set_preview_fps(camera_h camera,  camera_attr_fps_e fps)
3466 {
3467         if (camera == NULL) {
3468                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3469                 return CAMERA_ERROR_INVALID_PARAMETER;
3470         }
3471         int ret = CAMERA_ERROR_NONE;
3472         camera_cli_s *pc = (camera_cli_s *)camera;
3473         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
3474         int sock_fd;
3475         if (pc->cb_info == NULL) {
3476                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3477                 return CAMERA_ERROR_INVALID_PARAMETER;
3478         }
3479         sock_fd = pc->cb_info->fd;
3480         int set_fps = (int)fps;
3481         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3482         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_fps);
3483         LOGD("ret : 0x%x", ret);
3484         return ret;
3485 }
3486
3487
3488 int camera_attr_set_image_quality(camera_h camera,  int quality)
3489 {
3490         if (camera == NULL) {
3491                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3492                 return CAMERA_ERROR_INVALID_PARAMETER;
3493         }
3494         int ret = CAMERA_ERROR_NONE;
3495
3496         camera_cli_s *pc = (camera_cli_s *)camera;
3497         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
3498         int sock_fd;
3499         if (pc->cb_info == NULL) {
3500                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3501                 return CAMERA_ERROR_INVALID_PARAMETER;
3502         }
3503         sock_fd = pc->cb_info->fd;
3504         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3505         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, quality);
3506         LOGD("ret : 0x%x", ret);
3507         return ret;
3508 }
3509
3510 int camera_attr_get_preview_fps(camera_h camera,  camera_attr_fps_e *fps)
3511 {
3512         if (camera == NULL || fps == NULL) {
3513                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3514                 return CAMERA_ERROR_INVALID_PARAMETER;
3515         }
3516         int ret = CAMERA_ERROR_NONE;
3517
3518         camera_cli_s *pc = (camera_cli_s *)camera;
3519         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
3520         int get_fps;
3521         int sock_fd;
3522         if (pc->cb_info == NULL) {
3523                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3524                 return CAMERA_ERROR_INVALID_PARAMETER;
3525         }
3526         sock_fd = pc->cb_info->fd;
3527
3528         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3529         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3530
3531         if (ret == CAMERA_ERROR_NONE) {
3532                 muse_camera_msg_get(get_fps, pc->cb_info->recv_msg);
3533                 *fps = (camera_attr_fps_e)get_fps;
3534         }
3535         LOGD("ret : 0x%x", ret);
3536         return ret;
3537 }
3538
3539
3540 int camera_attr_get_image_quality(camera_h camera, int *quality)
3541 {
3542         if (camera == NULL || quality == NULL) {
3543                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3544                 return CAMERA_ERROR_INVALID_PARAMETER;
3545         }
3546         int ret = CAMERA_ERROR_NONE;
3547
3548         camera_cli_s *pc = (camera_cli_s *)camera;
3549         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
3550         int sock_fd;
3551         if (pc->cb_info == NULL) {
3552                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3553                 return CAMERA_ERROR_INVALID_PARAMETER;
3554         }
3555         sock_fd = pc->cb_info->fd;
3556         int get_quality;
3557         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3558         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3559
3560         if (ret == CAMERA_ERROR_NONE) {
3561                 muse_camera_msg_get(get_quality, pc->cb_info->recv_msg);
3562                 *quality = get_quality;
3563         }
3564         LOGD("ret : 0x%x", ret);
3565         return ret;
3566 }
3567
3568
3569 int camera_attr_set_zoom(camera_h camera, int zoom)
3570 {
3571         if (camera == NULL) {
3572                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3573                 return CAMERA_ERROR_INVALID_PARAMETER;
3574         }
3575         int ret = CAMERA_ERROR_NONE;
3576
3577         camera_cli_s *pc = (camera_cli_s *)camera;
3578         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
3579         int sock_fd;
3580         if (pc->cb_info == NULL) {
3581                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3582                 return CAMERA_ERROR_INVALID_PARAMETER;
3583         }
3584         sock_fd = pc->cb_info->fd;
3585
3586         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3587         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, zoom);
3588         LOGD("ret : 0x%x", ret);
3589         return ret;
3590 }
3591
3592 int camera_attr_set_af_mode(camera_h camera,  camera_attr_af_mode_e mode)
3593 {
3594         if (camera == NULL) {
3595                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3596                 return CAMERA_ERROR_INVALID_PARAMETER;
3597         }
3598         int ret = CAMERA_ERROR_NONE;
3599
3600         camera_cli_s *pc = (camera_cli_s *)camera;
3601         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
3602         int sock_fd;
3603         if (pc->cb_info == NULL) {
3604                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3605                 return CAMERA_ERROR_INVALID_PARAMETER;
3606         }
3607         sock_fd = pc->cb_info->fd;
3608         int set_mode = (int)mode;
3609         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3610         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
3611         LOGD("ret : 0x%x", ret);
3612         return ret;
3613 }
3614
3615 int camera_attr_set_af_area(camera_h camera, int x, int y)
3616 {
3617         if (camera == NULL) {
3618                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3619                 return CAMERA_ERROR_INVALID_PARAMETER;
3620         }
3621         int ret = CAMERA_ERROR_NONE;
3622         camera_cli_s *pc = (camera_cli_s *)camera;
3623         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
3624         int sock_fd = pc->cb_info->fd;
3625         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3626         muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, x, INT, y);
3627         LOGD("ret : 0x%x", ret);
3628         return ret;
3629 }
3630
3631
3632 int camera_attr_clear_af_area(camera_h camera)
3633 {
3634         if (camera == NULL) {
3635                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3636                 return CAMERA_ERROR_INVALID_PARAMETER;
3637         }
3638         int ret = CAMERA_ERROR_NONE;
3639
3640         camera_cli_s *pc = (camera_cli_s *)camera;
3641         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
3642         int sock_fd;
3643         if (pc->cb_info == NULL) {
3644                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3645                 return CAMERA_ERROR_INVALID_PARAMETER;
3646         }
3647         sock_fd = pc->cb_info->fd;
3648         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3649         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3650         LOGD("ret : 0x%x", ret);
3651         return ret;
3652 }
3653
3654
3655 int camera_attr_set_exposure_mode(camera_h camera,  camera_attr_exposure_mode_e mode)
3656 {
3657         if (camera == NULL) {
3658                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3659                 return CAMERA_ERROR_INVALID_PARAMETER;
3660         }
3661
3662         if (mode < CAMERA_ATTR_EXPOSURE_MODE_OFF || mode > CAMERA_ATTR_EXPOSURE_MODE_CUSTOM) {
3663                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3664                 return CAMERA_ERROR_INVALID_PARAMETER;
3665         }
3666
3667         int ret = CAMERA_ERROR_NONE;
3668         camera_cli_s *pc = (camera_cli_s *)camera;
3669         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
3670         int set_mode = (int)mode;
3671         int sock_fd;
3672         if (pc->cb_info == NULL) {
3673                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3674                 return CAMERA_ERROR_INVALID_PARAMETER;
3675         }
3676         sock_fd = pc->cb_info->fd;
3677         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3678         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
3679         LOGD("ret : 0x%x", ret);
3680         return ret;
3681 }
3682
3683
3684 int camera_attr_set_exposure(camera_h camera, int value)
3685 {
3686         if (camera == NULL) {
3687                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3688                 return CAMERA_ERROR_INVALID_PARAMETER;
3689         }
3690         int ret = CAMERA_ERROR_NONE;
3691
3692         camera_cli_s *pc = (camera_cli_s *)camera;
3693         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
3694         int sock_fd;
3695         if (pc->cb_info == NULL) {
3696                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3697                 return CAMERA_ERROR_INVALID_PARAMETER;
3698         }
3699         sock_fd = pc->cb_info->fd;
3700
3701         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3702         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, value);
3703         LOGD("ret : 0x%x", ret);
3704         return ret;
3705 }
3706
3707
3708 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
3709 {
3710         if (camera == NULL) {
3711                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3712                 return CAMERA_ERROR_INVALID_PARAMETER;
3713         }
3714         int ret = CAMERA_ERROR_NONE;
3715
3716         camera_cli_s *pc = (camera_cli_s *)camera;
3717         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
3718         int sock_fd;
3719         if (pc->cb_info == NULL) {
3720                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3721                 return CAMERA_ERROR_INVALID_PARAMETER;
3722         }
3723         sock_fd = pc->cb_info->fd;
3724         int set_iso = (int)iso;
3725         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3726         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_iso);
3727         LOGD("ret : 0x%x", ret);
3728         return ret;
3729 }
3730
3731
3732 int camera_attr_set_brightness(camera_h camera, int level)
3733 {
3734         if (camera == NULL) {
3735                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3736                 return CAMERA_ERROR_INVALID_PARAMETER;
3737         }
3738         int ret = CAMERA_ERROR_NONE;
3739
3740         camera_cli_s *pc = (camera_cli_s *)camera;
3741         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
3742         int sock_fd;
3743         if (pc->cb_info == NULL) {
3744                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3745                 return CAMERA_ERROR_INVALID_PARAMETER;
3746         }
3747         sock_fd = pc->cb_info->fd;
3748
3749         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3750         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, level);
3751         LOGD("ret : 0x%x", ret);
3752         return ret;
3753 }
3754
3755
3756 int camera_attr_set_contrast(camera_h camera, int level)
3757 {
3758         if (camera == NULL) {
3759                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3760                 return CAMERA_ERROR_INVALID_PARAMETER;
3761         }
3762         int ret = CAMERA_ERROR_NONE;
3763
3764         camera_cli_s *pc = (camera_cli_s *)camera;
3765         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
3766         int sock_fd;
3767         if (pc->cb_info == NULL) {
3768                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3769                 return CAMERA_ERROR_INVALID_PARAMETER;
3770         }
3771         sock_fd = pc->cb_info->fd;
3772
3773         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3774         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, level);
3775         LOGD("ret : 0x%x", ret);
3776         return ret;
3777 }
3778
3779
3780 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
3781 {
3782         if (camera == NULL) {
3783                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3784                 return CAMERA_ERROR_INVALID_PARAMETER;
3785         }
3786
3787         if (wb < CAMERA_ATTR_WHITE_BALANCE_NONE || wb > CAMERA_ATTR_WHITE_BALANCE_CUSTOM) {
3788                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
3789                 return CAMERA_ERROR_NOT_SUPPORTED;
3790         }
3791
3792         int ret = CAMERA_ERROR_NONE;
3793
3794         camera_cli_s *pc = (camera_cli_s *)camera;
3795         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
3796         int sock_fd;
3797         if (pc->cb_info == NULL) {
3798                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3799                 return CAMERA_ERROR_INVALID_PARAMETER;
3800         }
3801         sock_fd = pc->cb_info->fd;
3802         int set_whitebalance = (int)wb;
3803         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3804         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_whitebalance);
3805         LOGD("ret : 0x%x", ret);
3806         return ret;
3807 }
3808
3809
3810 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
3811 {
3812         if (camera == NULL) {
3813                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3814                 return CAMERA_ERROR_INVALID_PARAMETER;
3815         }
3816         int ret = CAMERA_ERROR_NONE;
3817
3818         camera_cli_s *pc = (camera_cli_s *)camera;
3819         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
3820         int sock_fd;
3821         if (pc->cb_info == NULL) {
3822                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3823                 return CAMERA_ERROR_INVALID_PARAMETER;
3824         }
3825         sock_fd = pc->cb_info->fd;
3826         int set_effect = (int)effect;
3827         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3828         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_effect);
3829         LOGD("ret : 0x%x", ret);
3830         return ret;
3831 }
3832
3833
3834 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
3835 {
3836         if (camera == NULL) {
3837                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3838                 return CAMERA_ERROR_INVALID_PARAMETER;
3839         }
3840         int ret = CAMERA_ERROR_NONE;
3841
3842         camera_cli_s *pc = (camera_cli_s *)camera;
3843         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
3844         int sock_fd;
3845         if (pc->cb_info == NULL) {
3846                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3847                 return CAMERA_ERROR_INVALID_PARAMETER;
3848         }
3849         sock_fd = pc->cb_info->fd;
3850         int set_mode = (int)mode;
3851         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3852         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
3853         LOGD("ret : 0x%x", ret);
3854         return ret;
3855 }
3856
3857
3858 int camera_attr_enable_tag(camera_h camera, bool enable)
3859 {
3860         if (camera == NULL) {
3861                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3862                 return CAMERA_ERROR_INVALID_PARAMETER;
3863         }
3864         int ret = CAMERA_ERROR_NONE;
3865         camera_cli_s *pc = (camera_cli_s *)camera;
3866         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
3867         int sock_fd;
3868         if (pc->cb_info == NULL) {
3869                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3870                 return CAMERA_ERROR_INVALID_PARAMETER;
3871         }
3872         sock_fd = pc->cb_info->fd;
3873         int set_enable = (int)enable;
3874
3875         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3876         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable);
3877         LOGD("ret : 0x%x", ret);
3878         return ret;
3879 }
3880
3881
3882 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
3883 {
3884         if (camera == NULL) {
3885                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3886                 return CAMERA_ERROR_INVALID_PARAMETER;
3887         }
3888         if (description == NULL) {
3889                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3890                 return CAMERA_ERROR_INVALID_PARAMETER;
3891         }
3892         int ret = CAMERA_ERROR_NONE;
3893         camera_cli_s *pc = (camera_cli_s *)camera;
3894         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
3895         int sock_fd;
3896         if (pc->cb_info == NULL) {
3897                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3898                 return CAMERA_ERROR_INVALID_PARAMETER;
3899         }
3900         sock_fd = pc->cb_info->fd;
3901         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3902         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, STRING, description);
3903         LOGD("ret : 0x%x", ret);
3904         return ret;
3905 }
3906
3907
3908 int camera_attr_set_tag_orientation(camera_h camera,  camera_attr_tag_orientation_e orientation)
3909 {
3910         if (camera == NULL) {
3911                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3912                 return CAMERA_ERROR_INVALID_PARAMETER;
3913         }
3914         int ret = CAMERA_ERROR_NONE;
3915         camera_cli_s *pc = (camera_cli_s *)camera;
3916         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
3917         int sock_fd;
3918         if (pc->cb_info == NULL) {
3919                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3920                 return CAMERA_ERROR_INVALID_PARAMETER;
3921         }
3922         sock_fd = pc->cb_info->fd;
3923         int set_orientation = (int)orientation;
3924
3925         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3926         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_orientation);
3927         LOGD("ret : 0x%x", ret);
3928         return ret;
3929 }
3930
3931
3932 int camera_attr_set_tag_software(camera_h camera,  const char *software)
3933 {
3934         if (camera == NULL) {
3935                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3936                 return CAMERA_ERROR_INVALID_PARAMETER;
3937         }
3938         if (software == NULL) {
3939                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3940                 return CAMERA_ERROR_INVALID_PARAMETER;
3941         }
3942         int ret = CAMERA_ERROR_NONE;
3943         camera_cli_s *pc = (camera_cli_s *)camera;
3944         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
3945         int sock_fd;
3946         if (pc->cb_info == NULL) {
3947                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3948                 return CAMERA_ERROR_INVALID_PARAMETER;
3949         }
3950         sock_fd = pc->cb_info->fd;
3951         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3952         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, STRING, software);
3953         LOGD("ret : 0x%x", ret);
3954         return ret;
3955 }
3956
3957
3958 int camera_attr_set_geotag(camera_h camera, double latitude , double longitude, double altitude)
3959 {
3960         if (camera == NULL) {
3961                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3962                 return CAMERA_ERROR_INVALID_PARAMETER;
3963         }
3964         int ret = CAMERA_ERROR_NONE;
3965         camera_cli_s *pc = (camera_cli_s *)camera;
3966         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
3967         int sock_fd;
3968         if (pc->cb_info == NULL) {
3969                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3970                 return CAMERA_ERROR_INVALID_PARAMETER;
3971         }
3972         sock_fd = pc->cb_info->fd;
3973         double set_geotag[3] = { latitude, longitude, altitude };
3974
3975         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3976         muse_camera_msg_send_array(api, sock_fd, pc->cb_info, ret,
3977                                                                         set_geotag, sizeof(set_geotag), sizeof(double));
3978         LOGD("ret : 0x%x", ret);
3979         return ret;
3980 }
3981
3982
3983 int camera_attr_remove_geotag(camera_h camera)
3984 {
3985         if (camera == NULL) {
3986                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3987                 return CAMERA_ERROR_INVALID_PARAMETER;
3988         }
3989         int ret = CAMERA_ERROR_NONE;
3990         camera_cli_s *pc = (camera_cli_s *)camera;
3991         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
3992         int sock_fd;
3993         if (pc->cb_info == NULL) {
3994                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3995                 return CAMERA_ERROR_INVALID_PARAMETER;
3996         }
3997         sock_fd = pc->cb_info->fd;
3998         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3999         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4000         LOGD("ret : 0x%x", ret);
4001         return ret;
4002 }
4003
4004
4005 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4006 {
4007         if (camera == NULL) {
4008                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4009                 return CAMERA_ERROR_INVALID_PARAMETER;
4010         }
4011         int ret = CAMERA_ERROR_NONE;
4012         camera_cli_s *pc = (camera_cli_s *)camera;
4013         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
4014         int sock_fd;
4015         if (pc->cb_info == NULL) {
4016                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4017                 return CAMERA_ERROR_INVALID_PARAMETER;
4018         }
4019         sock_fd = pc->cb_info->fd;
4020         int set_mode = (int)mode;
4021
4022         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4023         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
4024         LOGD("ret : 0x%x", ret);
4025         return ret;
4026 }
4027
4028
4029 int camera_attr_get_zoom(camera_h camera, int *zoom)
4030 {
4031         if (camera == NULL || zoom == NULL) {
4032                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4033                 return CAMERA_ERROR_INVALID_PARAMETER;
4034         }
4035         int ret = CAMERA_ERROR_NONE;
4036
4037         camera_cli_s *pc = (camera_cli_s *)camera;
4038         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4039         int get_zoom;
4040         int sock_fd;
4041         if (pc->cb_info == NULL) {
4042                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4043                 return CAMERA_ERROR_INVALID_PARAMETER;
4044         }
4045         sock_fd = pc->cb_info->fd;
4046
4047         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4048         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4049
4050         if (ret == CAMERA_ERROR_NONE) {
4051                 muse_camera_msg_get(get_zoom, pc->cb_info->recv_msg);
4052                 *zoom = get_zoom;
4053         }
4054         LOGD("ret : 0x%x", ret);
4055         return ret;
4056 }
4057
4058
4059 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
4060 {
4061         if (camera == NULL || min == NULL || max == NULL) {
4062                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4063                 return CAMERA_ERROR_INVALID_PARAMETER;
4064         }
4065         int ret = CAMERA_ERROR_NONE;
4066         camera_cli_s *pc = (camera_cli_s *)camera;
4067         int sock_fd;
4068         if (pc->cb_info == NULL) {
4069                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4070                 return CAMERA_ERROR_INVALID_PARAMETER;
4071         }
4072         sock_fd = pc->cb_info->fd;
4073         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
4074         int get_min;
4075         int get_max;
4076
4077         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4078         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4079
4080         if (ret == CAMERA_ERROR_NONE) {
4081                 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
4082                 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
4083                 *min = get_min;
4084                 *max = get_max;
4085         }
4086         LOGD("ret : 0x%x", ret);
4087         return ret;
4088 }
4089
4090
4091 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
4092 {
4093         if (camera == NULL || mode == NULL) {
4094                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4095                 return CAMERA_ERROR_INVALID_PARAMETER;
4096         }
4097         int ret = CAMERA_ERROR_NONE;
4098         camera_cli_s *pc = (camera_cli_s *)camera;
4099         int sock_fd;
4100         if (pc->cb_info == NULL) {
4101                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4102                 return CAMERA_ERROR_INVALID_PARAMETER;
4103         }
4104         sock_fd = pc->cb_info->fd;
4105         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
4106         int get_mode;
4107
4108         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4109         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4110
4111         if (ret == CAMERA_ERROR_NONE) {
4112                 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
4113                 *mode = (camera_attr_af_mode_e)get_mode;
4114         }
4115         LOGD("ret : 0x%x", ret);
4116         return ret;
4117 }
4118
4119
4120 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
4121 {
4122         if (camera == NULL || mode == NULL) {
4123                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4124                 return CAMERA_ERROR_INVALID_PARAMETER;
4125         }
4126         int ret = CAMERA_ERROR_NONE;
4127         camera_cli_s *pc = (camera_cli_s *)camera;
4128         int sock_fd;
4129         if (pc->cb_info == NULL) {
4130                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4131                 return CAMERA_ERROR_INVALID_PARAMETER;
4132         }
4133         sock_fd = pc->cb_info->fd;
4134         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
4135         int get_mode;
4136
4137         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4138         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4139
4140         if (ret == CAMERA_ERROR_NONE) {
4141                 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
4142                 *mode = (camera_attr_exposure_mode_e)get_mode;
4143         }
4144         LOGD("ret : 0x%x", ret);
4145         return ret;
4146 }
4147
4148 int camera_attr_get_exposure(camera_h camera, int *value)
4149 {
4150         if (camera == NULL || value == NULL) {
4151                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4152                 return CAMERA_ERROR_INVALID_PARAMETER;
4153         }
4154         int ret = CAMERA_ERROR_NONE;
4155         camera_cli_s *pc = (camera_cli_s *)camera;
4156         int sock_fd;
4157         if (pc->cb_info == NULL) {
4158                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4159                 return CAMERA_ERROR_INVALID_PARAMETER;
4160         }
4161         sock_fd = pc->cb_info->fd;
4162         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
4163         int get_value;
4164
4165         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4166         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4167
4168         if (ret == CAMERA_ERROR_NONE) {
4169                 muse_camera_msg_get(get_value, pc->cb_info->recv_msg);
4170                 *value = get_value;
4171         }
4172         LOGD("ret : 0x%x", ret);
4173         return ret;
4174 }
4175
4176
4177 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
4178 {
4179         if (camera == NULL || min == NULL || max == NULL) {
4180                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4181                 return CAMERA_ERROR_INVALID_PARAMETER;
4182         }
4183         int ret = CAMERA_ERROR_NONE;
4184         camera_cli_s *pc = (camera_cli_s *)camera;
4185         int sock_fd;
4186         if (pc->cb_info == NULL) {
4187                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4188                 return CAMERA_ERROR_INVALID_PARAMETER;
4189         }
4190         sock_fd = pc->cb_info->fd;
4191         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
4192         int get_min;
4193         int get_max;
4194
4195         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4196         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4197
4198         if (ret == CAMERA_ERROR_NONE) {
4199                 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
4200                 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
4201                 *min = get_min;
4202                 *max = get_max;
4203         }
4204         LOGD("ret : 0x%x", ret);
4205         return ret;
4206 }
4207
4208
4209 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
4210 {
4211         if (camera == NULL || iso == NULL) {
4212                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4213                 return CAMERA_ERROR_INVALID_PARAMETER;
4214         }
4215         int ret = CAMERA_ERROR_NONE;
4216         camera_cli_s *pc = (camera_cli_s *)camera;
4217         int sock_fd;
4218         if (pc->cb_info == NULL) {
4219                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4220                 return CAMERA_ERROR_INVALID_PARAMETER;
4221         }
4222         sock_fd = pc->cb_info->fd;
4223         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
4224         int get_iso;
4225
4226         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4227         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4228
4229         if (ret == CAMERA_ERROR_NONE) {
4230                 muse_camera_msg_get(get_iso, pc->cb_info->recv_msg);
4231                 *iso = (camera_attr_iso_e)get_iso;
4232         }
4233         LOGD("ret : 0x%x", ret);
4234         return ret;
4235 }
4236
4237
4238 int camera_attr_get_brightness(camera_h camera,  int *level)
4239 {
4240         if (camera == NULL || level == NULL) {
4241                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4242                 return CAMERA_ERROR_INVALID_PARAMETER;
4243         }
4244         int ret = CAMERA_ERROR_NONE;
4245         camera_cli_s *pc = (camera_cli_s *)camera;
4246         int sock_fd;
4247         if (pc->cb_info == NULL) {
4248                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4249                 return CAMERA_ERROR_INVALID_PARAMETER;
4250         }
4251         sock_fd = pc->cb_info->fd;
4252         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
4253         int get_level;
4254
4255         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4256         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4257
4258         if (ret == CAMERA_ERROR_NONE) {
4259                 muse_camera_msg_get(get_level, pc->cb_info->recv_msg);
4260                 *level = get_level;
4261         }
4262         LOGD("ret : 0x%x", ret);
4263         return ret;
4264 }
4265
4266
4267 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
4268 {
4269         if (camera == NULL || min == NULL || max == NULL) {
4270                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4271                 return CAMERA_ERROR_INVALID_PARAMETER;
4272         }
4273         int ret = CAMERA_ERROR_NONE;
4274         camera_cli_s *pc = (camera_cli_s *)camera;
4275         int sock_fd;
4276         if (pc->cb_info == NULL) {
4277                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4278                 return CAMERA_ERROR_INVALID_PARAMETER;
4279         }
4280         sock_fd = pc->cb_info->fd;
4281         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
4282         int get_min;
4283         int get_max;
4284
4285         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4286         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4287
4288         if (ret == CAMERA_ERROR_NONE) {
4289                 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
4290                 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
4291                 *min = get_min;
4292                 *max = get_max;
4293         }
4294         LOGD("ret : 0x%x", ret);
4295         return ret;
4296 }
4297
4298
4299 int camera_attr_get_contrast(camera_h camera,  int *level)
4300 {
4301         if (camera == NULL || level == NULL) {
4302                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4303                 return CAMERA_ERROR_INVALID_PARAMETER;
4304         }
4305         int ret = CAMERA_ERROR_NONE;
4306         camera_cli_s *pc = (camera_cli_s *)camera;
4307         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
4308         int sock_fd;
4309         if (pc->cb_info == NULL) {
4310                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4311                 return CAMERA_ERROR_INVALID_PARAMETER;
4312         }
4313         sock_fd = pc->cb_info->fd;
4314         int get_level;
4315
4316         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4317         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4318
4319         if (ret == CAMERA_ERROR_NONE) {
4320                 muse_camera_msg_get(get_level, pc->cb_info->recv_msg);
4321                 *level = get_level;
4322         }
4323         LOGD("ret : 0x%x", ret);
4324         return ret;
4325 }
4326
4327
4328 int camera_attr_get_contrast_range(camera_h camera, int *min , int *max)
4329 {
4330         if (camera == NULL || min == NULL || max == NULL) {
4331                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4332                 return CAMERA_ERROR_INVALID_PARAMETER;
4333         }
4334         int ret = CAMERA_ERROR_NONE;
4335         camera_cli_s *pc = (camera_cli_s *)camera;
4336         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
4337         int sock_fd;
4338         if (pc->cb_info == NULL) {
4339                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4340                 return CAMERA_ERROR_INVALID_PARAMETER;
4341         }
4342         sock_fd = pc->cb_info->fd;
4343         int get_min;
4344         int get_max;
4345
4346         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4347         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4348
4349         if (ret == CAMERA_ERROR_NONE) {
4350                 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
4351                 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
4352                 *min = get_min;
4353                 *max = get_max;
4354         }
4355         LOGD("ret : 0x%x", ret);
4356         return ret;
4357 }
4358
4359
4360 int camera_attr_get_whitebalance(camera_h camera,  camera_attr_whitebalance_e *wb)
4361 {
4362         if (camera == NULL || wb == NULL) {
4363                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4364                 return CAMERA_ERROR_INVALID_PARAMETER;
4365         }
4366         int ret = CAMERA_ERROR_NONE;
4367         camera_cli_s *pc = (camera_cli_s *)camera;
4368         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
4369         int sock_fd;
4370         if (pc->cb_info == NULL) {
4371                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4372                 return CAMERA_ERROR_INVALID_PARAMETER;
4373         }
4374         sock_fd = pc->cb_info->fd;
4375         int get_wb;
4376
4377         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4378         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4379
4380         if (ret == CAMERA_ERROR_NONE) {
4381                 muse_camera_msg_get(get_wb, pc->cb_info->recv_msg);
4382                 *wb = (camera_attr_whitebalance_e)get_wb;
4383         }
4384         LOGD("ret : 0x%x", ret);
4385         return ret;
4386 }
4387
4388
4389 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
4390 {
4391         if (camera == NULL || effect == NULL) {
4392                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4393                 return CAMERA_ERROR_INVALID_PARAMETER;
4394         }
4395
4396         int ret = CAMERA_ERROR_NONE;
4397         camera_cli_s *pc = (camera_cli_s *)camera;
4398         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
4399         int sock_fd;
4400         if (pc->cb_info == NULL) {
4401                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4402                 return CAMERA_ERROR_INVALID_PARAMETER;
4403         }
4404         sock_fd = pc->cb_info->fd;
4405         int get_effect;
4406
4407         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4408         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4409
4410         if (ret == CAMERA_ERROR_NONE) {
4411                 muse_camera_msg_get(get_effect, pc->cb_info->recv_msg);
4412                 *effect = (camera_attr_effect_mode_e)get_effect;
4413         }
4414         LOGD("ret : 0x%x", ret);
4415         return ret;
4416 }
4417
4418
4419 int camera_attr_get_scene_mode(camera_h camera,  camera_attr_scene_mode_e *mode)
4420 {
4421         if (camera == NULL || mode == NULL) {
4422                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4423                 return CAMERA_ERROR_INVALID_PARAMETER;
4424         }
4425
4426         int ret = CAMERA_ERROR_NONE;
4427         camera_cli_s *pc = (camera_cli_s *)camera;
4428         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
4429         int sock_fd;
4430         if (pc->cb_info == NULL) {
4431                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4432                 return CAMERA_ERROR_INVALID_PARAMETER;
4433         }
4434         sock_fd = pc->cb_info->fd;
4435         int get_mode;
4436
4437         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4438         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4439
4440         if (ret == CAMERA_ERROR_NONE) {
4441                 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
4442                 *mode = (camera_attr_scene_mode_e)get_mode;
4443         }
4444         LOGD("ret : 0x%x", ret);
4445         return ret;
4446 }
4447
4448
4449 int camera_attr_is_enabled_tag(camera_h camera,  bool *enable)
4450 {
4451         if (camera == NULL || enable == NULL) {
4452                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4453                 return CAMERA_ERROR_INVALID_PARAMETER;
4454         }
4455
4456         int ret = CAMERA_ERROR_NONE;
4457         camera_cli_s *pc = (camera_cli_s *)camera;
4458         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
4459         int sock_fd;
4460         if (pc->cb_info == NULL) {
4461                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4462                 return CAMERA_ERROR_INVALID_PARAMETER;
4463         }
4464         sock_fd = pc->cb_info->fd;
4465         int get_enabled;
4466
4467         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4468         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4469
4470         if (ret == CAMERA_ERROR_NONE) {
4471                 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
4472                 *enable = (bool)get_enabled;
4473         }
4474         LOGD("ret : 0x%x", ret);
4475         return ret;
4476 }
4477
4478
4479 int camera_attr_get_tag_image_description(camera_h camera,  char **description)
4480 {
4481         if (camera == NULL || description == NULL) {
4482                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4483                 return CAMERA_ERROR_INVALID_PARAMETER;
4484         }
4485
4486         int ret = CAMERA_ERROR_NONE;
4487         camera_cli_s *pc = (camera_cli_s *)camera;
4488         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
4489         int sock_fd;
4490         if (pc->cb_info == NULL) {
4491                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4492                 return CAMERA_ERROR_INVALID_PARAMETER;
4493         }
4494         sock_fd = pc->cb_info->fd;
4495         char get_description[MUSE_CAMERA_MSG_MAX_LENGTH] = {0,};
4496
4497         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4498         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4499
4500         if (ret == CAMERA_ERROR_NONE) {
4501                 muse_camera_msg_get_string(get_description, pc->cb_info->recv_msg);
4502                 *description = strdup(get_description);
4503         }
4504         LOGD("ret : 0x%x", ret);
4505         return ret;
4506 }
4507
4508
4509 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
4510 {
4511         if (camera == NULL || orientation == NULL) {
4512                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4513                 return CAMERA_ERROR_INVALID_PARAMETER;
4514         }
4515
4516         int ret = CAMERA_ERROR_NONE;
4517         camera_cli_s *pc = (camera_cli_s *)camera;
4518         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
4519         int sock_fd;
4520         if (pc->cb_info == NULL) {
4521                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4522                 return CAMERA_ERROR_INVALID_PARAMETER;
4523         }
4524         sock_fd = pc->cb_info->fd;
4525         int get_orientation;
4526
4527         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4528         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4529
4530         if (ret == CAMERA_ERROR_NONE) {
4531                 muse_camera_msg_get(get_orientation, pc->cb_info->recv_msg);
4532                 *orientation = (camera_attr_tag_orientation_e)get_orientation;
4533                 LOGD("success, orientation : %d", *orientation);
4534         }
4535         LOGD("ret : 0x%x", ret);
4536         return ret;
4537 }
4538
4539
4540 int camera_attr_get_tag_software(camera_h camera, char **software)
4541 {
4542         if (camera == NULL || software == NULL) {
4543                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4544                 return CAMERA_ERROR_INVALID_PARAMETER;
4545         }
4546
4547         int ret = CAMERA_ERROR_NONE;
4548         camera_cli_s *pc = (camera_cli_s *)camera;
4549         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
4550         int sock_fd;
4551         if (pc->cb_info == NULL) {
4552                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4553                 return CAMERA_ERROR_INVALID_PARAMETER;
4554         }
4555         sock_fd = pc->cb_info->fd;
4556         char get_software[MUSE_CAMERA_MSG_MAX_LENGTH] = {0,};
4557
4558         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4559         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4560
4561         if (ret == CAMERA_ERROR_NONE) {
4562                 muse_camera_msg_get_string(get_software, pc->cb_info->recv_msg);
4563                 *software = strdup(get_software);
4564         }
4565         LOGD("ret : 0x%x", ret);
4566         return ret;
4567 }
4568
4569
4570 int camera_attr_get_geotag(camera_h camera, double *latitude , double *longitude, double *altitude)
4571 {
4572         if (camera == NULL || latitude == NULL || longitude == NULL || altitude == NULL) {
4573                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4574                 return CAMERA_ERROR_INVALID_PARAMETER;
4575         }
4576
4577         int ret = CAMERA_ERROR_NONE;
4578         camera_cli_s *pc = (camera_cli_s *)camera;
4579         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
4580         double get_geotag[3] = {0,};
4581         int sock_fd;
4582         if (pc->cb_info == NULL) {
4583                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4584                 return CAMERA_ERROR_INVALID_PARAMETER;
4585         }
4586         sock_fd = pc->cb_info->fd;
4587         int valid = 0;
4588         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4589         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4590
4591         if (ret == CAMERA_ERROR_NONE) {
4592                 muse_camera_msg_get_array(get_geotag, pc->cb_info->recv_msg);
4593                 *latitude = get_geotag[0];
4594                 *longitude = get_geotag[1];
4595                 *altitude = get_geotag[2];
4596         } else {
4597                 LOGE("Returned value is not valid : 0x%x", valid);
4598         }
4599
4600         LOGD("ret : 0x%x", ret);
4601
4602         return ret;
4603 }
4604
4605
4606 int camera_attr_get_flash_mode(camera_h camera,  camera_attr_flash_mode_e *mode)
4607 {
4608         if (camera == NULL || mode == NULL) {
4609                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4610                 return CAMERA_ERROR_INVALID_PARAMETER;
4611         }
4612
4613         int ret = CAMERA_ERROR_NONE;
4614         camera_cli_s *pc = (camera_cli_s *)camera;
4615         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
4616         int sock_fd;
4617         if (pc->cb_info == NULL) {
4618                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4619                 return CAMERA_ERROR_INVALID_PARAMETER;
4620         }
4621         sock_fd = pc->cb_info->fd;
4622         int get_mode;
4623
4624         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4625         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4626
4627         if (ret == CAMERA_ERROR_NONE) {
4628                 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
4629                 *mode = (camera_attr_flash_mode_e)get_mode;
4630         }
4631         LOGD("ret : 0x%x", ret);
4632         return ret;
4633 }
4634
4635
4636 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
4637 {
4638         if (camera == NULL || foreach_cb == NULL) {
4639                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4640                 return CAMERA_ERROR_INVALID_PARAMETER;
4641         }
4642         int ret = CAMERA_ERROR_NONE;
4643
4644         camera_cli_s *pc = (camera_cli_s *)camera;
4645         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
4646
4647         LOGD("Enter, handle :%x", pc->remote_handle);
4648
4649         int sock_fd;
4650         if (pc->cb_info == NULL) {
4651                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4652                 return CAMERA_ERROR_INVALID_PARAMETER;
4653         }
4654         sock_fd = pc->cb_info->fd;
4655         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
4656         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
4657
4658         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4659         LOGD("ret : 0x%x", ret);
4660         return ret;
4661 }
4662
4663
4664 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb , void *user_data)
4665 {
4666         if (camera == NULL || foreach_cb == NULL) {
4667                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4668                 return CAMERA_ERROR_INVALID_PARAMETER;
4669         }
4670         int ret = CAMERA_ERROR_NONE;
4671
4672         camera_cli_s *pc = (camera_cli_s *)camera;
4673         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
4674
4675         LOGD("Enter, handle :%x", pc->remote_handle);
4676
4677         int sock_fd;
4678         if (pc->cb_info == NULL) {
4679                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4680                 return CAMERA_ERROR_INVALID_PARAMETER;
4681         }
4682         sock_fd = pc->cb_info->fd;
4683         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
4684         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
4685
4686         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4687         LOGD("ret : 0x%x", ret);
4688         return ret;
4689 }
4690
4691
4692 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
4693 {
4694         if (camera == NULL || foreach_cb == NULL) {
4695                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4696                 return CAMERA_ERROR_INVALID_PARAMETER;
4697         }
4698         int ret = CAMERA_ERROR_NONE;
4699
4700         camera_cli_s *pc = (camera_cli_s *)camera;
4701         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
4702
4703         LOGD("Enter, handle :%x", pc->remote_handle);
4704
4705         int sock_fd;
4706         if (pc->cb_info == NULL) {
4707                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4708                 return CAMERA_ERROR_INVALID_PARAMETER;
4709         }
4710         sock_fd = pc->cb_info->fd;
4711         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
4712         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
4713
4714         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4715         LOGD("ret : 0x%x", ret);
4716         return ret;
4717 }
4718
4719
4720 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb , void *user_data)
4721 {
4722         if (camera == NULL || foreach_cb == NULL) {
4723                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4724                 return CAMERA_ERROR_INVALID_PARAMETER;
4725         }
4726         int ret = CAMERA_ERROR_NONE;
4727
4728         camera_cli_s *pc = (camera_cli_s *)camera;
4729         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
4730
4731         LOGD("Enter, handle :%x", pc->remote_handle);
4732
4733         int sock_fd;
4734         if (pc->cb_info == NULL) {
4735                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4736                 return CAMERA_ERROR_INVALID_PARAMETER;
4737         }
4738         sock_fd = pc->cb_info->fd;
4739         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
4740         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
4741
4742         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4743         LOGD("ret : 0x%x", ret);
4744         return ret;
4745 }
4746
4747
4748 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb , void *user_data)
4749 {
4750         if (camera == NULL || foreach_cb == NULL) {
4751                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4752                 return CAMERA_ERROR_INVALID_PARAMETER;
4753         }
4754         int ret = CAMERA_ERROR_NONE;
4755
4756         camera_cli_s *pc = (camera_cli_s *)camera;
4757         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
4758
4759         LOGD("Enter, handle :%x", pc->remote_handle);
4760
4761         int sock_fd;
4762         if (pc->cb_info == NULL) {
4763                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4764                 return CAMERA_ERROR_INVALID_PARAMETER;
4765         }
4766         sock_fd = pc->cb_info->fd;
4767         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
4768         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
4769
4770         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4771         LOGD("ret : 0x%x", ret);
4772         return ret;
4773 }
4774
4775
4776 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb , void *user_data)
4777 {
4778         if (camera == NULL || foreach_cb == NULL) {
4779                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4780                 return CAMERA_ERROR_INVALID_PARAMETER;
4781         }
4782         int ret = CAMERA_ERROR_NONE;
4783
4784         camera_cli_s *pc = (camera_cli_s *)camera;
4785         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
4786
4787         LOGD("Enter, handle :%x", pc->remote_handle);
4788
4789         int sock_fd;
4790         if (pc->cb_info == NULL) {
4791                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4792                 return CAMERA_ERROR_INVALID_PARAMETER;
4793         }
4794         sock_fd = pc->cb_info->fd;
4795         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
4796         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
4797
4798         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4799         LOGD("ret : 0x%x", ret);
4800         return ret;
4801 }
4802
4803
4804 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb , void *user_data)
4805 {
4806         if (camera == NULL || foreach_cb == NULL) {
4807                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4808                 return CAMERA_ERROR_INVALID_PARAMETER;
4809         }
4810         int ret = CAMERA_ERROR_NONE;
4811
4812         camera_cli_s *pc = (camera_cli_s *)camera;
4813         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
4814
4815         LOGD("Enter, handle :%x", pc->remote_handle);
4816
4817         int sock_fd;
4818         if (pc->cb_info == NULL) {
4819                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4820                 return CAMERA_ERROR_INVALID_PARAMETER;
4821         }
4822         sock_fd = pc->cb_info->fd;
4823         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
4824         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
4825
4826         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4827         LOGD("ret : 0x%x", ret);
4828         return ret;
4829 }
4830
4831
4832 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb , void *user_data)
4833 {
4834         if (camera == NULL || foreach_cb == NULL) {
4835                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4836                 return CAMERA_ERROR_INVALID_PARAMETER;
4837         }
4838         int ret = CAMERA_ERROR_NONE;
4839
4840         camera_cli_s *pc = (camera_cli_s *)camera;
4841         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
4842         int sock_fd;
4843         if (pc->cb_info == NULL) {
4844                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4845                 return CAMERA_ERROR_INVALID_PARAMETER;
4846         }
4847         sock_fd = pc->cb_info->fd;
4848         LOGD("Enter, handle :%x", pc->remote_handle);
4849         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
4850         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
4851
4852         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4853         LOGD("Enter, handle :%x", pc->remote_handle);
4854         return ret;
4855 }
4856
4857 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)
4858 {
4859         if (camera == NULL || foreach_cb == NULL) {
4860                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4861                 return CAMERA_ERROR_INVALID_PARAMETER;
4862         }
4863         int ret = CAMERA_ERROR_NONE;
4864
4865         camera_cli_s *pc = (camera_cli_s *)camera;
4866         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
4867         int sock_fd;
4868         if (pc->cb_info == NULL) {
4869                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4870                 return CAMERA_ERROR_INVALID_PARAMETER;
4871         }
4872         sock_fd = pc->cb_info->fd;
4873         LOGD("Enter, handle :%x", pc->remote_handle);
4874         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
4875         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
4876
4877         muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, width, INT, height);
4878         LOGD("ret : 0x%x", ret);
4879         return ret;
4880 }
4881
4882 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
4883 {
4884         if (camera == NULL || foreach_cb == NULL) {
4885                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4886                 return CAMERA_ERROR_INVALID_PARAMETER;
4887         }
4888         int ret = CAMERA_ERROR_NONE;
4889
4890         camera_cli_s *pc = (camera_cli_s *)camera;
4891         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
4892         int sock_fd;
4893         if (pc->cb_info == NULL) {
4894                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4895                 return CAMERA_ERROR_INVALID_PARAMETER;
4896         }
4897         sock_fd = pc->cb_info->fd;
4898         LOGD("Enter, handle :%x", pc->remote_handle);
4899         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
4900         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
4901
4902         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4903         LOGD("ret : 0x%x", ret);
4904         return ret;
4905 }
4906
4907
4908 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
4909 {
4910         if (camera == NULL || foreach_cb == NULL) {
4911                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4912                 return CAMERA_ERROR_INVALID_PARAMETER;
4913         }
4914         int ret = CAMERA_ERROR_NONE;
4915
4916         camera_cli_s *pc = (camera_cli_s *)camera;
4917         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
4918         int sock_fd;
4919         if (pc->cb_info == NULL) {
4920                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4921                 return CAMERA_ERROR_INVALID_PARAMETER;
4922         }
4923         sock_fd = pc->cb_info->fd;
4924         LOGD("Enter, handle :%x", pc->remote_handle);
4925         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
4926         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
4927
4928         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4929         LOGD("ret : 0x%x", ret);
4930         return ret;
4931 }
4932
4933
4934 int camera_attr_set_stream_rotation(camera_h camera , camera_rotation_e rotation)
4935 {
4936         if (camera == NULL) {
4937                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4938                 return CAMERA_ERROR_INVALID_PARAMETER;
4939         }
4940
4941         int ret = CAMERA_ERROR_NONE;
4942         camera_cli_s *pc = (camera_cli_s *)camera;
4943         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
4944         int sock_fd;
4945         if (pc->cb_info == NULL) {
4946                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4947                 return CAMERA_ERROR_INVALID_PARAMETER;
4948         }
4949         sock_fd = pc->cb_info->fd;
4950         int set_rotation = (int)rotation;
4951
4952         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4953         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_rotation);
4954         LOGD("ret : 0x%x", ret);
4955         return ret;
4956 }
4957
4958
4959 int camera_attr_get_stream_rotation(camera_h camera , camera_rotation_e *rotation)
4960 {
4961         if (camera == NULL || rotation == NULL) {
4962                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4963                 return CAMERA_ERROR_INVALID_PARAMETER;
4964         }
4965
4966         int ret = CAMERA_ERROR_NONE;
4967         camera_cli_s *pc = (camera_cli_s *)camera;
4968         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
4969         int sock_fd;
4970         if (pc->cb_info == NULL) {
4971                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4972                 return CAMERA_ERROR_INVALID_PARAMETER;
4973         }
4974         sock_fd = pc->cb_info->fd;
4975         int get_rotation;
4976
4977         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4978         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4979
4980         if (ret == CAMERA_ERROR_NONE) {
4981                 muse_camera_msg_get(get_rotation, pc->cb_info->recv_msg);
4982                 *rotation = (camera_rotation_e)get_rotation;
4983         }
4984         LOGD("ret : 0x%x", ret);
4985         return ret;
4986 }
4987
4988
4989 int camera_attr_set_stream_flip(camera_h camera , camera_flip_e flip)
4990 {
4991         if (camera == NULL) {
4992                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4993                 return CAMERA_ERROR_INVALID_PARAMETER;
4994         }
4995
4996         int ret = CAMERA_ERROR_NONE;
4997         camera_cli_s *pc = (camera_cli_s *)camera;
4998         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
4999         int sock_fd;
5000         if (pc->cb_info == NULL) {
5001                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5002                 return CAMERA_ERROR_INVALID_PARAMETER;
5003         }
5004         sock_fd = pc->cb_info->fd;
5005         int set_flip = (int)flip;
5006
5007         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5008         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_flip);
5009         LOGD("ret : 0x%x", ret);
5010         return ret;
5011 }
5012
5013
5014 int camera_attr_get_stream_flip(camera_h camera , camera_flip_e *flip)
5015 {
5016         if (camera == NULL || flip == NULL) {
5017                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5018                 return CAMERA_ERROR_INVALID_PARAMETER;
5019         }
5020
5021         int ret = CAMERA_ERROR_NONE;
5022         camera_cli_s *pc = (camera_cli_s *)camera;
5023         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5024         int sock_fd;
5025         if (pc->cb_info == NULL) {
5026                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5027                 return CAMERA_ERROR_INVALID_PARAMETER;
5028         }
5029         sock_fd = pc->cb_info->fd;
5030         int get_flip;
5031
5032         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5033         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5034
5035         if (ret == CAMERA_ERROR_NONE) {
5036                 muse_camera_msg_get(get_flip, pc->cb_info->recv_msg);
5037                 *flip = (camera_flip_e)get_flip;
5038         }
5039         LOGD("ret : 0x%x", ret);
5040         return ret;
5041 }
5042
5043 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5044 {
5045         if (camera == NULL) {
5046                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5047                 return CAMERA_ERROR_INVALID_PARAMETER;
5048         }
5049
5050         int ret = CAMERA_ERROR_NONE;
5051         camera_cli_s *pc = (camera_cli_s *)camera;
5052         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5053         int sock_fd;
5054         if (pc->cb_info == NULL) {
5055                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5056                 return CAMERA_ERROR_INVALID_PARAMETER;
5057         }
5058         sock_fd = pc->cb_info->fd;
5059         int set_mode = (int)mode;
5060
5061         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5062         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
5063         LOGD("ret : 0x%x", ret);
5064         return ret;
5065 }
5066
5067
5068 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5069 {
5070         if (camera == NULL) {
5071                 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
5072                 return CAMERA_ERROR_INVALID_PARAMETER;
5073         }
5074         if (mode == NULL) {
5075                 LOGE("CAMERA_ERROR_NOT_SUPPORTED(0x%08x) - mode", CAMERA_ERROR_NOT_SUPPORTED);
5076                 return CAMERA_ERROR_NOT_SUPPORTED;
5077         }
5078         int ret = CAMERA_ERROR_NONE;
5079         camera_cli_s *pc = (camera_cli_s *)camera;
5080         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5081         int sock_fd;
5082         if (pc->cb_info == NULL) {
5083                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5084                 return CAMERA_ERROR_INVALID_PARAMETER;
5085         }
5086         sock_fd = pc->cb_info->fd;
5087         int get_mode;
5088
5089         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5090         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5091
5092         if (ret == CAMERA_ERROR_NONE) {
5093                 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
5094                 *mode = (camera_attr_hdr_mode_e)get_mode;
5095         }
5096         LOGD("ret : 0x%x", ret);
5097         return ret;
5098 }
5099
5100
5101 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5102 {
5103         if (camera == NULL) {
5104                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5105                 return false;
5106         }
5107
5108         int ret = CAMERA_ERROR_NONE;
5109         camera_cli_s *pc = (camera_cli_s *)camera;
5110         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
5111         int sock_fd;
5112         if (pc->cb_info == NULL) {
5113                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5114                 return CAMERA_ERROR_INVALID_PARAMETER;
5115         }
5116         sock_fd = pc->cb_info->fd;
5117         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5118         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5119         LOGD("ret : 0x%x", ret);
5120         return (bool)ret;
5121 }
5122
5123
5124 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void* user_data)
5125 {
5126         if (camera == NULL) {
5127                 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
5128                 return CAMERA_ERROR_INVALID_PARAMETER;
5129         }
5130         if (callback == NULL) {
5131                 LOGE("CAMERA_ERROR_NOT_SUPPORTED(0x%08x) - callback", CAMERA_ERROR_NOT_SUPPORTED);
5132                 return CAMERA_ERROR_NOT_SUPPORTED;
5133         }
5134         int ret = CAMERA_ERROR_NONE;
5135
5136         camera_cli_s *pc = (camera_cli_s *)camera;
5137         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5138         int sock_fd;
5139         if (pc->cb_info == NULL) {
5140                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5141                 return CAMERA_ERROR_INVALID_PARAMETER;
5142         }
5143         sock_fd = pc->cb_info->fd;
5144         LOGD("Enter, handle :%x", pc->remote_handle);
5145
5146         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5147         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5148
5149         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5150         LOGD("ret : 0x%x", ret);
5151         return ret;
5152 }
5153
5154
5155 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5156 {
5157         if (camera == NULL) {
5158                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5159                 return CAMERA_ERROR_INVALID_PARAMETER;
5160         }
5161
5162         int ret = CAMERA_ERROR_NONE;
5163
5164         camera_cli_s *pc = (camera_cli_s *)camera;
5165         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5166         int sock_fd;
5167         if (pc->cb_info == NULL) {
5168                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5169                 return CAMERA_ERROR_INVALID_PARAMETER;
5170         }
5171         sock_fd = pc->cb_info->fd;
5172         LOGD("Enter, handle :%x", pc->remote_handle);
5173
5174         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)NULL;
5175         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)NULL;
5176
5177         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5178         LOGD("ret : 0x%x", ret);
5179         return ret;
5180 }
5181
5182
5183 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
5184 {
5185         if (camera == NULL) {
5186                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5187                 return CAMERA_ERROR_INVALID_PARAMETER;
5188         }
5189
5190         int ret = CAMERA_ERROR_NONE;
5191         camera_cli_s *pc = (camera_cli_s *)camera;
5192         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
5193         int sock_fd;
5194         if (pc->cb_info == NULL) {
5195                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5196                 return CAMERA_ERROR_INVALID_PARAMETER;
5197         }
5198         sock_fd = pc->cb_info->fd;
5199         int set_enable = (int)enable;
5200
5201         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5202         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable);
5203         LOGD("ret : 0x%x", ret);
5204         return ret;
5205 }
5206
5207
5208 int camera_attr_is_enabled_anti_shake(camera_h camera , bool *enabled)
5209 {
5210         if (camera == NULL) {
5211                 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
5212                 return CAMERA_ERROR_INVALID_PARAMETER;
5213         }
5214         if (enabled == NULL) {
5215                 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
5216                 return CAMERA_ERROR_NOT_SUPPORTED;
5217         }
5218         int ret = CAMERA_ERROR_NONE;
5219         camera_cli_s *pc = (camera_cli_s *)camera;
5220         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
5221         int sock_fd;
5222         if (pc->cb_info == NULL) {
5223                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5224                 return CAMERA_ERROR_INVALID_PARAMETER;
5225         }
5226         sock_fd = pc->cb_info->fd;
5227         int get_enabled;
5228
5229         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5230         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5231
5232         if (ret == CAMERA_ERROR_NONE) {
5233                 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
5234                 *enabled = (bool)get_enabled;
5235         }
5236         LOGD("ret : 0x%x", ret);
5237         return ret;
5238 }
5239
5240
5241 bool camera_attr_is_supported_anti_shake(camera_h camera)
5242 {
5243
5244         if (camera == NULL) {
5245                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5246                 return false;
5247         }
5248
5249         int ret = CAMERA_ERROR_NONE;
5250         camera_cli_s *pc = (camera_cli_s *)camera;
5251         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
5252         int sock_fd;
5253         if (pc->cb_info == NULL) {
5254                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5255                 return CAMERA_ERROR_INVALID_PARAMETER;
5256         }
5257         sock_fd = pc->cb_info->fd;
5258         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5259         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5260         LOGD("ret : 0x%x", ret);
5261         return ret;
5262 }
5263
5264
5265 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
5266 {
5267         if (camera == NULL) {
5268                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5269                 return CAMERA_ERROR_INVALID_PARAMETER;
5270         }
5271
5272         int ret = CAMERA_ERROR_NONE;
5273         camera_cli_s *pc = (camera_cli_s *)camera;
5274         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
5275         int sock_fd;
5276         if (pc->cb_info == NULL) {
5277                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5278                 return CAMERA_ERROR_INVALID_PARAMETER;
5279         }
5280         sock_fd = pc->cb_info->fd;
5281         int set_enable = (int)enable;
5282
5283         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5284         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable);
5285         LOGD("ret : 0x%x", ret);
5286         return ret;
5287 }
5288
5289
5290 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
5291 {
5292         if (camera == NULL) {
5293                 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
5294                 return CAMERA_ERROR_INVALID_PARAMETER;
5295         }
5296         if (enabled == NULL) {
5297                 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
5298                 return CAMERA_ERROR_NOT_SUPPORTED;
5299         }
5300         int ret = CAMERA_ERROR_NONE;
5301         camera_cli_s *pc = (camera_cli_s *)camera;
5302         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
5303         int sock_fd;
5304         if (pc->cb_info == NULL) {
5305                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5306                 return CAMERA_ERROR_INVALID_PARAMETER;
5307         }
5308         sock_fd = pc->cb_info->fd;
5309         int get_enabled;
5310
5311         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5312         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5313
5314         if (ret == CAMERA_ERROR_NONE) {
5315                 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
5316                 *enabled = (bool)get_enabled;
5317         }
5318         LOGD("ret : 0x%x", ret);
5319         return ret;
5320 }
5321
5322
5323 bool camera_attr_is_supported_video_stabilization(camera_h camera)
5324 {
5325         if (camera == NULL) {
5326                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5327                 return false;
5328         }
5329
5330         int ret = CAMERA_ERROR_NONE;
5331         camera_cli_s *pc = (camera_cli_s *)camera;
5332         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
5333         int sock_fd;
5334         if (pc->cb_info == NULL) {
5335                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5336                 return CAMERA_ERROR_INVALID_PARAMETER;
5337         }
5338         sock_fd = pc->cb_info->fd;
5339         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5340         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5341         LOGD("ret : 0x%x", ret);
5342         return ret;
5343 }
5344
5345
5346 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
5347 {
5348         if (camera == NULL) {
5349                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5350                 return CAMERA_ERROR_INVALID_PARAMETER;
5351         }
5352
5353         int ret = CAMERA_ERROR_NONE;
5354         camera_cli_s *pc = (camera_cli_s *)camera;
5355         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
5356         int sock_fd;
5357         if (pc->cb_info == NULL) {
5358                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5359                 return CAMERA_ERROR_INVALID_PARAMETER;
5360         }
5361         sock_fd = pc->cb_info->fd;
5362         int set_enable = (int)enable;
5363
5364         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5365         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable);
5366         LOGD("ret : 0x%x", ret);
5367         return ret;
5368 }
5369
5370
5371 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
5372 {
5373         if (camera == NULL) {
5374                 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
5375                 return CAMERA_ERROR_INVALID_PARAMETER;
5376         }
5377         if (enabled == NULL) {
5378                 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
5379                 return CAMERA_ERROR_INVALID_PARAMETER;
5380         }
5381         int ret = CAMERA_ERROR_NONE;
5382         camera_cli_s *pc = (camera_cli_s *)camera;
5383         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
5384         int sock_fd;
5385         if (pc->cb_info == NULL) {
5386                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5387                 return CAMERA_ERROR_INVALID_PARAMETER;
5388         }
5389         sock_fd = pc->cb_info->fd;
5390         int get_enabled;
5391
5392         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5393         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5394
5395         if (ret == CAMERA_ERROR_NONE) {
5396                 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
5397                 *enabled = (bool)get_enabled;
5398         }
5399         LOGD("ret : 0x%x", ret);
5400         return ret;
5401 }
5402
5403
5404 bool camera_attr_is_supported_auto_contrast(camera_h camera)
5405 {
5406         if (camera == NULL) {
5407                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5408                 return false;
5409         }
5410
5411         int ret = CAMERA_ERROR_NONE;
5412         camera_cli_s *pc = (camera_cli_s *)camera;
5413         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
5414         int sock_fd;
5415         if (pc->cb_info == NULL) {
5416                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5417                 return CAMERA_ERROR_INVALID_PARAMETER;
5418         }
5419         sock_fd = pc->cb_info->fd;
5420         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5421         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5422         LOGD("ret : 0x%x", ret);
5423         return ret;
5424 }
5425
5426
5427 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
5428 {
5429         if (camera == NULL) {
5430                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5431                 return CAMERA_ERROR_INVALID_PARAMETER;
5432         }
5433
5434         int ret = CAMERA_ERROR_NONE;
5435         camera_cli_s *pc = (camera_cli_s *)camera;
5436         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
5437         int sock_fd;
5438         if (pc->cb_info == NULL) {
5439                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5440                 return CAMERA_ERROR_INVALID_PARAMETER;
5441         }
5442         sock_fd = pc->cb_info->fd;
5443         int set_disable = (int)disable;
5444
5445         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5446         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_disable);
5447         LOGD("ret : 0x%x", ret);
5448         return ret;
5449 }