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