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