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