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