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