[Release version 0.2.58] Add featuring for evas renderer
[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                                 LOGD("check api_class");
1754                                 if (muse_camera_msg_get(api_class, parse_str[i]))
1755                                         LOGD("camera api_class[%d]", api_class);
1756                         }
1757
1758                         if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1759                                 g_mutex_lock(&cb_info->api_mutex[api]);
1760
1761                                 if (!muse_camera_msg_get(ret, parse_str[i])) {
1762                                         LOGE("failed to get camera ret");
1763                                         g_mutex_unlock(&cb_info->api_mutex[api]);
1764                                         continue;
1765                                 }
1766
1767                                 cb_info->api_ret[api] = ret;
1768                                 cb_info->api_activating[api] = 1;
1769
1770                                 if (api == MUSE_CAMERA_API_CREATE) {
1771                                         if (ret != CAMERA_ERROR_NONE) {
1772                                                 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1773                                                 LOGE("camera create error 0x%x. close client cb handler", ret);
1774                                         }
1775                                 } else if (api == MUSE_CAMERA_API_DESTROY) {
1776                                         if (ret == CAMERA_ERROR_NONE) {
1777                                                 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1778                                                 LOGD("camera destroy done. close client cb handler");
1779                                         }
1780                                 }
1781
1782                                 g_cond_signal(&cb_info->api_cond[api]);
1783                                 g_mutex_unlock(&cb_info->api_mutex[api]);
1784                         } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
1785                                 camera_message_s *cam_msg = g_new0(camera_message_s, 1);
1786                                 if (cam_msg == NULL) {
1787                                         LOGE("failed to alloc cam_msg");
1788                                         continue;
1789                                 }
1790
1791                                 cam_msg->api = api;
1792                                 memcpy(cam_msg->recv_msg, parse_str[i], sizeof(cam_msg->recv_msg));
1793
1794                                 LOGD("add camera message to queue : api %d", api);
1795
1796                                 g_mutex_lock(&cb_info->msg_handler_mutex);
1797                                 g_queue_push_tail(cb_info->msg_queue, (gpointer)cam_msg);
1798                                 g_cond_signal(&cb_info->msg_handler_cond);
1799                                 g_mutex_unlock(&cb_info->msg_handler_mutex);
1800                         } else {
1801                                 LOGW("unknown camera api %d and api_class %d", api, api_class);
1802                         }
1803                 }
1804
1805         }
1806
1807         LOGD("client cb exit");
1808
1809 CB_HANDLER_EXIT:
1810         if (parse_str) {
1811                 for (i = 0 ; i < CAMERA_PARSE_STRING_SIZE ; i++) {
1812                         if (parse_str[i]) {
1813                                 free(parse_str[i]);
1814                                 parse_str[i] = NULL;
1815                         }
1816                 }
1817
1818                 free(parse_str);
1819                 parse_str = NULL;
1820         }
1821
1822         return NULL;
1823 }
1824
1825 static camera_cb_info_s *_client_callback_new(gint sockfd)
1826 {
1827         camera_cb_info_s *cb_info = NULL;
1828         gint *tmp_activating = NULL;
1829         gint *tmp_ret = NULL;
1830         gint i = 0;
1831
1832         g_return_val_if_fail(sockfd > 0, NULL);
1833
1834         cb_info = g_new0(camera_cb_info_s, 1);
1835         if (cb_info == NULL) {
1836                 LOGE("cb_info failed");
1837                 goto ErrorExit;
1838         }
1839
1840         g_mutex_init(&cb_info->msg_handler_mutex);
1841         g_cond_init(&cb_info->msg_handler_cond);
1842         g_mutex_init(&cb_info->idle_event_mutex);
1843         g_cond_init(&cb_info->idle_event_cond);
1844         g_mutex_init(&cb_info->mp_data_mutex);
1845 #ifdef EVAS_RENDERER_SUPPORT
1846         g_mutex_init(&cb_info->evas_mutex);
1847 #endif /* EVAS_RENDERER_SUPPORT */
1848
1849         for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
1850                 g_mutex_init(&cb_info->api_mutex[i]);
1851                 g_cond_init(&cb_info->api_cond[i]);
1852         }
1853
1854         tmp_activating = g_new0(gint, MUSE_CAMERA_API_MAX);
1855         if (tmp_activating == NULL) {
1856                 LOGE("tmp_activating failed");
1857                 goto ErrorExit;
1858         }
1859
1860         tmp_ret = g_new0(gint, MUSE_CAMERA_API_MAX);
1861         if (tmp_ret == NULL) {
1862                 LOGE("tmp_ret failed");
1863                 goto ErrorExit;
1864         }
1865
1866         cb_info->msg_queue = g_queue_new();
1867         if (cb_info->msg_queue == NULL) {
1868                 LOGE("msg_queue new failed");
1869                 goto ErrorExit;
1870         }
1871
1872         g_atomic_int_set(&cb_info->msg_handler_running, 1);
1873         cb_info->msg_handler_thread = g_thread_try_new("camera_msg_handler",
1874                 _camera_msg_handler_func, (gpointer)cb_info, NULL);
1875         if (cb_info->msg_handler_thread == NULL) {
1876                 LOGE("message handler thread creation failed");
1877                 goto ErrorExit;
1878         }
1879
1880         cb_info->fd = sockfd;
1881         cb_info->api_activating = tmp_activating;
1882         cb_info->api_ret = tmp_ret;
1883         cb_info->preview_cb_flag = 0;
1884 #ifdef EVAS_RENDERER_SUPPORT
1885         cb_info->evas_info = NULL;
1886 #endif /* EVAS_RENDERER_SUPPORT */
1887
1888         g_atomic_int_set(&cb_info->msg_recv_running, 1);
1889         cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
1890                 _camera_msg_recv_func, (gpointer)cb_info, NULL);
1891         if (cb_info->msg_recv_thread == NULL) {
1892                 LOGE("message receive thread creation failed");
1893                 goto ErrorExit;
1894         }
1895
1896         return cb_info;
1897
1898 ErrorExit:
1899         if (cb_info) {
1900                 if (cb_info->msg_handler_thread) {
1901                         g_mutex_lock(&cb_info->msg_handler_mutex);
1902                         g_atomic_int_set(&cb_info->msg_handler_running, 0);
1903                         g_cond_signal(&cb_info->msg_handler_cond);
1904                         g_mutex_unlock(&cb_info->msg_handler_mutex);
1905
1906                         g_thread_join(cb_info->msg_handler_thread);
1907                         g_thread_unref(cb_info->msg_handler_thread);
1908                         cb_info->msg_handler_thread = NULL;
1909                 }
1910
1911                 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
1912                         g_mutex_clear(&cb_info->api_mutex[i]);
1913                         g_cond_clear(&cb_info->api_cond[i]);
1914                 }
1915
1916                 g_mutex_clear(&cb_info->msg_handler_mutex);
1917                 g_cond_clear(&cb_info->msg_handler_cond);
1918                 g_mutex_clear(&cb_info->idle_event_mutex);
1919                 g_cond_clear(&cb_info->idle_event_cond);
1920                 g_mutex_clear(&cb_info->mp_data_mutex);
1921 #ifdef EVAS_RENDERER_SUPPORT
1922                 g_mutex_clear(&cb_info->evas_mutex);
1923 #endif /* EVAS_RENDERER_SUPPORT */
1924
1925                 if (cb_info->msg_queue) {
1926                         g_queue_free(cb_info->msg_queue);
1927                         cb_info->msg_queue = NULL;
1928                 }
1929
1930                 g_free(cb_info);
1931                 cb_info = NULL;
1932         }
1933
1934         if (tmp_activating) {
1935                 g_free(tmp_activating);
1936                 tmp_activating = NULL;
1937         }
1938         if (tmp_ret) {
1939                 g_free(tmp_ret);
1940                 tmp_ret = NULL;
1941         }
1942
1943         return NULL;
1944 }
1945
1946 static void _client_callback_destroy(camera_cb_info_s *cb_info)
1947 {
1948         gint i = 0;
1949
1950         g_return_if_fail(cb_info != NULL);
1951
1952         LOGD("MSG receive thread[%p] destroy", cb_info->msg_recv_thread);
1953
1954         g_thread_join(cb_info->msg_recv_thread);
1955         g_thread_unref(cb_info->msg_recv_thread);
1956         cb_info->msg_recv_thread = NULL;
1957
1958         LOGD("msg thread removed");
1959
1960         g_mutex_lock(&cb_info->msg_handler_mutex);
1961         g_atomic_int_set(&cb_info->msg_handler_running, 0);
1962         g_cond_signal(&cb_info->msg_handler_cond);
1963         g_mutex_unlock(&cb_info->msg_handler_mutex);
1964
1965         g_thread_join(cb_info->msg_handler_thread);
1966         g_thread_unref(cb_info->msg_handler_thread);
1967         cb_info->msg_handler_thread = NULL;
1968
1969         g_queue_free(cb_info->msg_queue);
1970         cb_info->msg_queue = NULL;
1971
1972         for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
1973                 g_mutex_clear(&cb_info->api_mutex[i]);
1974                 g_cond_clear(&cb_info->api_cond[i]);
1975         }
1976
1977         g_mutex_clear(&cb_info->msg_handler_mutex);
1978         g_cond_clear(&cb_info->msg_handler_cond);
1979         g_mutex_clear(&cb_info->idle_event_mutex);
1980         g_cond_clear(&cb_info->idle_event_cond);
1981         g_mutex_clear(&cb_info->mp_data_mutex);
1982 #ifdef EVAS_RENDERER_SUPPORT
1983         g_mutex_clear(&cb_info->evas_mutex);
1984 #endif /* EVAS_RENDERER_SUPPORT */
1985
1986         LOGD("event thread removed");
1987
1988         if (cb_info->fd > -1) {
1989                 muse_core_connection_close(cb_info->fd);
1990                 cb_info->fd = -1;
1991         }
1992
1993         if (cb_info->bufmgr) {
1994                 tbm_bufmgr_deinit(cb_info->bufmgr);
1995                 cb_info->bufmgr = NULL;
1996         }
1997         if (cb_info->api_activating) {
1998                 g_free(cb_info->api_activating);
1999                 cb_info->api_activating = NULL;
2000         }
2001         if (cb_info->api_ret) {
2002                 g_free(cb_info->api_ret);
2003                 cb_info->api_ret = NULL;
2004         }
2005         if (cb_info->pkt_fmt) {
2006                 media_format_unref(cb_info->pkt_fmt);
2007                 cb_info->pkt_fmt = NULL;
2008         }
2009
2010 #ifdef EVAS_RENDERER_SUPPORT
2011         if (cb_info->evas_info)
2012                 mm_evas_renderer_destroy(&cb_info->evas_info);
2013 #endif /* EVAS_RENDERER_SUPPORT */
2014
2015         cb_info->preview_cb_flag = 0;
2016
2017         g_free(cb_info);
2018         cb_info = NULL;
2019
2020         return;
2021 }
2022
2023
2024 int _camera_start_evas_rendering(camera_h camera)
2025 {
2026         int ret = CAMERA_ERROR_NONE;
2027         camera_cli_s *pc = (camera_cli_s *)camera;
2028
2029         if (camera == NULL) {
2030                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2031                 return CAMERA_ERROR_INVALID_PARAMETER;
2032         }
2033
2034         if (pc->cb_info == NULL) {
2035                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2036                 return CAMERA_ERROR_INVALID_PARAMETER;
2037         }
2038
2039         LOGD("start");
2040
2041         if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2042                 LOGE("EVAS surface is not set");
2043                 return CAMERA_ERROR_NONE;
2044         }
2045
2046 #ifdef EVAS_RENDERER_SUPPORT
2047         g_mutex_lock(&pc->cb_info->evas_mutex);
2048
2049         /* set evas render flag as RUN */
2050         pc->cb_info->run_evas_render = true;
2051         ret = CAMERA_ERROR_NONE;
2052
2053         g_mutex_unlock(&pc->cb_info->evas_mutex);
2054 #else /* EVAS_RENDERER_SUPPORT */
2055         LOGW("evas renderer is not supported");
2056         ret = CAMERA_ERROR_NOT_SUPPORTED;
2057 #endif /* EVAS_RENDERER_SUPPORT */
2058
2059         return ret;
2060 }
2061
2062
2063 int _camera_stop_evas_rendering(camera_h camera, bool keep_screen)
2064 {
2065         int ret = CAMERA_ERROR_NONE;
2066         camera_cli_s *pc = (camera_cli_s *)camera;
2067
2068         if (camera == NULL) {
2069                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2070                 return CAMERA_ERROR_INVALID_PARAMETER;
2071         }
2072
2073         if (pc->cb_info == NULL) {
2074                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2075                 return CAMERA_ERROR_INVALID_PARAMETER;
2076         }
2077
2078         LOGD("stop - keep screen %d", keep_screen);
2079
2080         if (!CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2081                 LOGE("EVAS surface is not set");
2082                 return CAMERA_ERROR_NONE;
2083         }
2084
2085 #ifdef EVAS_RENDERER_SUPPORT
2086         g_mutex_lock(&pc->cb_info->evas_mutex);
2087
2088         /* set evas render flag as STOP and release buffers */
2089         pc->cb_info->run_evas_render = false;
2090
2091         ret = mm_evas_renderer_retrieve_all_packets(pc->cb_info->evas_info, keep_screen);
2092         if (ret != MM_ERROR_NONE) {
2093                 LOGE("mm_evas_renderer_retrieve_all_packets failed 0x%x", ret);
2094                 ret = CAMERA_ERROR_INVALID_OPERATION;
2095         }
2096
2097         g_mutex_unlock(&pc->cb_info->evas_mutex);
2098 #else /* EVAS_RENDERER_SUPPORT */
2099         LOGW("evas renderer is not supported");
2100         ret = CAMERA_ERROR_NOT_SUPPORTED;
2101 #endif /* EVAS_RENDERER_SUPPORT */
2102
2103         return ret;
2104 }
2105
2106
2107 int camera_create(camera_device_e device, camera_h *camera)
2108 {
2109         int sock_fd = -1;
2110         char *sndMsg;
2111         int ret = CAMERA_ERROR_NONE;
2112         int pid = 0;
2113         camera_cli_s *pc = NULL;
2114         tbm_bufmgr bufmgr = NULL;
2115
2116         muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
2117         muse_core_api_module_e muse_module = MUSE_CAMERA;
2118         int device_type = (int)device;
2119
2120         if (camera == NULL) {
2121                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2122                 return CAMERA_ERROR_INVALID_PARAMETER;
2123         }
2124
2125         bufmgr = tbm_bufmgr_init(-1);
2126         if (bufmgr == NULL) {
2127                 LOGE("get tbm bufmgr failed");
2128                 return CAMERA_ERROR_INVALID_OPERATION;
2129         }
2130
2131         sock_fd = muse_core_client_new();
2132         if (sock_fd < 0) {
2133                 LOGE("muse_core_client_new failed - returned fd %d", sock_fd);
2134                 ret = CAMERA_ERROR_INVALID_OPERATION;
2135                 goto ErrorExit;
2136         }
2137
2138         pid = getpid();
2139
2140         sndMsg = muse_core_msg_json_factory_new(api,
2141                 MUSE_TYPE_INT, "module", muse_module,
2142                 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
2143                 MUSE_TYPE_INT, "pid", pid,
2144                 0);
2145
2146         muse_core_ipc_send_msg(sock_fd, sndMsg);
2147         muse_core_msg_json_factory_free(sndMsg);
2148
2149         pc = g_new0(camera_cli_s, 1);
2150         if (pc == NULL) {
2151                 LOGE("camera_cli_s alloc failed");
2152                 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2153                 goto ErrorExit;
2154         }
2155
2156         pc->cb_info = _client_callback_new(sock_fd);
2157         if (pc->cb_info == NULL) {
2158                 LOGE("cb_info alloc failed");
2159                 ret = CAMERA_ERROR_OUT_OF_MEMORY;
2160                 goto ErrorExit;
2161         }
2162
2163         LOGD("cb info : %d", pc->cb_info->fd);
2164
2165         ret = _client_wait_for_cb_return(api, pc->cb_info, CALLBACK_TIME_OUT);
2166         if (ret == CAMERA_ERROR_NONE) {
2167                 intptr_t handle = 0;
2168                 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
2169                 if (handle == 0) {
2170                         LOGE("Receiving Handle Failed!!");
2171                         ret = CAMERA_ERROR_INVALID_OPERATION;
2172                         goto ErrorExit;
2173                 }
2174
2175                 pc->remote_handle = handle;
2176                 pc->cb_info->bufmgr = bufmgr;
2177
2178                 ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL);
2179                 if (ret != CAMERA_ERROR_NONE) {
2180                         LOGE("init display failed 0x%x", ret);
2181                         goto ErrorExit;
2182                 }
2183
2184                 LOGD("camera create 0x%x", pc->remote_handle);
2185                 *camera = (camera_h)pc;
2186         } else {
2187                 goto ErrorExit;
2188         }
2189
2190         return ret;
2191
2192 ErrorExit:
2193         tbm_bufmgr_deinit(bufmgr);
2194         bufmgr = NULL;
2195
2196         if (pc) {
2197                 _client_callback_destroy(pc->cb_info);
2198                 pc->cb_info = NULL;
2199                 g_free(pc);
2200                 pc = NULL;
2201         }
2202
2203         LOGE("camera create error : 0x%x", ret);
2204
2205         return ret;
2206 }
2207
2208 int camera_destroy(camera_h camera)
2209 {
2210         if (camera == NULL) {
2211                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2212                 return CAMERA_ERROR_INVALID_PARAMETER;
2213         }
2214
2215         int ret = CAMERA_ERROR_NONE;
2216         muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
2217         camera_cli_s *pc = (camera_cli_s *)camera;
2218         int sock_fd = 0;
2219
2220         LOGD("ENTER");
2221
2222         if (pc->cb_info == NULL) {
2223                 LOGE("cb_info NULL, INVALID_PARAMETER");
2224                 return CAMERA_ERROR_INVALID_PARAMETER;
2225         }
2226
2227         sock_fd = pc->cb_info->fd;
2228
2229         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2230         if (ret == CAMERA_ERROR_NONE) {
2231                 _camera_remove_idle_event_all(pc->cb_info);
2232                 _client_callback_destroy(pc->cb_info);
2233                 pc->cb_info = NULL;
2234
2235                 g_free(pc);
2236                 pc = NULL;
2237         } else {
2238                 LOGE("camera destroy error : 0x%x", ret);
2239         }
2240
2241         return ret;
2242 }
2243
2244 int camera_start_preview(camera_h camera)
2245 {
2246         int ret = CAMERA_ERROR_NONE;
2247         muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
2248         camera_cli_s *pc = (camera_cli_s *)camera;
2249         int sock_fd = 0;
2250
2251         if (camera == NULL) {
2252                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2253                 return CAMERA_ERROR_INVALID_PARAMETER;
2254         }
2255
2256         if (pc->cb_info == NULL) {
2257                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2258                 return CAMERA_ERROR_INVALID_PARAMETER;
2259         }
2260
2261         LOGD("start");
2262
2263         sock_fd = pc->cb_info->fd;
2264
2265         muse_camera_msg_send_longtime(api, sock_fd, pc->cb_info, ret);
2266
2267         if (ret != CAMERA_ERROR_NONE) {
2268                 LOGE("start preview failed 0x%x", ret);
2269         } else if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2270                 ret = _camera_start_evas_rendering(camera);
2271         }
2272
2273         LOGD("ret : 0x%x", ret);
2274
2275         return ret;
2276 }
2277
2278 int camera_stop_preview(camera_h camera)
2279 {
2280         int ret = CAMERA_ERROR_NONE;
2281         int sock_fd = 0;
2282         camera_cli_s *pc = NULL;
2283         muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
2284
2285         if (camera == NULL) {
2286                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2287                 return CAMERA_ERROR_INVALID_PARAMETER;
2288         }
2289
2290         pc = (camera_cli_s *)camera;
2291
2292         if (pc->cb_info == NULL) {
2293                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2294                 return CAMERA_ERROR_INVALID_PARAMETER;
2295         }
2296
2297         sock_fd = pc->cb_info->fd;
2298
2299         LOGD("Enter");
2300
2301         if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2302                 camera_state_e current_state = CAMERA_STATE_NONE;
2303
2304                 ret = camera_get_state(camera, &current_state);
2305                 if (ret != CAMERA_ERROR_NONE) {
2306                         LOGE("failed to get current state 0x%x", ret);
2307                         return ret;
2308                 }
2309
2310                 if (current_state == CAMERA_STATE_PREVIEW) {
2311                         ret = _camera_stop_evas_rendering(camera, false);
2312                         if (ret != CAMERA_ERROR_NONE)
2313                                 return ret;
2314                 }
2315         }
2316
2317         /* send stop preview message */
2318         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2319
2320         LOGD("ret : 0x%x", ret);
2321
2322         return ret;
2323 }
2324
2325 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
2326 {
2327         if (camera == NULL) {
2328                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2329                 return CAMERA_ERROR_INVALID_PARAMETER;
2330         }
2331         int ret = CAMERA_ERROR_NONE;
2332
2333         camera_cli_s *pc = (camera_cli_s *)camera;
2334         muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
2335         int sock_fd;
2336         int is_capturing_cb = 0;
2337         int is_completed_cb = 0;
2338         LOGD("Enter, handle :%x", pc->remote_handle);
2339
2340         if (pc->cb_info == NULL) {
2341                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2342                 return CAMERA_ERROR_INVALID_PARAMETER;
2343         }
2344
2345         sock_fd = pc->cb_info->fd;
2346
2347         if (capturing_cb != NULL) {
2348                 is_capturing_cb = 1;
2349                 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2350                 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2351         }
2352
2353         if (completed_cb != NULL) {
2354                 is_completed_cb = 1;
2355                 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2356                 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2357         }
2358
2359         muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, is_capturing_cb, INT, is_completed_cb);
2360         LOGD("is_capturing_cb :%d, is_completed_cb : %d", is_capturing_cb, is_completed_cb);
2361         LOGD("ret : 0x%x", ret);
2362         return ret;
2363 }
2364
2365 bool camera_is_supported_continuous_capture(camera_h camera)
2366 {
2367         if (camera == NULL) {
2368                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2369                 return false;
2370         }
2371
2372         int ret = CAMERA_ERROR_NONE;
2373         camera_cli_s *pc = (camera_cli_s *)camera;
2374         muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2375         int sock_fd;
2376
2377         if (pc->cb_info == NULL) {
2378                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2379                 return CAMERA_ERROR_INVALID_PARAMETER;
2380         }
2381
2382         sock_fd = pc->cb_info->fd;
2383
2384         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2385         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2386         LOGD("ret : 0x%x", ret);
2387         return (bool)ret;
2388 }
2389
2390 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)
2391 {
2392         if (camera == NULL) {
2393                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2394                 return CAMERA_ERROR_INVALID_PARAMETER;
2395         }
2396
2397         int ret = CAMERA_ERROR_NONE;
2398
2399         camera_cli_s *pc = (camera_cli_s *)camera;
2400         muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2401
2402         LOGD("Enter, handle :%x", pc->remote_handle);
2403
2404         int sock_fd;
2405         if (pc->cb_info == NULL) {
2406                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2407                 return CAMERA_ERROR_INVALID_PARAMETER;
2408         }
2409         sock_fd = pc->cb_info->fd;
2410
2411         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2412         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2413         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2414
2415         muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, count, INT, interval);
2416
2417         LOGD("ret : 0x%x", ret);
2418
2419         return ret;
2420 }
2421
2422 int camera_stop_continuous_capture(camera_h camera)
2423 {
2424         if (camera == NULL) {
2425                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2426                 return CAMERA_ERROR_INVALID_PARAMETER;
2427         }
2428
2429
2430         int ret = CAMERA_ERROR_NONE;
2431
2432         camera_cli_s *pc = (camera_cli_s *)camera;
2433         muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2434         LOGD("Enter,  handle :%x", pc->remote_handle);
2435         int sock_fd;
2436         if (pc->cb_info == NULL) {
2437                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2438                 return CAMERA_ERROR_INVALID_PARAMETER;
2439         }
2440         sock_fd = pc->cb_info->fd;
2441         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2442         LOGD("ret : 0x%x", ret);
2443         return ret;
2444 }
2445
2446 bool camera_is_supported_face_detection(camera_h camera)
2447 {
2448         if (camera == NULL) {
2449                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2450                 return false;
2451         }
2452         int ret = CAMERA_ERROR_NONE;
2453
2454         camera_cli_s *pc = (camera_cli_s *)camera;
2455         muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2456         int sock_fd;
2457         if (pc->cb_info == NULL) {
2458                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2459                 return CAMERA_ERROR_INVALID_PARAMETER;
2460         }
2461         sock_fd = pc->cb_info->fd;
2462
2463         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2464         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2465         LOGD("ret : 0x%x", ret);
2466         return (bool)ret;
2467 }
2468
2469 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2470 {
2471         if (camera == NULL) {
2472                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2473                 return false;
2474         }
2475         int ret = CAMERA_ERROR_NONE;
2476
2477         camera_cli_s *pc = (camera_cli_s *)camera;
2478         muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2479         int sock_fd;
2480         if (pc->cb_info == NULL) {
2481                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2482                 return CAMERA_ERROR_INVALID_PARAMETER;
2483         }
2484         sock_fd = pc->cb_info->fd;
2485
2486         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2487         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2488         LOGD("ret : 0x%x", ret);
2489         return (bool)ret;
2490 }
2491
2492 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2493 {
2494         if (camera == NULL) {
2495                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2496                 return false;
2497         }
2498
2499         int ret = CAMERA_ERROR_NONE;
2500
2501         camera_cli_s *pc = (camera_cli_s *)camera;
2502         muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2503         int sock_fd;
2504         if (pc->cb_info == NULL) {
2505                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2506                 return CAMERA_ERROR_INVALID_PARAMETER;
2507         }
2508         sock_fd = pc->cb_info->fd;
2509
2510         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2511         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2512         LOGD("ret : 0x%x", ret);
2513         return (bool)ret;
2514 }
2515
2516 int camera_get_device_count(camera_h camera, int *device_count)
2517 {
2518         if (camera == NULL || device_count == NULL) {
2519                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2520                 return CAMERA_ERROR_INVALID_PARAMETER;
2521         }
2522         int ret = CAMERA_ERROR_NONE;
2523
2524         camera_cli_s *pc = (camera_cli_s *)camera;
2525         muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2526         int sock_fd;
2527         if (pc->cb_info == NULL) {
2528                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2529                 return CAMERA_ERROR_INVALID_PARAMETER;
2530         }
2531         sock_fd = pc->cb_info->fd;
2532         int get_device_count;
2533
2534         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2535         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2536
2537         if (ret == CAMERA_ERROR_NONE) {
2538                 muse_camera_msg_get(get_device_count, pc->cb_info->recv_msg);
2539                 *device_count = get_device_count;
2540         }
2541         LOGD("ret : 0x%x", ret);
2542         return ret;
2543 }
2544
2545 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2546 {
2547         if (camera == NULL) {
2548                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2549                 return CAMERA_ERROR_INVALID_PARAMETER;
2550         }
2551
2552         int ret = CAMERA_ERROR_NONE;
2553
2554         camera_cli_s *pc = (camera_cli_s *)camera;
2555         muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2556
2557         LOGD("Enter, handle :%x", pc->remote_handle);
2558         int sock_fd;
2559         if (pc->cb_info == NULL) {
2560                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2561                 return CAMERA_ERROR_INVALID_PARAMETER;
2562         }
2563         sock_fd = pc->cb_info->fd;
2564         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2565         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2566
2567         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2568         LOGD("ret : 0x%x", ret);
2569         return ret;
2570 }
2571
2572 int camera_stop_face_detection(camera_h camera)
2573 {
2574         if (camera == NULL) {
2575                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2576                 return CAMERA_ERROR_INVALID_PARAMETER;
2577         }
2578
2579         int ret = CAMERA_ERROR_NONE;
2580
2581         camera_cli_s *pc = (camera_cli_s *)camera;
2582         muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
2583         LOGD("Enter,  handle :%x", pc->remote_handle);
2584         int sock_fd;
2585         if (pc->cb_info == NULL) {
2586                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2587                 return CAMERA_ERROR_INVALID_PARAMETER;
2588         }
2589         sock_fd = pc->cb_info->fd;
2590         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2591         LOGD("ret : 0x%x", ret);
2592         return ret;
2593 }
2594
2595 int camera_get_state(camera_h camera, camera_state_e *state)
2596 {
2597         if (camera == NULL || state == NULL) {
2598                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2599                 return CAMERA_ERROR_INVALID_PARAMETER;
2600         }
2601         int ret = CAMERA_ERROR_NONE;
2602
2603         camera_cli_s *pc = (camera_cli_s *)camera;
2604         muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
2605         int sock_fd;
2606         if (pc->cb_info == NULL) {
2607                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2608                 return CAMERA_ERROR_INVALID_PARAMETER;
2609         }
2610         sock_fd = pc->cb_info->fd;
2611         int get_state;
2612
2613         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2614         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2615
2616         if (ret == CAMERA_ERROR_NONE) {
2617                 muse_camera_msg_get(get_state, pc->cb_info->recv_msg);
2618                 *state = (camera_state_e)get_state;
2619         }
2620         LOGD("ret : 0x%x", ret);
2621         return ret;
2622 }
2623
2624 int camera_start_focusing(camera_h camera, bool continuous)
2625 {
2626         if (camera == NULL) {
2627                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2628                 return CAMERA_ERROR_INVALID_PARAMETER;
2629         }
2630
2631         int ret = CAMERA_ERROR_NONE;
2632
2633         camera_cli_s *pc = (camera_cli_s *)camera;
2634         muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
2635         int sock_fd;
2636         if (pc->cb_info == NULL) {
2637                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2638                 return CAMERA_ERROR_INVALID_PARAMETER;
2639         }
2640         sock_fd = pc->cb_info->fd;
2641         int is_continuous = (int)continuous;
2642
2643         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2644         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, is_continuous);
2645         LOGD("ret : 0x%x", ret);
2646         return ret;
2647 }
2648
2649 int camera_cancel_focusing(camera_h camera)
2650 {
2651         if (camera == NULL) {
2652                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2653                 return CAMERA_ERROR_INVALID_PARAMETER;
2654         }
2655
2656         int ret = CAMERA_ERROR_NONE;
2657
2658         camera_cli_s *pc = (camera_cli_s *)camera;
2659         muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
2660         int sock_fd;
2661         if (pc->cb_info == NULL) {
2662                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2663                 return CAMERA_ERROR_INVALID_PARAMETER;
2664         }
2665         sock_fd = pc->cb_info->fd;
2666
2667         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2668         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2669         LOGD("ret : 0x%x", ret);
2670         return ret;
2671 }
2672
2673 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
2674 {
2675         int ret = CAMERA_ERROR_NONE;
2676         void *set_display_handle = NULL;
2677         Evas_Object *obj = NULL;
2678         const char *object_type = NULL;
2679 #ifdef HAVE_WAYLAND
2680         camera_wl_info_s *wl_info = NULL;
2681 #endif /* HAVE_WAYLAND */
2682         camera_cli_s *pc = (camera_cli_s *)camera;
2683         camera_cb_info_s *cb_info = NULL;
2684         muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
2685         camera_state_e current_state = CAMERA_STATE_NONE;
2686         int sock_fd = 0;
2687
2688         if (camera == NULL) {
2689                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2690                 return CAMERA_ERROR_INVALID_PARAMETER;
2691         }
2692
2693         if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
2694                 LOGE("invalid type %d", type);
2695                 return CAMERA_ERROR_INVALID_PARAMETER;
2696         }
2697
2698         if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
2699                 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
2700                 return CAMERA_ERROR_INVALID_PARAMETER;
2701         }
2702
2703         if (pc->cb_info == NULL) {
2704                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2705                 return CAMERA_ERROR_INVALID_PARAMETER;
2706         }
2707
2708         cb_info = (camera_cb_info_s *)pc->cb_info;
2709         sock_fd = cb_info->fd;
2710
2711         ret = camera_get_state(camera, &current_state);
2712         if (ret != CAMERA_ERROR_NONE) {
2713                 LOGE("failed to get current state 0x%x", ret);
2714                 return ret;
2715         }
2716
2717         if (current_state != CAMERA_STATE_CREATED) {
2718                 LOGE("INVALID_STATE : current %d", current_state);
2719                 return CAMERA_ERROR_INVALID_STATE;
2720         }
2721
2722         LOGD("Enter, remote_handle : %x display : 0x%x", pc->remote_handle, display);
2723
2724         if (type == CAMERA_DISPLAY_TYPE_NONE) {
2725                 set_display_handle = 0;
2726                 LOGD("display type NONE");
2727         } else {
2728                 obj = (Evas_Object *)display;
2729                 object_type = evas_object_type_get(obj);
2730                 if (object_type) {
2731                         if (type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
2732 #ifdef HAVE_WAYLAND
2733                                 /* get wayland parent id */
2734                                 if (_get_wl_info(obj, &pc->wl_info) != CAMERA_ERROR_NONE) {
2735                                         LOGE("failed to get wayland info");
2736                                         return CAMERA_ERROR_INVALID_OPERATION;
2737                                 }
2738
2739                                 set_display_handle = (void *)&pc->wl_info;
2740 #else /* HAVE_WAYLAND */
2741                                 /* x window overlay surface */
2742                                 set_display_handle = (void *)elm_win_xwindow_get(obj);
2743 #endif /* HAVE_WAYLAND */
2744                                 LOGD("display type OVERLAY : handle %p", set_display_handle);
2745                         } else if (type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
2746                                 /* evas object surface */
2747                                 set_display_handle = (void *)display;
2748                                 LOGD("display type EVAS : handle %p", set_display_handle);
2749
2750 #ifdef EVAS_RENDERER_SUPPORT
2751                                 g_mutex_lock(&cb_info->evas_mutex);
2752
2753                                 if (cb_info->evas_info) {
2754                                         LOGW("destroy existed evas renderer %p", cb_info->evas_info);
2755                                         ret = mm_evas_renderer_destroy(&cb_info->evas_info);
2756                                         if (ret != MM_ERROR_NONE) {
2757                                                 LOGE("failed to destroy evas renderer %p", cb_info->evas_info);
2758                                                 g_mutex_unlock(&cb_info->evas_mutex);
2759                                                 return CAMERA_ERROR_INVALID_OPERATION;
2760                                         }
2761                                 }
2762
2763                                 /* create evas renderer */
2764                                 ret = mm_evas_renderer_create(&cb_info->evas_info, (Evas_Object *)set_display_handle);
2765                                 if (ret == MM_ERROR_NONE) {
2766                                         camera_flip_e flip = CAMERA_FLIP_NONE;
2767                                         camera_display_mode_e mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
2768                                         camera_rotation_e rotation = CAMERA_ROTATION_NONE;
2769                                         bool visible = 0;
2770                                         int x = 0;
2771                                         int y = 0;
2772                                         int width = 0;
2773                                         int height = 0;
2774
2775                                         camera_get_display_flip(camera, &flip);
2776                                         camera_get_display_mode(camera, &mode);
2777                                         camera_get_display_rotation(camera, &rotation);
2778                                         camera_is_display_visible(camera, &visible);
2779                                         camera_attr_get_display_roi_area(camera, &x, &y, &width, &height);
2780
2781                                         LOGD("current setting : flip %d, mode %d, rotation %d, visible %d, roi %d,%d,%dx%d",
2782                                                 flip, mode, rotation, visible, x, y, width, height);
2783
2784                                         ret = mm_evas_renderer_set_flip(cb_info->evas_info, flip);
2785                                         ret |= mm_evas_renderer_set_geometry(cb_info->evas_info, mode);
2786                                         ret |= mm_evas_renderer_set_rotation(cb_info->evas_info, rotation);
2787                                         ret |= mm_evas_renderer_set_visible(cb_info->evas_info, visible);
2788                                         ret |= mm_evas_renderer_set_roi_area(cb_info->evas_info, x, y, width, height);
2789                                 }
2790
2791                                 g_mutex_unlock(&cb_info->evas_mutex);
2792
2793                                 if (ret != MM_ERROR_NONE) {
2794                                         LOGE("mm_evas_renderer error 0x%x", ret);
2795                                         return CAMERA_ERROR_INVALID_OPERATION;
2796                                 }
2797 #else /* EVAS_RENDERER_SUPPORT */
2798                                 LOGE("EVAS surface is not supported");
2799                                 return CAMERA_ERROR_NOT_SUPPORTED;
2800 #endif /* EVAS_RENDERER_SUPPORT */
2801                         } else {
2802                                 LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type);
2803                                 return CAMERA_ERROR_INVALID_PARAMETER;
2804                         }
2805                 } else {
2806                         LOGE("failed to get evas object type from %p", obj);
2807                         return CAMERA_ERROR_INVALID_PARAMETER;
2808                 }
2809         }
2810
2811         pc->display_handle = (intptr_t)set_display_handle;
2812
2813         if (type == CAMERA_DISPLAY_TYPE_OVERLAY) {
2814 #ifdef HAVE_WAYLAND
2815                 wl_info = &pc->wl_info;
2816                 muse_camera_msg_send_array_and_value(api, sock_fd, cb_info, ret,
2817                         wl_info, 5, sizeof(int), INT, type);
2818
2819                 LOGD("wayland parent id : %d, window %d,%d,%dx%d",
2820                         wl_info->parent_id, wl_info->window_x, wl_info->window_y,
2821                         wl_info->window_width, wl_info->window_height);
2822 #else /* HAVE_WAYLAND */
2823                 muse_camera_msg_send2(api, sock_fd, cb_info, ret, INT, type, INT, set_display_handle);
2824
2825                 LOGD("x id : %d", (int)set_display_handle);
2826 #endif /* HAVE_WAYLAND */
2827         } else
2828                 muse_camera_msg_send1(api, sock_fd, cb_info, ret, INT, type);
2829
2830         if (ret != CAMERA_ERROR_NONE)
2831                 LOGE("set display error 0x%x", ret);
2832         else if (type == CAMERA_DISPLAY_TYPE_EVAS)
2833                 SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_EVAS);
2834
2835         return ret;
2836 }
2837
2838 int camera_set_preview_resolution(camera_h camera,  int width, int height)
2839 {
2840         if (camera == NULL) {
2841                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2842                 return CAMERA_ERROR_INVALID_PARAMETER;
2843         }
2844         int ret = CAMERA_ERROR_NONE;
2845
2846         camera_cli_s *pc = (camera_cli_s *)camera;
2847         muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
2848         int sock_fd;
2849         if (pc->cb_info == NULL) {
2850                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2851                 return CAMERA_ERROR_INVALID_PARAMETER;
2852         }
2853         sock_fd = pc->cb_info->fd;
2854
2855         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2856         muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, width, INT, height);
2857         LOGD("ret : 0x%x", ret);
2858         return ret;
2859 }
2860
2861
2862 int camera_set_capture_resolution(camera_h camera,  int width, int height)
2863 {
2864         if (camera == NULL) {
2865                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2866                 return CAMERA_ERROR_INVALID_PARAMETER;
2867         }
2868
2869         int ret = CAMERA_ERROR_NONE;
2870
2871         camera_cli_s *pc = (camera_cli_s *)camera;
2872         muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
2873         int sock_fd;
2874         if (pc->cb_info == NULL) {
2875                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2876                 return CAMERA_ERROR_INVALID_PARAMETER;
2877         }
2878         sock_fd = pc->cb_info->fd;
2879
2880         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2881         muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, width, INT, height);
2882         LOGD("ret : 0x%x", ret);
2883         return ret;
2884 }
2885
2886 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
2887 {
2888         if (camera == NULL) {
2889                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2890                 return CAMERA_ERROR_INVALID_PARAMETER;
2891         }
2892
2893         int ret = CAMERA_ERROR_NONE;
2894         int set_format = (int)format;
2895
2896         camera_cli_s *pc = (camera_cli_s *)camera;
2897         muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
2898         int sock_fd;
2899         if (pc->cb_info == NULL) {
2900                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2901                 return CAMERA_ERROR_INVALID_PARAMETER;
2902         }
2903         sock_fd = pc->cb_info->fd;
2904
2905         LOGD("Enter, remote_handle : %x, capture_format: %d", pc->remote_handle, set_format);
2906         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_format);
2907         LOGD("ret : 0x%x", ret);
2908         return ret;
2909 }
2910
2911 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
2912 {
2913         if (camera == NULL) {
2914                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2915                 return CAMERA_ERROR_INVALID_PARAMETER;
2916         }
2917
2918         int ret = CAMERA_ERROR_NONE;
2919         int set_format = (int)format;
2920
2921         camera_cli_s *pc = (camera_cli_s *)camera;
2922         muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
2923         int sock_fd;
2924         if (pc->cb_info == NULL) {
2925                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2926                 return CAMERA_ERROR_INVALID_PARAMETER;
2927         }
2928         sock_fd = pc->cb_info->fd;
2929
2930         LOGD("Enter, remote_handle : %x, capture_format: %d", pc->remote_handle, set_format);
2931         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_format);
2932         LOGD("ret : 0x%x", ret);
2933         return ret;
2934 }
2935
2936 int camera_get_preview_resolution(camera_h camera,  int *width, int *height)
2937 {
2938         if (camera == NULL || width == NULL || height == NULL) {
2939                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2940                 return CAMERA_ERROR_INVALID_PARAMETER;
2941         }
2942
2943
2944         int ret = CAMERA_ERROR_NONE;
2945
2946         camera_cli_s *pc = (camera_cli_s *)camera;
2947         muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
2948         int sock_fd;
2949         if (pc->cb_info == NULL) {
2950                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2951                 return CAMERA_ERROR_INVALID_PARAMETER;
2952         }
2953         sock_fd = pc->cb_info->fd;
2954         int get_width;
2955         int get_height;
2956
2957         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2958         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2959
2960         if (ret == CAMERA_ERROR_NONE) {
2961                 muse_camera_msg_get(get_width, pc->cb_info->recv_msg);
2962                 muse_camera_msg_get(get_height, pc->cb_info->recv_msg);
2963                 *width = get_width;
2964                 *height = get_height;
2965         }
2966         LOGD("ret : 0x%x", ret);
2967         return ret;
2968 }
2969
2970 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
2971 {
2972         int ret = CAMERA_ERROR_NONE;
2973         int set_rotation = (int)rotation;
2974         camera_cli_s *pc = NULL;
2975
2976         if (camera == NULL) {
2977                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2978                 return CAMERA_ERROR_INVALID_PARAMETER;
2979         }
2980
2981         if (rotation < CAMERA_ROTATION_NONE || rotation > CAMERA_ROTATION_270) {
2982                 LOGE("Invalid rotation %d", rotation);
2983                 return CAMERA_ERROR_INVALID_PARAMETER;
2984         }
2985
2986         pc = (camera_cli_s *)camera;
2987
2988         if (pc->cb_info == NULL) {
2989                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2990                 return CAMERA_ERROR_INVALID_PARAMETER;
2991         }
2992
2993 #ifdef EVAS_RENDERER_SUPPORT
2994         if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
2995                 g_mutex_lock(&pc->cb_info->evas_mutex);
2996
2997                 ret = mm_evas_renderer_set_rotation(pc->cb_info->evas_info, rotation);
2998
2999                 g_mutex_unlock(&pc->cb_info->evas_mutex);
3000
3001                 if (ret != MM_ERROR_NONE) {
3002                         LOGE("failed to set rotation for evas surface 0x%x", ret);
3003                         return CAMERA_ERROR_INVALID_OPERATION;
3004                 }
3005         }
3006 #endif /* EVAS_RENDERER_SUPPORT */
3007
3008         muse_camera_msg_send1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION,
3009                 pc->cb_info->fd, pc->cb_info, ret, INT, set_rotation);
3010
3011         return ret;
3012 }
3013
3014 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
3015 {
3016         int ret = CAMERA_ERROR_NONE;
3017         int get_rotation = CAMERA_ROTATION_NONE;
3018         camera_cli_s *pc = NULL;
3019
3020         if (camera == NULL || rotation == NULL) {
3021                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3022                 return CAMERA_ERROR_INVALID_PARAMETER;
3023         }
3024
3025         pc = (camera_cli_s *)camera;
3026
3027         if (pc->cb_info == NULL) {
3028                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3029                 return CAMERA_ERROR_INVALID_PARAMETER;
3030         }
3031
3032         muse_camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION,
3033                 pc->cb_info->fd, pc->cb_info, ret);
3034
3035         if (ret == CAMERA_ERROR_NONE) {
3036                 muse_camera_msg_get(get_rotation, pc->cb_info->recv_msg);
3037                 *rotation = (camera_rotation_e)get_rotation;
3038         }
3039
3040         return ret;
3041 }
3042
3043 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
3044 {
3045         int ret = CAMERA_ERROR_NONE;
3046         int set_flip = (int)flip;
3047         camera_cli_s *pc = NULL;
3048
3049         if (camera == NULL) {
3050                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3051                 return CAMERA_ERROR_INVALID_PARAMETER;
3052         }
3053
3054         if (flip < CAMERA_FLIP_NONE || flip > CAMERA_FLIP_BOTH) {
3055                 LOGE("Invalid flip %d", flip);
3056                 return CAMERA_ERROR_INVALID_PARAMETER;
3057         }
3058
3059         pc = (camera_cli_s *)camera;
3060
3061         if (pc->cb_info == NULL) {
3062                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3063                 return CAMERA_ERROR_INVALID_PARAMETER;
3064         }
3065
3066 #ifdef EVAS_RENDERER_SUPPORT
3067         if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3068                 g_mutex_lock(&pc->cb_info->evas_mutex);
3069
3070                 ret = mm_evas_renderer_set_flip(pc->cb_info->evas_info, flip);
3071
3072                 g_mutex_unlock(&pc->cb_info->evas_mutex);
3073
3074                 if (ret != MM_ERROR_NONE) {
3075                         LOGE("failed to set flip for evas surface 0x%x", ret);
3076                         return CAMERA_ERROR_INVALID_OPERATION;
3077                 }
3078         }
3079 #endif /* EVAS_RENDERER_SUPPORT */
3080
3081         muse_camera_msg_send1(MUSE_CAMERA_API_SET_DISPLAY_FLIP,
3082                 pc->cb_info->fd, pc->cb_info, ret, INT, set_flip);
3083
3084         return ret;
3085 }
3086
3087 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
3088 {
3089         int ret = CAMERA_ERROR_NONE;
3090         int get_flip = CAMERA_FLIP_NONE;
3091         camera_cli_s *pc = NULL;
3092
3093         if (camera == NULL || flip == NULL) {
3094                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3095                 return CAMERA_ERROR_INVALID_PARAMETER;
3096         }
3097
3098         pc = (camera_cli_s *)camera;
3099
3100         if (pc->cb_info == NULL) {
3101                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3102                 return CAMERA_ERROR_INVALID_PARAMETER;
3103         }
3104
3105         muse_camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP,
3106                 pc->cb_info->fd, pc->cb_info, ret);
3107
3108         if (ret == CAMERA_ERROR_NONE) {
3109                 muse_camera_msg_get(get_flip, pc->cb_info->recv_msg);
3110                 *flip = (camera_flip_e)get_flip;
3111         }
3112
3113         return ret;
3114 }
3115
3116 int camera_set_display_visible(camera_h camera, bool visible)
3117 {
3118         int ret = CAMERA_ERROR_NONE;
3119         int set_visible = (int)visible;
3120         camera_cli_s *pc = NULL;
3121
3122         if (camera == NULL) {
3123                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3124                 return CAMERA_ERROR_INVALID_PARAMETER;
3125         }
3126
3127         pc = (camera_cli_s *)camera;
3128
3129         if (pc->cb_info == NULL) {
3130                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3131                 return CAMERA_ERROR_INVALID_PARAMETER;
3132         }
3133
3134 #ifdef EVAS_RENDERER_SUPPORT
3135         if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3136                 g_mutex_lock(&pc->cb_info->evas_mutex);
3137
3138                 ret = mm_evas_renderer_set_visible(pc->cb_info->evas_info, visible);
3139
3140                 g_mutex_unlock(&pc->cb_info->evas_mutex);
3141
3142                 if (ret != MM_ERROR_NONE) {
3143                         LOGE("failed to set visible for evas surface 0x%x", ret);
3144                         return CAMERA_ERROR_INVALID_OPERATION;
3145                 }
3146         }
3147 #endif /* EVAS_RENDERER_SUPPORT */
3148
3149         muse_camera_msg_send1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE,
3150                 pc->cb_info->fd, pc->cb_info, ret, INT, set_visible);
3151
3152         return ret;
3153 }
3154
3155 int camera_is_display_visible(camera_h camera, bool *visible)
3156 {
3157         int ret = CAMERA_ERROR_NONE;
3158         int get_visible = true;
3159         camera_cli_s *pc = NULL;
3160
3161         if (camera == NULL || visible == NULL) {
3162                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3163                 return CAMERA_ERROR_INVALID_PARAMETER;
3164         }
3165
3166         pc = (camera_cli_s *)camera;
3167
3168         if (pc->cb_info == NULL) {
3169                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3170                 return CAMERA_ERROR_INVALID_PARAMETER;
3171         }
3172
3173         muse_camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE,
3174                 pc->cb_info->fd, pc->cb_info, ret);
3175
3176         if (ret == CAMERA_ERROR_NONE) {
3177                 muse_camera_msg_get(get_visible, pc->cb_info->recv_msg);
3178                 *visible = (bool)get_visible;
3179         }
3180
3181         return ret;
3182 }
3183
3184 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
3185 {
3186         int ret = CAMERA_ERROR_NONE;
3187         int set_mode = (int)mode;
3188         camera_cli_s *pc = NULL;
3189
3190         if (camera == NULL) {
3191                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3192                 return CAMERA_ERROR_INVALID_PARAMETER;
3193         }
3194
3195         if (mode < CAMERA_DISPLAY_MODE_LETTER_BOX || mode > CAMERA_DISPLAY_MODE_CUSTOM_ROI) {
3196                 LOGE("Invalid mode %d", mode);
3197                 return CAMERA_ERROR_INVALID_PARAMETER;
3198         }
3199
3200         pc = (camera_cli_s *)camera;
3201
3202         if (pc->cb_info == NULL) {
3203                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3204                 return CAMERA_ERROR_INVALID_PARAMETER;
3205         }
3206
3207 #ifdef EVAS_RENDERER_SUPPORT
3208         if (CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
3209                 g_mutex_lock(&pc->cb_info->evas_mutex);
3210
3211                 ret = mm_evas_renderer_set_geometry(pc->cb_info->evas_info, mode);
3212
3213                 g_mutex_unlock(&pc->cb_info->evas_mutex);
3214
3215                 if (ret != MM_ERROR_NONE) {
3216                         LOGE("failed to set geometry for evas surface 0x%x", ret);
3217                         return CAMERA_ERROR_INVALID_OPERATION;
3218                 }
3219         }
3220 #endif /* EVAS_RENDERER_SUPPORT */
3221
3222         muse_camera_msg_send1(MUSE_CAMERA_API_SET_DISPLAY_MODE,
3223                 pc->cb_info->fd, pc->cb_info, ret, INT, set_mode);
3224
3225         return ret;
3226 }
3227
3228 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
3229 {
3230         int ret = CAMERA_ERROR_NONE;
3231         int get_mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
3232         camera_cli_s *pc = NULL;
3233
3234         if (camera == NULL || mode == NULL) {
3235                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3236                 return CAMERA_ERROR_INVALID_PARAMETER;
3237         }
3238
3239         pc = (camera_cli_s *)camera;
3240
3241         if (pc->cb_info == NULL) {
3242                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3243                 return CAMERA_ERROR_INVALID_PARAMETER;
3244         }
3245
3246         muse_camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE,
3247                 pc->cb_info->fd, pc->cb_info, ret);
3248
3249         if (ret == CAMERA_ERROR_NONE) {
3250                 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
3251                 *mode = (camera_display_mode_e)get_mode;
3252         }
3253
3254         return ret;
3255 }
3256
3257 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
3258 {
3259         if (camera == NULL || width == NULL || height == NULL) {
3260                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3261                 return CAMERA_ERROR_INVALID_PARAMETER;
3262         }
3263         int ret = CAMERA_ERROR_NONE;
3264
3265         camera_cli_s *pc = (camera_cli_s *)camera;
3266         muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
3267         int sock_fd;
3268         if (pc->cb_info == NULL) {
3269                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3270                 return CAMERA_ERROR_INVALID_PARAMETER;
3271         }
3272         sock_fd = pc->cb_info->fd;
3273         int get_width;
3274         int get_height;
3275
3276         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3277         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3278
3279         if (ret == CAMERA_ERROR_NONE) {
3280                 muse_camera_msg_get(get_width, pc->cb_info->recv_msg);
3281                 muse_camera_msg_get(get_height, pc->cb_info->recv_msg);
3282                 *width = get_width;
3283                 *height = get_height;
3284         }
3285         LOGD("ret : 0x%x", ret);
3286         return ret;
3287 }
3288
3289 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
3290 {
3291         if (camera == NULL || format == NULL) {
3292                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3293                 return CAMERA_ERROR_INVALID_PARAMETER;
3294         }
3295         int ret = CAMERA_ERROR_NONE;
3296
3297         camera_cli_s *pc = (camera_cli_s *)camera;
3298         muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
3299         int get_format;
3300         int sock_fd;
3301         if (pc->cb_info == NULL) {
3302                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3303                 return CAMERA_ERROR_INVALID_PARAMETER;
3304         }
3305         sock_fd = pc->cb_info->fd;
3306
3307         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3308         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3309
3310         if (ret == CAMERA_ERROR_NONE) {
3311                 muse_camera_msg_get(get_format, pc->cb_info->recv_msg);
3312                 *format = (camera_pixel_format_e)get_format;
3313         }
3314         LOGD("ret : 0x%x", ret);
3315         return ret;
3316 }
3317
3318 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
3319 {
3320         if (camera == NULL || format == NULL) {
3321                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3322                 return CAMERA_ERROR_INVALID_PARAMETER;
3323         }
3324
3325         int ret = CAMERA_ERROR_NONE;
3326
3327         camera_cli_s *pc = (camera_cli_s *)camera;
3328         muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
3329         int get_format;
3330         int sock_fd;
3331         if (pc->cb_info == NULL) {
3332                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3333                 return CAMERA_ERROR_INVALID_PARAMETER;
3334         }
3335         sock_fd = pc->cb_info->fd;
3336
3337         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3338         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3339
3340         if (ret == CAMERA_ERROR_NONE) {
3341                 muse_camera_msg_get(get_format, pc->cb_info->recv_msg);
3342                 *format = (camera_pixel_format_e)get_format;
3343         }
3344         LOGD("ret : 0x%x", ret);
3345         return ret;
3346 }
3347
3348 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direciton)
3349 {
3350         if (camera == NULL || facing_direciton == NULL) {
3351                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3352                 return CAMERA_ERROR_INVALID_PARAMETER;
3353         }
3354
3355         int ret = CAMERA_ERROR_NONE;
3356
3357         camera_cli_s *pc = (camera_cli_s *)camera;
3358         muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
3359         int sock_fd;
3360         if (pc->cb_info == NULL) {
3361                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3362                 return CAMERA_ERROR_INVALID_PARAMETER;
3363         }
3364         sock_fd = pc->cb_info->fd;
3365         int get_facing_direction;
3366
3367         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3368         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3369
3370         if (ret == CAMERA_ERROR_NONE) {
3371                 muse_camera_msg_get(get_facing_direction, pc->cb_info->recv_msg);
3372                 *facing_direciton = (camera_facing_direction_e)get_facing_direction;
3373         }
3374         LOGD("ret : 0x%x", ret);
3375         return ret;
3376 }
3377
3378 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
3379 {
3380         if (camera == NULL || callback == NULL) {
3381                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3382                 return CAMERA_ERROR_INVALID_PARAMETER;
3383         }
3384         int ret = CAMERA_ERROR_NONE;
3385
3386         camera_cli_s *pc = (camera_cli_s *)camera;
3387         camera_cb_info_s *cb_info = (camera_cb_info_s *)pc->cb_info;
3388         int sock_fd;
3389         if (pc->cb_info == NULL) {
3390                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3391                 return CAMERA_ERROR_INVALID_PARAMETER;
3392         }
3393         sock_fd = pc->cb_info->fd;
3394         muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
3395
3396         LOGD("Enter, handle :%x", pc->remote_handle);
3397
3398         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
3399         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
3400         SET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_USER);
3401
3402         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3403         LOGD("ret : 0x%x", ret);
3404         return ret;
3405 }
3406
3407 int camera_unset_preview_cb(camera_h camera)
3408 {
3409         if (camera == NULL) {
3410                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3411                 return CAMERA_ERROR_INVALID_PARAMETER;
3412         }
3413
3414         int ret = CAMERA_ERROR_NONE;
3415
3416         camera_cli_s *pc = (camera_cli_s *)camera;
3417         camera_cb_info_s *cb_info = (camera_cb_info_s *)pc->cb_info;
3418         muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
3419
3420         LOGD("Enter, handle :%x", pc->remote_handle);
3421
3422         int sock_fd;
3423         if (pc->cb_info == NULL) {
3424                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3425                 return CAMERA_ERROR_INVALID_PARAMETER;
3426         }
3427         sock_fd = pc->cb_info->fd;
3428         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = (void *)NULL;
3429         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = (void *)NULL;
3430         UNSET_PREVIEW_CB_TYPE(cb_info, PREVIEW_CB_TYPE_USER);
3431
3432         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3433         LOGD("ret : 0x%x", ret);
3434         return ret;
3435 }
3436
3437 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
3438 {
3439         if (camera == NULL) {
3440                 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
3441                 return CAMERA_ERROR_INVALID_PARAMETER;
3442         }
3443
3444         if (camera_is_supported_media_packet_preview_cb(camera) == false) {
3445                 LOGE("NOT SUPPORTED");
3446                 return CAMERA_ERROR_NOT_SUPPORTED;
3447         }
3448
3449         if (callback == NULL) {
3450                 LOGE("INVALID_PARAMETER(0x%08x) - callback", CAMERA_ERROR_INVALID_PARAMETER);
3451                 return CAMERA_ERROR_INVALID_PARAMETER;
3452         }
3453
3454         int ret = CAMERA_ERROR_NONE;
3455
3456         camera_cli_s *pc = (camera_cli_s *)camera;
3457         muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
3458
3459         LOGD("Enter, handle :%x", pc->remote_handle);
3460
3461         int sock_fd;
3462         if (pc->cb_info == NULL) {
3463                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3464                 return CAMERA_ERROR_INVALID_PARAMETER;
3465         }
3466         sock_fd = pc->cb_info->fd;
3467         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
3468         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
3469
3470         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3471         LOGD("ret : 0x%x", ret);
3472         return ret;
3473 }
3474
3475 int camera_unset_media_packet_preview_cb(camera_h camera)
3476 {
3477         if (camera == NULL) {
3478                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3479                 return CAMERA_ERROR_INVALID_PARAMETER;
3480         }
3481
3482         int ret = CAMERA_ERROR_NONE;
3483
3484         camera_cli_s *pc = (camera_cli_s *)camera;
3485         muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3486
3487         LOGD("Enter, handle :%x", pc->remote_handle);
3488
3489         int sock_fd;
3490         if (pc->cb_info == NULL) {
3491                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3492                 return CAMERA_ERROR_INVALID_PARAMETER;
3493         }
3494         sock_fd = pc->cb_info->fd;
3495         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)NULL;
3496         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)NULL;
3497
3498         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3499         LOGD("ret : 0x%x", ret);
3500         return ret;
3501 }
3502
3503 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3504 {
3505         if (camera == NULL || callback == NULL) {
3506                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3507                 return CAMERA_ERROR_INVALID_PARAMETER;
3508         }
3509         int ret = CAMERA_ERROR_NONE;
3510
3511         camera_cli_s *pc = (camera_cli_s *)camera;
3512         muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3513
3514         LOGD("Enter, handle :%x", pc->remote_handle);
3515
3516         int sock_fd;
3517         if (pc->cb_info == NULL) {
3518                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3519                 return CAMERA_ERROR_INVALID_PARAMETER;
3520         }
3521         sock_fd = pc->cb_info->fd;
3522         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3523         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3524
3525         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3526         LOGD("ret : 0x%x", ret);
3527         return ret;
3528 }
3529 int camera_unset_state_changed_cb(camera_h camera)
3530 {
3531         if (camera == NULL) {
3532                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3533                 return CAMERA_ERROR_INVALID_PARAMETER;
3534         }
3535         int ret = CAMERA_ERROR_NONE;
3536
3537         camera_cli_s *pc = (camera_cli_s *)camera;
3538         muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3539
3540         LOGD("Enter, handle :%x", pc->remote_handle);
3541
3542         int sock_fd;
3543         if (pc->cb_info == NULL) {
3544                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3545                 return CAMERA_ERROR_INVALID_PARAMETER;
3546         }
3547         sock_fd = pc->cb_info->fd;
3548         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void *)NULL;
3549         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void *)NULL;
3550
3551         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3552         LOGD("ret : 0x%x", ret);
3553         return ret;
3554 }
3555
3556 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3557 {
3558         if (camera == NULL || callback == NULL) {
3559                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3560                 return CAMERA_ERROR_INVALID_PARAMETER;
3561         }
3562         int ret = CAMERA_ERROR_NONE;
3563
3564         camera_cli_s *pc = (camera_cli_s *)camera;
3565         muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3566
3567         LOGD("Enter, handle :%x", pc->remote_handle);
3568
3569         int sock_fd;
3570         if (pc->cb_info == NULL) {
3571                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3572                 return CAMERA_ERROR_INVALID_PARAMETER;
3573         }
3574         sock_fd = pc->cb_info->fd;
3575         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3576         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3577
3578         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3579         LOGD("ret : 0x%x", ret);
3580         return ret;
3581 }
3582
3583 int camera_unset_interrupted_cb(camera_h camera)
3584 {
3585         if (camera == NULL) {
3586                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3587                 return CAMERA_ERROR_INVALID_PARAMETER;
3588         }
3589         int ret = CAMERA_ERROR_NONE;
3590
3591         camera_cli_s *pc = (camera_cli_s *)camera;
3592         muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3593
3594         LOGD("Enter, handle :%x", pc->remote_handle);
3595
3596         int sock_fd;
3597         if (pc->cb_info == NULL) {
3598                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3599                 return CAMERA_ERROR_INVALID_PARAMETER;
3600         }
3601         sock_fd = pc->cb_info->fd;
3602         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = (void *)NULL;
3603         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = (void *)NULL;
3604
3605         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3606         LOGD("ret : 0x%x", ret);
3607         return ret;
3608 }
3609
3610 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
3611 {
3612         if (camera == NULL || callback == NULL) {
3613                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3614                 return CAMERA_ERROR_INVALID_PARAMETER;
3615         }
3616         int ret = CAMERA_ERROR_NONE;
3617
3618         camera_cli_s *pc = (camera_cli_s *)camera;
3619         muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3620
3621         LOGD("Enter, handle :%x", pc->remote_handle);
3622
3623         int sock_fd;
3624         if (pc->cb_info == NULL) {
3625                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3626                 return CAMERA_ERROR_INVALID_PARAMETER;
3627         }
3628         sock_fd = pc->cb_info->fd;
3629         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3630         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3631
3632         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3633         LOGD("ret : 0x%x", ret);
3634         return ret;
3635 }
3636
3637 int camera_unset_focus_changed_cb(camera_h camera)
3638 {
3639         if (camera == NULL) {
3640                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3641                 return CAMERA_ERROR_INVALID_PARAMETER;
3642         }
3643         int ret = CAMERA_ERROR_NONE;
3644
3645         camera_cli_s *pc = (camera_cli_s *)camera;
3646         muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
3647
3648         LOGD("Enter, handle :%x", pc->remote_handle);
3649
3650         int sock_fd;
3651         if (pc->cb_info == NULL) {
3652                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3653                 return CAMERA_ERROR_INVALID_PARAMETER;
3654         }
3655         sock_fd = pc->cb_info->fd;
3656         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void *)NULL;
3657         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void *)NULL;
3658
3659         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3660         LOGD("ret : 0x%x", ret);
3661         return ret;
3662 }
3663
3664 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
3665 {
3666         if (camera == NULL || callback == NULL) {
3667                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3668                 return CAMERA_ERROR_INVALID_PARAMETER;
3669         }
3670         int ret = CAMERA_ERROR_NONE;
3671
3672         camera_cli_s *pc = (camera_cli_s *)camera;
3673         muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
3674
3675         LOGD("Enter, handle :%x", pc->remote_handle);
3676
3677         int sock_fd;
3678         if (pc->cb_info == NULL) {
3679                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3680                 return CAMERA_ERROR_INVALID_PARAMETER;
3681         }
3682         sock_fd = pc->cb_info->fd;
3683         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
3684         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
3685
3686         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3687         LOGD("ret : 0x%x", ret);
3688         return ret;
3689 }
3690
3691 int camera_unset_error_cb(camera_h camera)
3692 {
3693         if (camera == NULL) {
3694                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3695                 return CAMERA_ERROR_INVALID_PARAMETER;
3696         }
3697         int ret = CAMERA_ERROR_NONE;
3698
3699         camera_cli_s *pc = (camera_cli_s *)camera;
3700         muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
3701
3702         LOGD("Enter, handle :%x", pc->remote_handle);
3703
3704         int sock_fd;
3705         if (pc->cb_info == NULL) {
3706                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3707                 return CAMERA_ERROR_INVALID_PARAMETER;
3708         }
3709         sock_fd = pc->cb_info->fd;
3710         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = (void *)NULL;
3711         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = (void *)NULL;
3712
3713         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3714         LOGD("ret : 0x%x", ret);
3715         return ret;
3716 }
3717
3718 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb , void *user_data)
3719 {
3720         if (camera == NULL || foreach_cb == NULL) {
3721                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3722                 return CAMERA_ERROR_INVALID_PARAMETER;
3723         }
3724         int ret = CAMERA_ERROR_NONE;
3725
3726         camera_cli_s *pc = (camera_cli_s *)camera;
3727         muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
3728
3729         LOGD("Enter, handle :%x", pc->remote_handle);
3730
3731         int sock_fd;
3732         if (pc->cb_info == NULL) {
3733                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3734                 return CAMERA_ERROR_INVALID_PARAMETER;
3735         }
3736         sock_fd = pc->cb_info->fd;
3737         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
3738         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
3739
3740         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3741         LOGD("ret : 0x%x", ret);
3742         return ret;
3743 }
3744
3745 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb , void *user_data)
3746 {
3747         if (camera == NULL || foreach_cb == NULL) {
3748                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3749                 return CAMERA_ERROR_INVALID_PARAMETER;
3750         }
3751         int ret = CAMERA_ERROR_NONE;
3752
3753         camera_cli_s *pc = (camera_cli_s *)camera;
3754         muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
3755
3756         LOGD("Enter, handle :%x", pc->remote_handle);
3757
3758         int sock_fd;
3759         if (pc->cb_info == NULL) {
3760                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3761                 return CAMERA_ERROR_INVALID_PARAMETER;
3762         }
3763         sock_fd = pc->cb_info->fd;
3764         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
3765         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
3766
3767         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3768         LOGD("ret : 0x%x", ret);
3769         return ret;
3770 }
3771
3772 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb , void *user_data)
3773 {
3774         if (camera == NULL || foreach_cb == NULL) {
3775                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3776                 return CAMERA_ERROR_INVALID_PARAMETER;
3777         }
3778         int ret = CAMERA_ERROR_NONE;
3779
3780         camera_cli_s *pc = (camera_cli_s *)camera;
3781         muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
3782
3783         LOGD("Enter, handle :%x", pc->remote_handle);
3784
3785         int sock_fd;
3786         if (pc->cb_info == NULL) {
3787                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3788                 return CAMERA_ERROR_INVALID_PARAMETER;
3789         }
3790         sock_fd = pc->cb_info->fd;
3791         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
3792         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
3793
3794         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3795         LOGD("ret : 0x%x", ret);
3796         return ret;
3797 }
3798
3799
3800 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb , void *user_data)
3801 {
3802         if (camera == NULL || foreach_cb == NULL) {
3803                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3804                 return CAMERA_ERROR_INVALID_PARAMETER;
3805         }
3806         int ret = CAMERA_ERROR_NONE;
3807
3808         camera_cli_s *pc = (camera_cli_s *)camera;
3809         muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
3810
3811         LOGD("Enter, handle :%x", pc->remote_handle);
3812
3813         int sock_fd;
3814         if (pc->cb_info == NULL) {
3815                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3816                 return CAMERA_ERROR_INVALID_PARAMETER;
3817         }
3818         sock_fd = pc->cb_info->fd;
3819         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
3820         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
3821
3822         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3823         LOGD("ret : 0x%x", ret);
3824         return ret;
3825 }
3826
3827
3828 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
3829 {
3830         if (camera == NULL || width == NULL || height == NULL) {
3831                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3832                 return CAMERA_ERROR_INVALID_PARAMETER;
3833         }
3834         int ret = CAMERA_ERROR_NONE;
3835
3836         camera_cli_s *pc = (camera_cli_s *)camera;
3837         muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
3838         int sock_fd;
3839         if (pc->cb_info == NULL) {
3840                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3841                 return CAMERA_ERROR_INVALID_PARAMETER;
3842         }
3843         sock_fd = pc->cb_info->fd;
3844         int get_width;
3845         int get_height;
3846
3847         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3848         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3849
3850         if (ret == CAMERA_ERROR_NONE) {
3851                 muse_camera_msg_get(get_width, pc->cb_info->recv_msg);
3852                 muse_camera_msg_get(get_height, pc->cb_info->recv_msg);
3853                 *width = get_width;
3854                 *height = get_height;
3855         }
3856         LOGD("ret : 0x%x", ret);
3857         return ret;
3858 }
3859
3860
3861 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
3862 {
3863         if (camera == NULL || angle == NULL) {
3864                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3865                 return CAMERA_ERROR_INVALID_PARAMETER;
3866         }
3867         int ret = CAMERA_ERROR_NONE;
3868
3869         camera_cli_s *pc = (camera_cli_s *)camera;
3870         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
3871         int sock_fd;
3872         if (pc->cb_info == NULL) {
3873                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3874                 return CAMERA_ERROR_INVALID_PARAMETER;
3875         }
3876         sock_fd = pc->cb_info->fd;
3877         int get_angle;
3878
3879         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3880         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3881
3882         if (ret == CAMERA_ERROR_NONE) {
3883                 muse_camera_msg_get(get_angle, pc->cb_info->recv_msg);
3884                 *angle = get_angle;
3885         }
3886         LOGD("ret : 0x%x", ret);
3887         return ret;
3888 }
3889
3890 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
3891 {
3892         if (camera == NULL) {
3893                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3894                 return CAMERA_ERROR_INVALID_PARAMETER;
3895         }
3896         int ret = CAMERA_ERROR_NONE;
3897         camera_cli_s *pc = (camera_cli_s *)camera;
3898         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
3899         int sock_fd;
3900         if (pc->cb_info == NULL) {
3901                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3902                 return CAMERA_ERROR_INVALID_PARAMETER;
3903         }
3904         sock_fd = pc->cb_info->fd;
3905         int set_mode = (int)mode;
3906         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3907         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
3908         LOGD("ret : 0x%x", ret);
3909         return ret;
3910 }
3911
3912 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
3913 {
3914         if (camera == NULL || mode == NULL) {
3915                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3916                 return CAMERA_ERROR_INVALID_PARAMETER;
3917         }
3918
3919         int ret = CAMERA_ERROR_NONE;
3920         camera_cli_s *pc = (camera_cli_s *)camera;
3921         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
3922         int sock_fd;
3923         if (pc->cb_info == NULL) {
3924                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3925                 return CAMERA_ERROR_INVALID_PARAMETER;
3926         }
3927         sock_fd = pc->cb_info->fd;
3928         int get_mode;
3929         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3930         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3931
3932         if (ret == CAMERA_ERROR_NONE) {
3933                 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
3934                 *mode = (camera_attr_theater_mode_e)get_mode;
3935         }
3936         LOGD("ret : 0x%x", ret);
3937         return ret;
3938 }
3939
3940 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
3941 {
3942         if (camera == NULL || foreach_cb == NULL) {
3943                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3944                 return CAMERA_ERROR_INVALID_PARAMETER;
3945         }
3946         int ret = CAMERA_ERROR_NONE;
3947
3948         camera_cli_s *pc = (camera_cli_s *)camera;
3949         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
3950
3951         LOGD("Enter, handle :%x", pc->remote_handle);
3952
3953         int sock_fd;
3954         if (pc->cb_info == NULL) {
3955                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3956                 return CAMERA_ERROR_INVALID_PARAMETER;
3957         }
3958         sock_fd = pc->cb_info->fd;
3959         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
3960         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
3961
3962         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3963
3964         LOGD("Finish, return :%x", ret);
3965
3966         return ret;
3967 }
3968
3969 int camera_attr_set_preview_fps(camera_h camera,  camera_attr_fps_e fps)
3970 {
3971         if (camera == NULL) {
3972                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3973                 return CAMERA_ERROR_INVALID_PARAMETER;
3974         }
3975         int ret = CAMERA_ERROR_NONE;
3976         camera_cli_s *pc = (camera_cli_s *)camera;
3977         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
3978         int sock_fd;
3979         if (pc->cb_info == NULL) {
3980                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3981                 return CAMERA_ERROR_INVALID_PARAMETER;
3982         }
3983         sock_fd = pc->cb_info->fd;
3984         int set_fps = (int)fps;
3985         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3986         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_fps);
3987         LOGD("ret : 0x%x", ret);
3988         return ret;
3989 }
3990
3991
3992 int camera_attr_set_image_quality(camera_h camera,  int quality)
3993 {
3994         if (camera == NULL) {
3995                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3996                 return CAMERA_ERROR_INVALID_PARAMETER;
3997         }
3998         int ret = CAMERA_ERROR_NONE;
3999
4000         camera_cli_s *pc = (camera_cli_s *)camera;
4001         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
4002         int sock_fd;
4003         if (pc->cb_info == NULL) {
4004                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4005                 return CAMERA_ERROR_INVALID_PARAMETER;
4006         }
4007         sock_fd = pc->cb_info->fd;
4008         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4009         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, quality);
4010         LOGD("ret : 0x%x", ret);
4011         return ret;
4012 }
4013
4014 int camera_attr_get_preview_fps(camera_h camera,  camera_attr_fps_e *fps)
4015 {
4016         if (camera == NULL || fps == NULL) {
4017                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4018                 return CAMERA_ERROR_INVALID_PARAMETER;
4019         }
4020         int ret = CAMERA_ERROR_NONE;
4021
4022         camera_cli_s *pc = (camera_cli_s *)camera;
4023         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
4024         int get_fps;
4025         int sock_fd;
4026         if (pc->cb_info == NULL) {
4027                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4028                 return CAMERA_ERROR_INVALID_PARAMETER;
4029         }
4030         sock_fd = pc->cb_info->fd;
4031
4032         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4033         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4034
4035         if (ret == CAMERA_ERROR_NONE) {
4036                 muse_camera_msg_get(get_fps, pc->cb_info->recv_msg);
4037                 *fps = (camera_attr_fps_e)get_fps;
4038         }
4039         LOGD("ret : 0x%x", ret);
4040         return ret;
4041 }
4042
4043
4044 int camera_attr_get_image_quality(camera_h camera, int *quality)
4045 {
4046         if (camera == NULL || quality == NULL) {
4047                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4048                 return CAMERA_ERROR_INVALID_PARAMETER;
4049         }
4050         int ret = CAMERA_ERROR_NONE;
4051
4052         camera_cli_s *pc = (camera_cli_s *)camera;
4053         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
4054         int sock_fd;
4055         if (pc->cb_info == NULL) {
4056                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4057                 return CAMERA_ERROR_INVALID_PARAMETER;
4058         }
4059         sock_fd = pc->cb_info->fd;
4060         int get_quality;
4061         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4062         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4063
4064         if (ret == CAMERA_ERROR_NONE) {
4065                 muse_camera_msg_get(get_quality, pc->cb_info->recv_msg);
4066                 *quality = get_quality;
4067         }
4068         LOGD("ret : 0x%x", ret);
4069         return ret;
4070 }
4071
4072
4073 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
4074 {
4075         if (camera == NULL || bitrate == NULL) {
4076                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4077                 return CAMERA_ERROR_INVALID_PARAMETER;
4078         }
4079
4080         int ret = CAMERA_ERROR_NONE;
4081
4082         camera_cli_s *pc = (camera_cli_s *)camera;
4083         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
4084         int sock_fd;
4085         if (pc->cb_info == NULL) {
4086                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4087                 return CAMERA_ERROR_INVALID_PARAMETER;
4088         }
4089         sock_fd = pc->cb_info->fd;
4090         int get_bitrate;
4091
4092         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4093         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4094
4095         if (ret == CAMERA_ERROR_NONE) {
4096                 muse_camera_msg_get(get_bitrate, pc->cb_info->recv_msg);
4097                 *bitrate = get_bitrate;
4098         }
4099         LOGD("ret : 0x%x", ret);
4100         return ret;
4101 }
4102
4103
4104 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
4105 {
4106         if (camera == NULL) {
4107                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4108                 return CAMERA_ERROR_INVALID_PARAMETER;
4109         }
4110
4111         int ret = CAMERA_ERROR_NONE;
4112
4113         camera_cli_s *pc = (camera_cli_s *)camera;
4114         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
4115         int sock_fd;
4116         if (pc->cb_info == NULL) {
4117                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4118                 return CAMERA_ERROR_INVALID_PARAMETER;
4119         }
4120         sock_fd = pc->cb_info->fd;
4121         int set_bitrate = bitrate;
4122         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4123         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_bitrate);
4124         LOGD("ret : 0x%x", ret);
4125         return ret;
4126 }
4127
4128
4129 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
4130 {
4131         if (camera == NULL || interval == NULL) {
4132                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4133                 return CAMERA_ERROR_INVALID_PARAMETER;
4134         }
4135
4136         int ret = CAMERA_ERROR_NONE;
4137
4138         camera_cli_s *pc = (camera_cli_s *)camera;
4139         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
4140         int sock_fd;
4141         if (pc->cb_info == NULL) {
4142                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4143                 return CAMERA_ERROR_INVALID_PARAMETER;
4144         }
4145         sock_fd = pc->cb_info->fd;
4146         int get_gop_interval;
4147
4148         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4149         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4150
4151         if (ret == CAMERA_ERROR_NONE) {
4152                 muse_camera_msg_get(get_gop_interval, pc->cb_info->recv_msg);
4153                 *interval = get_gop_interval;
4154         }
4155         LOGD("ret : 0x%x", ret);
4156         return ret;
4157 }
4158
4159
4160 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
4161 {
4162         if (camera == NULL) {
4163                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4164                 return CAMERA_ERROR_INVALID_PARAMETER;
4165         }
4166
4167         int ret = CAMERA_ERROR_NONE;
4168
4169         camera_cli_s *pc = (camera_cli_s *)camera;
4170         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
4171         int sock_fd;
4172         if (pc->cb_info == NULL) {
4173                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4174                 return CAMERA_ERROR_INVALID_PARAMETER;
4175         }
4176         sock_fd = pc->cb_info->fd;
4177         int set_gop_interval = interval;
4178         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4179         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_gop_interval);
4180         LOGD("ret : 0x%x", ret);
4181         return ret;
4182 }
4183
4184
4185 int camera_attr_set_zoom(camera_h camera, int zoom)
4186 {
4187         if (camera == NULL) {
4188                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4189                 return CAMERA_ERROR_INVALID_PARAMETER;
4190         }
4191         int ret = CAMERA_ERROR_NONE;
4192
4193         camera_cli_s *pc = (camera_cli_s *)camera;
4194         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
4195         int sock_fd;
4196         if (pc->cb_info == NULL) {
4197                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4198                 return CAMERA_ERROR_INVALID_PARAMETER;
4199         }
4200         sock_fd = pc->cb_info->fd;
4201
4202         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4203         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, zoom);
4204         LOGD("ret : 0x%x", ret);
4205         return ret;
4206 }
4207
4208 int camera_attr_set_af_mode(camera_h camera,  camera_attr_af_mode_e mode)
4209 {
4210         if (camera == NULL) {
4211                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4212                 return CAMERA_ERROR_INVALID_PARAMETER;
4213         }
4214         int ret = CAMERA_ERROR_NONE;
4215
4216         camera_cli_s *pc = (camera_cli_s *)camera;
4217         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
4218         int sock_fd;
4219         if (pc->cb_info == NULL) {
4220                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4221                 return CAMERA_ERROR_INVALID_PARAMETER;
4222         }
4223         sock_fd = pc->cb_info->fd;
4224         int set_mode = (int)mode;
4225         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4226         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
4227         LOGD("ret : 0x%x", ret);
4228         return ret;
4229 }
4230
4231 int camera_attr_set_af_area(camera_h camera, int x, int y)
4232 {
4233         if (camera == NULL) {
4234                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4235                 return CAMERA_ERROR_INVALID_PARAMETER;
4236         }
4237         int ret = CAMERA_ERROR_NONE;
4238         camera_cli_s *pc = (camera_cli_s *)camera;
4239         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
4240         int sock_fd = pc->cb_info->fd;
4241         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4242         muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, x, INT, y);
4243         LOGD("ret : 0x%x", ret);
4244         return ret;
4245 }
4246
4247
4248 int camera_attr_clear_af_area(camera_h camera)
4249 {
4250         if (camera == NULL) {
4251                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4252                 return CAMERA_ERROR_INVALID_PARAMETER;
4253         }
4254         int ret = CAMERA_ERROR_NONE;
4255
4256         camera_cli_s *pc = (camera_cli_s *)camera;
4257         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
4258         int sock_fd;
4259         if (pc->cb_info == NULL) {
4260                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4261                 return CAMERA_ERROR_INVALID_PARAMETER;
4262         }
4263         sock_fd = pc->cb_info->fd;
4264         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4265         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4266         LOGD("ret : 0x%x", ret);
4267         return ret;
4268 }
4269
4270
4271 int camera_attr_set_exposure_mode(camera_h camera,  camera_attr_exposure_mode_e mode)
4272 {
4273         if (camera == NULL) {
4274                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4275                 return CAMERA_ERROR_INVALID_PARAMETER;
4276         }
4277
4278         if (mode < CAMERA_ATTR_EXPOSURE_MODE_OFF || mode > CAMERA_ATTR_EXPOSURE_MODE_CUSTOM) {
4279                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4280                 return CAMERA_ERROR_INVALID_PARAMETER;
4281         }
4282
4283         int ret = CAMERA_ERROR_NONE;
4284         camera_cli_s *pc = (camera_cli_s *)camera;
4285         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
4286         int set_mode = (int)mode;
4287         int sock_fd;
4288         if (pc->cb_info == NULL) {
4289                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4290                 return CAMERA_ERROR_INVALID_PARAMETER;
4291         }
4292         sock_fd = pc->cb_info->fd;
4293         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4294         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
4295         LOGD("ret : 0x%x", ret);
4296         return ret;
4297 }
4298
4299
4300 int camera_attr_set_exposure(camera_h camera, int value)
4301 {
4302         if (camera == NULL) {
4303                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4304                 return CAMERA_ERROR_INVALID_PARAMETER;
4305         }
4306         int ret = CAMERA_ERROR_NONE;
4307
4308         camera_cli_s *pc = (camera_cli_s *)camera;
4309         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
4310         int sock_fd;
4311         if (pc->cb_info == NULL) {
4312                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4313                 return CAMERA_ERROR_INVALID_PARAMETER;
4314         }
4315         sock_fd = pc->cb_info->fd;
4316
4317         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4318         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, value);
4319         LOGD("ret : 0x%x", ret);
4320         return ret;
4321 }
4322
4323
4324 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
4325 {
4326         if (camera == NULL) {
4327                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4328                 return CAMERA_ERROR_INVALID_PARAMETER;
4329         }
4330         int ret = CAMERA_ERROR_NONE;
4331
4332         camera_cli_s *pc = (camera_cli_s *)camera;
4333         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
4334         int sock_fd;
4335         if (pc->cb_info == NULL) {
4336                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4337                 return CAMERA_ERROR_INVALID_PARAMETER;
4338         }
4339         sock_fd = pc->cb_info->fd;
4340         int set_iso = (int)iso;
4341         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4342         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_iso);
4343         LOGD("ret : 0x%x", ret);
4344         return ret;
4345 }
4346
4347
4348 int camera_attr_set_brightness(camera_h camera, int level)
4349 {
4350         if (camera == NULL) {
4351                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4352                 return CAMERA_ERROR_INVALID_PARAMETER;
4353         }
4354         int ret = CAMERA_ERROR_NONE;
4355
4356         camera_cli_s *pc = (camera_cli_s *)camera;
4357         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
4358         int sock_fd;
4359         if (pc->cb_info == NULL) {
4360                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4361                 return CAMERA_ERROR_INVALID_PARAMETER;
4362         }
4363         sock_fd = pc->cb_info->fd;
4364
4365         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4366         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, level);
4367         LOGD("ret : 0x%x", ret);
4368         return ret;
4369 }
4370
4371
4372 int camera_attr_set_contrast(camera_h camera, int level)
4373 {
4374         if (camera == NULL) {
4375                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4376                 return CAMERA_ERROR_INVALID_PARAMETER;
4377         }
4378         int ret = CAMERA_ERROR_NONE;
4379
4380         camera_cli_s *pc = (camera_cli_s *)camera;
4381         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
4382         int sock_fd;
4383         if (pc->cb_info == NULL) {
4384                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4385                 return CAMERA_ERROR_INVALID_PARAMETER;
4386         }
4387         sock_fd = pc->cb_info->fd;
4388
4389         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4390         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, level);
4391         LOGD("ret : 0x%x", ret);
4392         return ret;
4393 }
4394
4395
4396 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
4397 {
4398         if (camera == NULL) {
4399                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4400                 return CAMERA_ERROR_INVALID_PARAMETER;
4401         }
4402
4403         if (wb < CAMERA_ATTR_WHITE_BALANCE_NONE || wb > CAMERA_ATTR_WHITE_BALANCE_CUSTOM) {
4404                 LOGE("invalid white balance %d", wb);
4405                 return CAMERA_ERROR_INVALID_PARAMETER;
4406         }
4407
4408         int ret = CAMERA_ERROR_NONE;
4409
4410         camera_cli_s *pc = (camera_cli_s *)camera;
4411         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
4412         int sock_fd;
4413         if (pc->cb_info == NULL) {
4414                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4415                 return CAMERA_ERROR_INVALID_PARAMETER;
4416         }
4417         sock_fd = pc->cb_info->fd;
4418         int set_whitebalance = (int)wb;
4419         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4420         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_whitebalance);
4421         LOGD("ret : 0x%x", ret);
4422         return ret;
4423 }
4424
4425
4426 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
4427 {
4428         if (camera == NULL) {
4429                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4430                 return CAMERA_ERROR_INVALID_PARAMETER;
4431         }
4432         int ret = CAMERA_ERROR_NONE;
4433
4434         camera_cli_s *pc = (camera_cli_s *)camera;
4435         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
4436         int sock_fd;
4437         if (pc->cb_info == NULL) {
4438                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4439                 return CAMERA_ERROR_INVALID_PARAMETER;
4440         }
4441         sock_fd = pc->cb_info->fd;
4442         int set_effect = (int)effect;
4443         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4444         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_effect);
4445         LOGD("ret : 0x%x", ret);
4446         return ret;
4447 }
4448
4449
4450 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
4451 {
4452         if (camera == NULL) {
4453                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4454                 return CAMERA_ERROR_INVALID_PARAMETER;
4455         }
4456         int ret = CAMERA_ERROR_NONE;
4457
4458         camera_cli_s *pc = (camera_cli_s *)camera;
4459         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
4460         int sock_fd;
4461         if (pc->cb_info == NULL) {
4462                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4463                 return CAMERA_ERROR_INVALID_PARAMETER;
4464         }
4465         sock_fd = pc->cb_info->fd;
4466         int set_mode = (int)mode;
4467         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4468         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
4469         LOGD("ret : 0x%x", ret);
4470         return ret;
4471 }
4472
4473
4474 int camera_attr_enable_tag(camera_h camera, bool enable)
4475 {
4476         if (camera == NULL) {
4477                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4478                 return CAMERA_ERROR_INVALID_PARAMETER;
4479         }
4480         int ret = CAMERA_ERROR_NONE;
4481         camera_cli_s *pc = (camera_cli_s *)camera;
4482         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4483         int sock_fd;
4484         if (pc->cb_info == NULL) {
4485                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4486                 return CAMERA_ERROR_INVALID_PARAMETER;
4487         }
4488         sock_fd = pc->cb_info->fd;
4489         int set_enable = (int)enable;
4490
4491         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4492         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable);
4493         LOGD("ret : 0x%x", ret);
4494         return ret;
4495 }
4496
4497
4498 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4499 {
4500         if (camera == NULL) {
4501                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4502                 return CAMERA_ERROR_INVALID_PARAMETER;
4503         }
4504         if (description == NULL) {
4505                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4506                 return CAMERA_ERROR_INVALID_PARAMETER;
4507         }
4508         int ret = CAMERA_ERROR_NONE;
4509         camera_cli_s *pc = (camera_cli_s *)camera;
4510         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4511         int sock_fd;
4512         if (pc->cb_info == NULL) {
4513                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4514                 return CAMERA_ERROR_INVALID_PARAMETER;
4515         }
4516         sock_fd = pc->cb_info->fd;
4517         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4518         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, STRING, description);
4519         LOGD("ret : 0x%x", ret);
4520         return ret;
4521 }
4522
4523
4524 int camera_attr_set_tag_orientation(camera_h camera,  camera_attr_tag_orientation_e orientation)
4525 {
4526         if (camera == NULL) {
4527                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4528                 return CAMERA_ERROR_INVALID_PARAMETER;
4529         }
4530         int ret = CAMERA_ERROR_NONE;
4531         camera_cli_s *pc = (camera_cli_s *)camera;
4532         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4533         int sock_fd;
4534         if (pc->cb_info == NULL) {
4535                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4536                 return CAMERA_ERROR_INVALID_PARAMETER;
4537         }
4538         sock_fd = pc->cb_info->fd;
4539         int set_orientation = (int)orientation;
4540
4541         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4542         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_orientation);
4543         LOGD("ret : 0x%x", ret);
4544         return ret;
4545 }
4546
4547
4548 int camera_attr_set_tag_software(camera_h camera,  const char *software)
4549 {
4550         if (camera == NULL) {
4551                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4552                 return CAMERA_ERROR_INVALID_PARAMETER;
4553         }
4554         if (software == NULL) {
4555                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4556                 return CAMERA_ERROR_INVALID_PARAMETER;
4557         }
4558         int ret = CAMERA_ERROR_NONE;
4559         camera_cli_s *pc = (camera_cli_s *)camera;
4560         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4561         int sock_fd;
4562         if (pc->cb_info == NULL) {
4563                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4564                 return CAMERA_ERROR_INVALID_PARAMETER;
4565         }
4566         sock_fd = pc->cb_info->fd;
4567         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4568         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, STRING, software);
4569         LOGD("ret : 0x%x", ret);
4570         return ret;
4571 }
4572
4573
4574 int camera_attr_set_geotag(camera_h camera, double latitude , double longitude, double altitude)
4575 {
4576         if (camera == NULL) {
4577                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4578                 return CAMERA_ERROR_INVALID_PARAMETER;
4579         }
4580         int ret = CAMERA_ERROR_NONE;
4581         camera_cli_s *pc = (camera_cli_s *)camera;
4582         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4583         int sock_fd;
4584         if (pc->cb_info == NULL) {
4585                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4586                 return CAMERA_ERROR_INVALID_PARAMETER;
4587         }
4588         sock_fd = pc->cb_info->fd;
4589         double set_geotag[3] = { latitude, longitude, altitude };
4590
4591         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4592         muse_camera_msg_send_array(api, sock_fd, pc->cb_info, ret,
4593                                                                         set_geotag, sizeof(set_geotag), sizeof(double));
4594         LOGD("ret : 0x%x", ret);
4595         return ret;
4596 }
4597
4598
4599 int camera_attr_remove_geotag(camera_h camera)
4600 {
4601         if (camera == NULL) {
4602                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4603                 return CAMERA_ERROR_INVALID_PARAMETER;
4604         }
4605         int ret = CAMERA_ERROR_NONE;
4606         camera_cli_s *pc = (camera_cli_s *)camera;
4607         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4608         int sock_fd;
4609         if (pc->cb_info == NULL) {
4610                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4611                 return CAMERA_ERROR_INVALID_PARAMETER;
4612         }
4613         sock_fd = pc->cb_info->fd;
4614         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4615         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4616         LOGD("ret : 0x%x", ret);
4617         return ret;
4618 }
4619
4620
4621 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4622 {
4623         if (camera == NULL) {
4624                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4625                 return CAMERA_ERROR_INVALID_PARAMETER;
4626         }
4627         int ret = CAMERA_ERROR_NONE;
4628         camera_cli_s *pc = (camera_cli_s *)camera;
4629         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
4630         int sock_fd;
4631         if (pc->cb_info == NULL) {
4632                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4633                 return CAMERA_ERROR_INVALID_PARAMETER;
4634         }
4635         sock_fd = pc->cb_info->fd;
4636         int set_mode = (int)mode;
4637
4638         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4639         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
4640         LOGD("ret : 0x%x", ret);
4641         return ret;
4642 }
4643
4644
4645 int camera_attr_get_zoom(camera_h camera, int *zoom)
4646 {
4647         if (camera == NULL || zoom == NULL) {
4648                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4649                 return CAMERA_ERROR_INVALID_PARAMETER;
4650         }
4651         int ret = CAMERA_ERROR_NONE;
4652
4653         camera_cli_s *pc = (camera_cli_s *)camera;
4654         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4655         int get_zoom;
4656         int sock_fd;
4657         if (pc->cb_info == NULL) {
4658                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4659                 return CAMERA_ERROR_INVALID_PARAMETER;
4660         }
4661         sock_fd = pc->cb_info->fd;
4662
4663         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4664         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4665
4666         if (ret == CAMERA_ERROR_NONE) {
4667                 muse_camera_msg_get(get_zoom, pc->cb_info->recv_msg);
4668                 *zoom = get_zoom;
4669         }
4670         LOGD("ret : 0x%x", ret);
4671         return ret;
4672 }
4673
4674
4675 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
4676 {
4677         if (camera == NULL || min == NULL || max == NULL) {
4678                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4679                 return CAMERA_ERROR_INVALID_PARAMETER;
4680         }
4681         int ret = CAMERA_ERROR_NONE;
4682         camera_cli_s *pc = (camera_cli_s *)camera;
4683         int sock_fd;
4684         if (pc->cb_info == NULL) {
4685                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4686                 return CAMERA_ERROR_INVALID_PARAMETER;
4687         }
4688         sock_fd = pc->cb_info->fd;
4689         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
4690         int get_min;
4691         int get_max;
4692
4693         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4694         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4695
4696         if (ret == CAMERA_ERROR_NONE) {
4697                 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
4698                 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
4699                 *min = get_min;
4700                 *max = get_max;
4701         }
4702         LOGD("ret : 0x%x", ret);
4703         return ret;
4704 }
4705
4706
4707 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
4708 {
4709         if (camera == NULL || mode == NULL) {
4710                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4711                 return CAMERA_ERROR_INVALID_PARAMETER;
4712         }
4713         int ret = CAMERA_ERROR_NONE;
4714         camera_cli_s *pc = (camera_cli_s *)camera;
4715         int sock_fd;
4716         if (pc->cb_info == NULL) {
4717                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4718                 return CAMERA_ERROR_INVALID_PARAMETER;
4719         }
4720         sock_fd = pc->cb_info->fd;
4721         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
4722         int get_mode;
4723
4724         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4725         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4726
4727         if (ret == CAMERA_ERROR_NONE) {
4728                 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
4729                 *mode = (camera_attr_af_mode_e)get_mode;
4730         }
4731         LOGD("ret : 0x%x", ret);
4732         return ret;
4733 }
4734
4735
4736 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
4737 {
4738         if (camera == NULL || mode == NULL) {
4739                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4740                 return CAMERA_ERROR_INVALID_PARAMETER;
4741         }
4742         int ret = CAMERA_ERROR_NONE;
4743         camera_cli_s *pc = (camera_cli_s *)camera;
4744         int sock_fd;
4745         if (pc->cb_info == NULL) {
4746                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4747                 return CAMERA_ERROR_INVALID_PARAMETER;
4748         }
4749         sock_fd = pc->cb_info->fd;
4750         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
4751         int get_mode;
4752
4753         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4754         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4755
4756         if (ret == CAMERA_ERROR_NONE) {
4757                 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
4758                 *mode = (camera_attr_exposure_mode_e)get_mode;
4759         }
4760         LOGD("ret : 0x%x", ret);
4761         return ret;
4762 }
4763
4764 int camera_attr_get_exposure(camera_h camera, int *value)
4765 {
4766         if (camera == NULL || value == NULL) {
4767                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4768                 return CAMERA_ERROR_INVALID_PARAMETER;
4769         }
4770         int ret = CAMERA_ERROR_NONE;
4771         camera_cli_s *pc = (camera_cli_s *)camera;
4772         int sock_fd;
4773         if (pc->cb_info == NULL) {
4774                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4775                 return CAMERA_ERROR_INVALID_PARAMETER;
4776         }
4777         sock_fd = pc->cb_info->fd;
4778         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
4779         int get_value;
4780
4781         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4782         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4783
4784         if (ret == CAMERA_ERROR_NONE) {
4785                 muse_camera_msg_get(get_value, pc->cb_info->recv_msg);
4786                 *value = get_value;
4787         }
4788         LOGD("ret : 0x%x", ret);
4789         return ret;
4790 }
4791
4792
4793 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
4794 {
4795         if (camera == NULL || min == NULL || max == NULL) {
4796                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4797                 return CAMERA_ERROR_INVALID_PARAMETER;
4798         }
4799         int ret = CAMERA_ERROR_NONE;
4800         camera_cli_s *pc = (camera_cli_s *)camera;
4801         int sock_fd;
4802         if (pc->cb_info == NULL) {
4803                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4804                 return CAMERA_ERROR_INVALID_PARAMETER;
4805         }
4806         sock_fd = pc->cb_info->fd;
4807         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
4808         int get_min;
4809         int get_max;
4810
4811         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4812         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4813
4814         if (ret == CAMERA_ERROR_NONE) {
4815                 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
4816                 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
4817                 *min = get_min;
4818                 *max = get_max;
4819         }
4820         LOGD("ret : 0x%x", ret);
4821         return ret;
4822 }
4823
4824
4825 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
4826 {
4827         if (camera == NULL || iso == NULL) {
4828                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4829                 return CAMERA_ERROR_INVALID_PARAMETER;
4830         }
4831         int ret = CAMERA_ERROR_NONE;
4832         camera_cli_s *pc = (camera_cli_s *)camera;
4833         int sock_fd;
4834         if (pc->cb_info == NULL) {
4835                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4836                 return CAMERA_ERROR_INVALID_PARAMETER;
4837         }
4838         sock_fd = pc->cb_info->fd;
4839         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
4840         int get_iso;
4841
4842         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4843         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4844
4845         if (ret == CAMERA_ERROR_NONE) {
4846                 muse_camera_msg_get(get_iso, pc->cb_info->recv_msg);
4847                 *iso = (camera_attr_iso_e)get_iso;
4848         }
4849         LOGD("ret : 0x%x", ret);
4850         return ret;
4851 }
4852
4853
4854 int camera_attr_get_brightness(camera_h camera,  int *level)
4855 {
4856         if (camera == NULL || level == NULL) {
4857                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4858                 return CAMERA_ERROR_INVALID_PARAMETER;
4859         }
4860         int ret = CAMERA_ERROR_NONE;
4861         camera_cli_s *pc = (camera_cli_s *)camera;
4862         int sock_fd;
4863         if (pc->cb_info == NULL) {
4864                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4865                 return CAMERA_ERROR_INVALID_PARAMETER;
4866         }
4867         sock_fd = pc->cb_info->fd;
4868         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
4869         int get_level;
4870
4871         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4872         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4873
4874         if (ret == CAMERA_ERROR_NONE) {
4875                 muse_camera_msg_get(get_level, pc->cb_info->recv_msg);
4876                 *level = get_level;
4877         }
4878         LOGD("ret : 0x%x", ret);
4879         return ret;
4880 }
4881
4882
4883 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
4884 {
4885         if (camera == NULL || min == NULL || max == NULL) {
4886                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4887                 return CAMERA_ERROR_INVALID_PARAMETER;
4888         }
4889         int ret = CAMERA_ERROR_NONE;
4890         camera_cli_s *pc = (camera_cli_s *)camera;
4891         int sock_fd;
4892         if (pc->cb_info == NULL) {
4893                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4894                 return CAMERA_ERROR_INVALID_PARAMETER;
4895         }
4896         sock_fd = pc->cb_info->fd;
4897         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
4898         int get_min;
4899         int get_max;
4900
4901         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4902         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4903
4904         if (ret == CAMERA_ERROR_NONE) {
4905                 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
4906                 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
4907                 *min = get_min;
4908                 *max = get_max;
4909         }
4910         LOGD("ret : 0x%x", ret);
4911         return ret;
4912 }
4913
4914
4915 int camera_attr_get_contrast(camera_h camera,  int *level)
4916 {
4917         if (camera == NULL || level == NULL) {
4918                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4919                 return CAMERA_ERROR_INVALID_PARAMETER;
4920         }
4921         int ret = CAMERA_ERROR_NONE;
4922         camera_cli_s *pc = (camera_cli_s *)camera;
4923         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
4924         int sock_fd;
4925         if (pc->cb_info == NULL) {
4926                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4927                 return CAMERA_ERROR_INVALID_PARAMETER;
4928         }
4929         sock_fd = pc->cb_info->fd;
4930         int get_level;
4931
4932         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4933         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4934
4935         if (ret == CAMERA_ERROR_NONE) {
4936                 muse_camera_msg_get(get_level, pc->cb_info->recv_msg);
4937                 *level = get_level;
4938         }
4939         LOGD("ret : 0x%x", ret);
4940         return ret;
4941 }
4942
4943
4944 int camera_attr_get_contrast_range(camera_h camera, int *min , int *max)
4945 {
4946         if (camera == NULL || min == NULL || max == NULL) {
4947                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4948                 return CAMERA_ERROR_INVALID_PARAMETER;
4949         }
4950         int ret = CAMERA_ERROR_NONE;
4951         camera_cli_s *pc = (camera_cli_s *)camera;
4952         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
4953         int sock_fd;
4954         if (pc->cb_info == NULL) {
4955                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4956                 return CAMERA_ERROR_INVALID_PARAMETER;
4957         }
4958         sock_fd = pc->cb_info->fd;
4959         int get_min;
4960         int get_max;
4961
4962         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4963         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4964
4965         if (ret == CAMERA_ERROR_NONE) {
4966                 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
4967                 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
4968                 *min = get_min;
4969                 *max = get_max;
4970         }
4971         LOGD("ret : 0x%x", ret);
4972         return ret;
4973 }
4974
4975
4976 int camera_attr_get_whitebalance(camera_h camera,  camera_attr_whitebalance_e *wb)
4977 {
4978         if (camera == NULL || wb == NULL) {
4979                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4980                 return CAMERA_ERROR_INVALID_PARAMETER;
4981         }
4982         int ret = CAMERA_ERROR_NONE;
4983         camera_cli_s *pc = (camera_cli_s *)camera;
4984         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
4985         int sock_fd;
4986         if (pc->cb_info == NULL) {
4987                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4988                 return CAMERA_ERROR_INVALID_PARAMETER;
4989         }
4990         sock_fd = pc->cb_info->fd;
4991         int get_wb;
4992
4993         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4994         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4995
4996         if (ret == CAMERA_ERROR_NONE) {
4997                 muse_camera_msg_get(get_wb, pc->cb_info->recv_msg);
4998                 *wb = (camera_attr_whitebalance_e)get_wb;
4999         }
5000         LOGD("ret : 0x%x", ret);
5001         return ret;
5002 }
5003
5004
5005 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
5006 {
5007         if (camera == NULL || effect == NULL) {
5008                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5009                 return CAMERA_ERROR_INVALID_PARAMETER;
5010         }
5011
5012         int ret = CAMERA_ERROR_NONE;
5013         camera_cli_s *pc = (camera_cli_s *)camera;
5014         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
5015         int sock_fd;
5016         if (pc->cb_info == NULL) {
5017                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5018                 return CAMERA_ERROR_INVALID_PARAMETER;
5019         }
5020         sock_fd = pc->cb_info->fd;
5021         int get_effect;
5022
5023         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5024         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5025
5026         if (ret == CAMERA_ERROR_NONE) {
5027                 muse_camera_msg_get(get_effect, pc->cb_info->recv_msg);
5028                 *effect = (camera_attr_effect_mode_e)get_effect;
5029         }
5030         LOGD("ret : 0x%x", ret);
5031         return ret;
5032 }
5033
5034
5035 int camera_attr_get_scene_mode(camera_h camera,  camera_attr_scene_mode_e *mode)
5036 {
5037         if (camera == NULL || mode == NULL) {
5038                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5039                 return CAMERA_ERROR_INVALID_PARAMETER;
5040         }
5041
5042         int ret = CAMERA_ERROR_NONE;
5043         camera_cli_s *pc = (camera_cli_s *)camera;
5044         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
5045         int sock_fd;
5046         if (pc->cb_info == NULL) {
5047                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5048                 return CAMERA_ERROR_INVALID_PARAMETER;
5049         }
5050         sock_fd = pc->cb_info->fd;
5051         int get_mode;
5052
5053         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5054         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5055
5056         if (ret == CAMERA_ERROR_NONE) {
5057                 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
5058                 *mode = (camera_attr_scene_mode_e)get_mode;
5059         }
5060         LOGD("ret : 0x%x", ret);
5061         return ret;
5062 }
5063
5064
5065 int camera_attr_is_enabled_tag(camera_h camera,  bool *enable)
5066 {
5067         if (camera == NULL || enable == NULL) {
5068                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5069                 return CAMERA_ERROR_INVALID_PARAMETER;
5070         }
5071
5072         int ret = CAMERA_ERROR_NONE;
5073         camera_cli_s *pc = (camera_cli_s *)camera;
5074         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
5075         int sock_fd;
5076         if (pc->cb_info == NULL) {
5077                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5078                 return CAMERA_ERROR_INVALID_PARAMETER;
5079         }
5080         sock_fd = pc->cb_info->fd;
5081         int get_enabled;
5082
5083         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5084         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5085
5086         if (ret == CAMERA_ERROR_NONE) {
5087                 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
5088                 *enable = (bool)get_enabled;
5089         }
5090         LOGD("ret : 0x%x", ret);
5091         return ret;
5092 }
5093
5094
5095 int camera_attr_get_tag_image_description(camera_h camera,  char **description)
5096 {
5097         if (camera == NULL || description == NULL) {
5098                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5099                 return CAMERA_ERROR_INVALID_PARAMETER;
5100         }
5101
5102         int ret = CAMERA_ERROR_NONE;
5103         camera_cli_s *pc = (camera_cli_s *)camera;
5104         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
5105         int sock_fd;
5106         if (pc->cb_info == NULL) {
5107                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5108                 return CAMERA_ERROR_INVALID_PARAMETER;
5109         }
5110         sock_fd = pc->cb_info->fd;
5111         char get_description[MUSE_CAMERA_MSG_MAX_LENGTH] = {0,};
5112
5113         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5114         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5115
5116         if (ret == CAMERA_ERROR_NONE) {
5117                 muse_camera_msg_get_string(get_description, pc->cb_info->recv_msg);
5118                 *description = strdup(get_description);
5119         }
5120         LOGD("ret : 0x%x", ret);
5121         return ret;
5122 }
5123
5124
5125 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
5126 {
5127         if (camera == NULL || orientation == NULL) {
5128                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5129                 return CAMERA_ERROR_INVALID_PARAMETER;
5130         }
5131
5132         int ret = CAMERA_ERROR_NONE;
5133         camera_cli_s *pc = (camera_cli_s *)camera;
5134         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
5135         int sock_fd;
5136         if (pc->cb_info == NULL) {
5137                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5138                 return CAMERA_ERROR_INVALID_PARAMETER;
5139         }
5140         sock_fd = pc->cb_info->fd;
5141         int get_orientation;
5142
5143         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5144         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5145
5146         if (ret == CAMERA_ERROR_NONE) {
5147                 muse_camera_msg_get(get_orientation, pc->cb_info->recv_msg);
5148                 *orientation = (camera_attr_tag_orientation_e)get_orientation;
5149                 LOGD("success, orientation : %d", *orientation);
5150         }
5151         LOGD("ret : 0x%x", ret);
5152         return ret;
5153 }
5154
5155
5156 int camera_attr_get_tag_software(camera_h camera, char **software)
5157 {
5158         if (camera == NULL || software == NULL) {
5159                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5160                 return CAMERA_ERROR_INVALID_PARAMETER;
5161         }
5162
5163         int ret = CAMERA_ERROR_NONE;
5164         camera_cli_s *pc = (camera_cli_s *)camera;
5165         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
5166         int sock_fd;
5167         if (pc->cb_info == NULL) {
5168                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5169                 return CAMERA_ERROR_INVALID_PARAMETER;
5170         }
5171         sock_fd = pc->cb_info->fd;
5172         char get_software[MUSE_CAMERA_MSG_MAX_LENGTH] = {0,};
5173
5174         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5175         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5176
5177         if (ret == CAMERA_ERROR_NONE) {
5178                 muse_camera_msg_get_string(get_software, pc->cb_info->recv_msg);
5179                 *software = strdup(get_software);
5180         }
5181         LOGD("ret : 0x%x", ret);
5182         return ret;
5183 }
5184
5185
5186 int camera_attr_get_geotag(camera_h camera, double *latitude , double *longitude, double *altitude)
5187 {
5188         if (camera == NULL || latitude == NULL || longitude == NULL || altitude == NULL) {
5189                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5190                 return CAMERA_ERROR_INVALID_PARAMETER;
5191         }
5192
5193         int ret = CAMERA_ERROR_NONE;
5194         camera_cli_s *pc = (camera_cli_s *)camera;
5195         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
5196         double get_geotag[3] = {0,};
5197         int sock_fd;
5198         if (pc->cb_info == NULL) {
5199                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5200                 return CAMERA_ERROR_INVALID_PARAMETER;
5201         }
5202         sock_fd = pc->cb_info->fd;
5203
5204         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5205
5206         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5207
5208         if (ret == CAMERA_ERROR_NONE) {
5209                 muse_camera_msg_get_array(get_geotag, pc->cb_info->recv_msg);
5210                 *latitude = get_geotag[0];
5211                 *longitude = get_geotag[1];
5212                 *altitude = get_geotag[2];
5213
5214                 LOGD("ret : 0x%x", ret);
5215         } else {
5216                 LOGE("Returned value is not valid : 0x%x", ret);
5217         }
5218
5219         return ret;
5220 }
5221
5222
5223 int camera_attr_get_flash_mode(camera_h camera,  camera_attr_flash_mode_e *mode)
5224 {
5225         if (camera == NULL || mode == NULL) {
5226                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5227                 return CAMERA_ERROR_INVALID_PARAMETER;
5228         }
5229
5230         int ret = CAMERA_ERROR_NONE;
5231         camera_cli_s *pc = (camera_cli_s *)camera;
5232         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
5233         int sock_fd;
5234         if (pc->cb_info == NULL) {
5235                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5236                 return CAMERA_ERROR_INVALID_PARAMETER;
5237         }
5238         sock_fd = pc->cb_info->fd;
5239         int get_mode;
5240
5241         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5242         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5243
5244         if (ret == CAMERA_ERROR_NONE) {
5245                 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
5246                 *mode = (camera_attr_flash_mode_e)get_mode;
5247         }
5248         LOGD("ret : 0x%x", ret);
5249         return ret;
5250 }
5251
5252
5253 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
5254 {
5255         int sock_fd = -1;
5256         char *sndMsg;
5257         int ret = CAMERA_ERROR_NONE;
5258         camera_cli_s *pc = NULL;
5259         int get_flash_state = 0;
5260
5261         /* create muse connection */
5262         muse_camera_api_e api = MUSE_CAMERA_API_GET_FLASH_STATE;
5263         muse_core_api_module_e muse_module = MUSE_CAMERA;
5264         int device_type = (int)device;
5265
5266         if (state == NULL) {
5267                 LOGE("invalid pointer for state");
5268                 return CAMERA_ERROR_INVALID_PARAMETER;
5269         }
5270
5271         sock_fd = muse_core_client_new();
5272         if (sock_fd < 0) {
5273                 LOGE("muse_core_client_new failed - returned fd %d", sock_fd);
5274                 ret = CAMERA_ERROR_INVALID_OPERATION;
5275                 goto Exit;
5276         }
5277
5278         sndMsg = muse_core_msg_json_factory_new(api,
5279                 MUSE_TYPE_INT, "module", muse_module,
5280                 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
5281                 0);
5282
5283         muse_core_ipc_send_msg(sock_fd, sndMsg);
5284         muse_core_msg_json_factory_free(sndMsg);
5285
5286         pc = g_new0(camera_cli_s, 1);
5287         if (pc == NULL) {
5288                 LOGE("camera_cli_s alloc failed");
5289                 ret = CAMERA_ERROR_OUT_OF_MEMORY;
5290                 goto Exit;
5291         }
5292
5293         pc->cb_info = _client_callback_new(sock_fd);
5294         if (pc->cb_info == NULL) {
5295                 LOGE("cb_info alloc failed");
5296                 ret = CAMERA_ERROR_OUT_OF_MEMORY;
5297                 goto Exit;
5298         }
5299
5300         ret = _client_wait_for_cb_return(api, pc->cb_info, CALLBACK_TIME_OUT);
5301
5302         if (ret == CAMERA_ERROR_NONE) {
5303                 muse_camera_msg_get(get_flash_state, pc->cb_info->recv_msg);
5304                 *state = (camera_flash_state_e)get_flash_state;
5305         }
5306
5307         LOGD("Flash state : %d\n", *state);
5308
5309 Exit:
5310         /* release resources */
5311         if (pc) {
5312                 g_atomic_int_set(&pc->cb_info->msg_recv_running, 0);
5313                 g_atomic_int_set(&pc->cb_info->msg_handler_running, 0);
5314                 _client_callback_destroy(pc->cb_info);
5315                 pc->cb_info = NULL;
5316                 g_free(pc);
5317                 pc = NULL;
5318         }
5319
5320         return ret;
5321 }
5322
5323
5324 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
5325 {
5326         if (camera == NULL || foreach_cb == NULL) {
5327                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5328                 return CAMERA_ERROR_INVALID_PARAMETER;
5329         }
5330         int ret = CAMERA_ERROR_NONE;
5331
5332         camera_cli_s *pc = (camera_cli_s *)camera;
5333         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
5334
5335         LOGD("Enter, handle :%x", pc->remote_handle);
5336
5337         int sock_fd;
5338         if (pc->cb_info == NULL) {
5339                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5340                 return CAMERA_ERROR_INVALID_PARAMETER;
5341         }
5342         sock_fd = pc->cb_info->fd;
5343         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
5344         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
5345
5346         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5347         LOGD("ret : 0x%x", ret);
5348         return ret;
5349 }
5350
5351
5352 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb , void *user_data)
5353 {
5354         if (camera == NULL || foreach_cb == NULL) {
5355                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5356                 return CAMERA_ERROR_INVALID_PARAMETER;
5357         }
5358         int ret = CAMERA_ERROR_NONE;
5359
5360         camera_cli_s *pc = (camera_cli_s *)camera;
5361         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
5362
5363         LOGD("Enter, handle :%x", pc->remote_handle);
5364
5365         int sock_fd;
5366         if (pc->cb_info == NULL) {
5367                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5368                 return CAMERA_ERROR_INVALID_PARAMETER;
5369         }
5370         sock_fd = pc->cb_info->fd;
5371         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
5372         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
5373
5374         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5375         LOGD("ret : 0x%x", ret);
5376         return ret;
5377 }
5378
5379
5380 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
5381 {
5382         if (camera == NULL || foreach_cb == NULL) {
5383                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5384                 return CAMERA_ERROR_INVALID_PARAMETER;
5385         }
5386         int ret = CAMERA_ERROR_NONE;
5387
5388         camera_cli_s *pc = (camera_cli_s *)camera;
5389         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
5390
5391         LOGD("Enter, handle :%x", pc->remote_handle);
5392
5393         int sock_fd;
5394         if (pc->cb_info == NULL) {
5395                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5396                 return CAMERA_ERROR_INVALID_PARAMETER;
5397         }
5398         sock_fd = pc->cb_info->fd;
5399         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
5400         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
5401
5402         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5403         LOGD("ret : 0x%x", ret);
5404         return ret;
5405 }
5406
5407
5408 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb , void *user_data)
5409 {
5410         if (camera == NULL || foreach_cb == NULL) {
5411                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5412                 return CAMERA_ERROR_INVALID_PARAMETER;
5413         }
5414         int ret = CAMERA_ERROR_NONE;
5415
5416         camera_cli_s *pc = (camera_cli_s *)camera;
5417         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
5418
5419         LOGD("Enter, handle :%x", pc->remote_handle);
5420
5421         int sock_fd;
5422         if (pc->cb_info == NULL) {
5423                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5424                 return CAMERA_ERROR_INVALID_PARAMETER;
5425         }
5426         sock_fd = pc->cb_info->fd;
5427         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
5428         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
5429
5430         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5431         LOGD("ret : 0x%x", ret);
5432         return ret;
5433 }
5434
5435
5436 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb , void *user_data)
5437 {
5438         if (camera == NULL || foreach_cb == NULL) {
5439                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5440                 return CAMERA_ERROR_INVALID_PARAMETER;
5441         }
5442         int ret = CAMERA_ERROR_NONE;
5443
5444         camera_cli_s *pc = (camera_cli_s *)camera;
5445         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
5446
5447         LOGD("Enter, handle :%x", pc->remote_handle);
5448
5449         int sock_fd;
5450         if (pc->cb_info == NULL) {
5451                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5452                 return CAMERA_ERROR_INVALID_PARAMETER;
5453         }
5454         sock_fd = pc->cb_info->fd;
5455         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
5456         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
5457
5458         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5459         LOGD("ret : 0x%x", ret);
5460         return ret;
5461 }
5462
5463
5464 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb , void *user_data)
5465 {
5466         if (camera == NULL || foreach_cb == NULL) {
5467                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5468                 return CAMERA_ERROR_INVALID_PARAMETER;
5469         }
5470         int ret = CAMERA_ERROR_NONE;
5471
5472         camera_cli_s *pc = (camera_cli_s *)camera;
5473         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
5474
5475         LOGD("Enter, handle :%x", pc->remote_handle);
5476
5477         int sock_fd;
5478         if (pc->cb_info == NULL) {
5479                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5480                 return CAMERA_ERROR_INVALID_PARAMETER;
5481         }
5482         sock_fd = pc->cb_info->fd;
5483         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
5484         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
5485
5486         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5487         LOGD("ret : 0x%x", ret);
5488         return ret;
5489 }
5490
5491
5492 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb , void *user_data)
5493 {
5494         if (camera == NULL || foreach_cb == NULL) {
5495                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5496                 return CAMERA_ERROR_INVALID_PARAMETER;
5497         }
5498         int ret = CAMERA_ERROR_NONE;
5499
5500         camera_cli_s *pc = (camera_cli_s *)camera;
5501         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5502
5503         LOGD("Enter, handle :%x", pc->remote_handle);
5504
5505         int sock_fd;
5506         if (pc->cb_info == NULL) {
5507                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5508                 return CAMERA_ERROR_INVALID_PARAMETER;
5509         }
5510         sock_fd = pc->cb_info->fd;
5511         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5512         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5513
5514         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5515         LOGD("ret : 0x%x", ret);
5516         return ret;
5517 }
5518
5519
5520 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb , void *user_data)
5521 {
5522         if (camera == NULL || foreach_cb == NULL) {
5523                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5524                 return CAMERA_ERROR_INVALID_PARAMETER;
5525         }
5526         int ret = CAMERA_ERROR_NONE;
5527
5528         camera_cli_s *pc = (camera_cli_s *)camera;
5529         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5530         int sock_fd;
5531         if (pc->cb_info == NULL) {
5532                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5533                 return CAMERA_ERROR_INVALID_PARAMETER;
5534         }
5535         sock_fd = pc->cb_info->fd;
5536         LOGD("Enter, handle :%x", pc->remote_handle);
5537         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5538         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5539
5540         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5541         LOGD("Enter, handle :%x", pc->remote_handle);
5542         return ret;
5543 }
5544
5545 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)
5546 {
5547         if (camera == NULL || foreach_cb == NULL) {
5548                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5549                 return CAMERA_ERROR_INVALID_PARAMETER;
5550         }
5551         int ret = CAMERA_ERROR_NONE;
5552
5553         camera_cli_s *pc = (camera_cli_s *)camera;
5554         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5555         int sock_fd;
5556         if (pc->cb_info == NULL) {
5557                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5558                 return CAMERA_ERROR_INVALID_PARAMETER;
5559         }
5560         sock_fd = pc->cb_info->fd;
5561         LOGD("Enter, handle :%x", pc->remote_handle);
5562         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5563         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5564
5565         muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, width, INT, height);
5566         LOGD("ret : 0x%x", ret);
5567         return ret;
5568 }
5569
5570 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5571 {
5572         if (camera == NULL || foreach_cb == NULL) {
5573                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5574                 return CAMERA_ERROR_INVALID_PARAMETER;
5575         }
5576         int ret = CAMERA_ERROR_NONE;
5577
5578         camera_cli_s *pc = (camera_cli_s *)camera;
5579         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5580         int sock_fd;
5581         if (pc->cb_info == NULL) {
5582                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5583                 return CAMERA_ERROR_INVALID_PARAMETER;
5584         }
5585         sock_fd = pc->cb_info->fd;
5586         LOGD("Enter, handle :%x", pc->remote_handle);
5587         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5588         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5589
5590         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5591         LOGD("ret : 0x%x", ret);
5592         return ret;
5593 }
5594
5595
5596 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5597 {
5598         if (camera == NULL || foreach_cb == NULL) {
5599                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5600                 return CAMERA_ERROR_INVALID_PARAMETER;
5601         }
5602         int ret = CAMERA_ERROR_NONE;
5603
5604         camera_cli_s *pc = (camera_cli_s *)camera;
5605         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5606         int sock_fd;
5607         if (pc->cb_info == NULL) {
5608                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5609                 return CAMERA_ERROR_INVALID_PARAMETER;
5610         }
5611         sock_fd = pc->cb_info->fd;
5612         LOGD("Enter, handle :%x", pc->remote_handle);
5613         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5614         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5615
5616         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5617         LOGD("ret : 0x%x", ret);
5618         return ret;
5619 }
5620
5621
5622 int camera_attr_set_stream_rotation(camera_h camera , camera_rotation_e rotation)
5623 {
5624         if (camera == NULL) {
5625                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5626                 return CAMERA_ERROR_INVALID_PARAMETER;
5627         }
5628
5629         int ret = CAMERA_ERROR_NONE;
5630         camera_cli_s *pc = (camera_cli_s *)camera;
5631         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5632         int sock_fd;
5633         if (pc->cb_info == NULL) {
5634                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5635                 return CAMERA_ERROR_INVALID_PARAMETER;
5636         }
5637         sock_fd = pc->cb_info->fd;
5638         int set_rotation = (int)rotation;
5639
5640         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5641         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_rotation);
5642         LOGD("ret : 0x%x", ret);
5643         return ret;
5644 }
5645
5646
5647 int camera_attr_get_stream_rotation(camera_h camera , camera_rotation_e *rotation)
5648 {
5649         if (camera == NULL || rotation == NULL) {
5650                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5651                 return CAMERA_ERROR_INVALID_PARAMETER;
5652         }
5653
5654         int ret = CAMERA_ERROR_NONE;
5655         camera_cli_s *pc = (camera_cli_s *)camera;
5656         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5657         int sock_fd;
5658         if (pc->cb_info == NULL) {
5659                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5660                 return CAMERA_ERROR_INVALID_PARAMETER;
5661         }
5662         sock_fd = pc->cb_info->fd;
5663         int get_rotation;
5664
5665         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5666         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5667
5668         if (ret == CAMERA_ERROR_NONE) {
5669                 muse_camera_msg_get(get_rotation, pc->cb_info->recv_msg);
5670                 *rotation = (camera_rotation_e)get_rotation;
5671         }
5672         LOGD("ret : 0x%x", ret);
5673         return ret;
5674 }
5675
5676
5677 int camera_attr_set_stream_flip(camera_h camera , camera_flip_e flip)
5678 {
5679         if (camera == NULL) {
5680                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5681                 return CAMERA_ERROR_INVALID_PARAMETER;
5682         }
5683
5684         int ret = CAMERA_ERROR_NONE;
5685         camera_cli_s *pc = (camera_cli_s *)camera;
5686         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5687         int sock_fd;
5688         if (pc->cb_info == NULL) {
5689                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5690                 return CAMERA_ERROR_INVALID_PARAMETER;
5691         }
5692         sock_fd = pc->cb_info->fd;
5693         int set_flip = (int)flip;
5694
5695         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5696         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_flip);
5697         LOGD("ret : 0x%x", ret);
5698         return ret;
5699 }
5700
5701
5702 int camera_attr_get_stream_flip(camera_h camera , camera_flip_e *flip)
5703 {
5704         if (camera == NULL || flip == NULL) {
5705                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5706                 return CAMERA_ERROR_INVALID_PARAMETER;
5707         }
5708
5709         int ret = CAMERA_ERROR_NONE;
5710         camera_cli_s *pc = (camera_cli_s *)camera;
5711         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5712         int sock_fd;
5713         if (pc->cb_info == NULL) {
5714                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5715                 return CAMERA_ERROR_INVALID_PARAMETER;
5716         }
5717         sock_fd = pc->cb_info->fd;
5718         int get_flip;
5719
5720         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5721         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5722
5723         if (ret == CAMERA_ERROR_NONE) {
5724                 muse_camera_msg_get(get_flip, pc->cb_info->recv_msg);
5725                 *flip = (camera_flip_e)get_flip;
5726         }
5727         LOGD("ret : 0x%x", ret);
5728         return ret;
5729 }
5730
5731 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5732 {
5733         if (camera == NULL) {
5734                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5735                 return CAMERA_ERROR_INVALID_PARAMETER;
5736         }
5737
5738         int ret = CAMERA_ERROR_NONE;
5739         camera_cli_s *pc = (camera_cli_s *)camera;
5740         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5741         int sock_fd;
5742         if (pc->cb_info == NULL) {
5743                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5744                 return CAMERA_ERROR_INVALID_PARAMETER;
5745         }
5746         sock_fd = pc->cb_info->fd;
5747         int set_mode = (int)mode;
5748
5749         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5750         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
5751         LOGD("ret : 0x%x", ret);
5752         return ret;
5753 }
5754
5755
5756 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5757 {
5758         if (camera == NULL) {
5759                 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
5760                 return CAMERA_ERROR_INVALID_PARAMETER;
5761         }
5762         if (mode == NULL) {
5763                 LOGE("INVALID_PARAMETER(0x%08x) - mode", CAMERA_ERROR_INVALID_PARAMETER);
5764                 return CAMERA_ERROR_INVALID_PARAMETER;
5765         }
5766         int ret = CAMERA_ERROR_NONE;
5767         camera_cli_s *pc = (camera_cli_s *)camera;
5768         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5769         int sock_fd;
5770         if (pc->cb_info == NULL) {
5771                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5772                 return CAMERA_ERROR_INVALID_PARAMETER;
5773         }
5774         sock_fd = pc->cb_info->fd;
5775         int get_mode;
5776
5777         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5778         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5779
5780         if (ret == CAMERA_ERROR_NONE) {
5781                 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
5782                 *mode = (camera_attr_hdr_mode_e)get_mode;
5783         }
5784         LOGD("ret : 0x%x", ret);
5785         return ret;
5786 }
5787
5788
5789 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5790 {
5791         if (camera == NULL) {
5792                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5793                 return false;
5794         }
5795
5796         int ret = CAMERA_ERROR_NONE;
5797         camera_cli_s *pc = (camera_cli_s *)camera;
5798         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
5799         int sock_fd;
5800         if (pc->cb_info == NULL) {
5801                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5802                 return CAMERA_ERROR_INVALID_PARAMETER;
5803         }
5804         sock_fd = pc->cb_info->fd;
5805         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5806         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5807         LOGD("ret : 0x%x", ret);
5808         return (bool)ret;
5809 }
5810
5811
5812 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5813 {
5814         int ret = CAMERA_ERROR_NONE;
5815         camera_cli_s *pc = (camera_cli_s *)camera;
5816         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5817         int sock_fd;
5818
5819         if (camera == NULL) {
5820                 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
5821                 return CAMERA_ERROR_INVALID_PARAMETER;
5822         }
5823
5824         if (pc->cb_info == NULL) {
5825                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5826                 return CAMERA_ERROR_INVALID_PARAMETER;
5827         }
5828
5829         sock_fd = pc->cb_info->fd;
5830
5831         LOGD("Enter, handle :%x", pc->remote_handle);
5832
5833         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5834
5835         if (ret == CAMERA_ERROR_NONE) {
5836                 if (callback == NULL) {
5837                         LOGE("INVALID_PARAMETER(0x%08x) - callback", CAMERA_ERROR_INVALID_PARAMETER);
5838                         return CAMERA_ERROR_INVALID_PARAMETER;
5839                 }
5840
5841                 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5842                 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5843         }
5844
5845         LOGD("ret : 0x%x", ret);
5846
5847         return ret;
5848 }
5849
5850
5851 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5852 {
5853         if (camera == NULL) {
5854                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5855                 return CAMERA_ERROR_INVALID_PARAMETER;
5856         }
5857
5858         int ret = CAMERA_ERROR_NONE;
5859
5860         camera_cli_s *pc = (camera_cli_s *)camera;
5861         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5862         int sock_fd;
5863         if (pc->cb_info == NULL) {
5864                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5865                 return CAMERA_ERROR_INVALID_PARAMETER;
5866         }
5867         sock_fd = pc->cb_info->fd;
5868         LOGD("Enter, handle :%x", pc->remote_handle);
5869
5870         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)NULL;
5871         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)NULL;
5872
5873         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5874         LOGD("ret : 0x%x", ret);
5875         return ret;
5876 }
5877
5878
5879 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
5880 {
5881         if (camera == NULL) {
5882                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5883                 return CAMERA_ERROR_INVALID_PARAMETER;
5884         }
5885
5886         int ret = CAMERA_ERROR_NONE;
5887         camera_cli_s *pc = (camera_cli_s *)camera;
5888         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
5889         int sock_fd;
5890         if (pc->cb_info == NULL) {
5891                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5892                 return CAMERA_ERROR_INVALID_PARAMETER;
5893         }
5894         sock_fd = pc->cb_info->fd;
5895         int set_enable = (int)enable;
5896
5897         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5898         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable);
5899         LOGD("ret : 0x%x", ret);
5900         return ret;
5901 }
5902
5903
5904 int camera_attr_is_enabled_anti_shake(camera_h camera , bool *enabled)
5905 {
5906         if (camera == NULL) {
5907                 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
5908                 return CAMERA_ERROR_INVALID_PARAMETER;
5909         }
5910         if (enabled == NULL) {
5911                 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
5912                 return CAMERA_ERROR_INVALID_PARAMETER;
5913         }
5914         int ret = CAMERA_ERROR_NONE;
5915         camera_cli_s *pc = (camera_cli_s *)camera;
5916         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
5917         int sock_fd;
5918         if (pc->cb_info == NULL) {
5919                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5920                 return CAMERA_ERROR_INVALID_PARAMETER;
5921         }
5922         sock_fd = pc->cb_info->fd;
5923         int get_enabled;
5924
5925         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5926         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5927
5928         if (ret == CAMERA_ERROR_NONE) {
5929                 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
5930                 *enabled = (bool)get_enabled;
5931         }
5932         LOGD("ret : 0x%x", ret);
5933         return ret;
5934 }
5935
5936
5937 bool camera_attr_is_supported_anti_shake(camera_h camera)
5938 {
5939
5940         if (camera == NULL) {
5941                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5942                 return false;
5943         }
5944
5945         int ret = CAMERA_ERROR_NONE;
5946         camera_cli_s *pc = (camera_cli_s *)camera;
5947         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
5948         int sock_fd;
5949         if (pc->cb_info == NULL) {
5950                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5951                 return CAMERA_ERROR_INVALID_PARAMETER;
5952         }
5953         sock_fd = pc->cb_info->fd;
5954         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5955         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5956         LOGD("ret : 0x%x", ret);
5957         return ret;
5958 }
5959
5960
5961 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
5962 {
5963         if (camera == NULL) {
5964                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5965                 return CAMERA_ERROR_INVALID_PARAMETER;
5966         }
5967
5968         int ret = CAMERA_ERROR_NONE;
5969         camera_cli_s *pc = (camera_cli_s *)camera;
5970         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
5971         int sock_fd;
5972         if (pc->cb_info == NULL) {
5973                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5974                 return CAMERA_ERROR_INVALID_PARAMETER;
5975         }
5976         sock_fd = pc->cb_info->fd;
5977         int set_enable = (int)enable;
5978
5979         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5980         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable);
5981         LOGD("ret : 0x%x", ret);
5982         return ret;
5983 }
5984
5985
5986 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
5987 {
5988         if (camera == NULL) {
5989                 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
5990                 return CAMERA_ERROR_INVALID_PARAMETER;
5991         }
5992         if (enabled == NULL) {
5993                 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
5994                 return CAMERA_ERROR_INVALID_PARAMETER;
5995         }
5996         int ret = CAMERA_ERROR_NONE;
5997         camera_cli_s *pc = (camera_cli_s *)camera;
5998         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
5999         int sock_fd;
6000         if (pc->cb_info == NULL) {
6001                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6002                 return CAMERA_ERROR_INVALID_PARAMETER;
6003         }
6004         sock_fd = pc->cb_info->fd;
6005         int get_enabled;
6006
6007         LOGD("Enter, remote_handle : %x", pc->remote_handle);
6008         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
6009
6010         if (ret == CAMERA_ERROR_NONE) {
6011                 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
6012                 *enabled = (bool)get_enabled;
6013         }
6014         LOGD("ret : 0x%x", ret);
6015         return ret;
6016 }
6017
6018
6019 bool camera_attr_is_supported_video_stabilization(camera_h camera)
6020 {
6021         if (camera == NULL) {
6022                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6023                 return false;
6024         }
6025
6026         int ret = CAMERA_ERROR_NONE;
6027         camera_cli_s *pc = (camera_cli_s *)camera;
6028         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
6029         int sock_fd;
6030         if (pc->cb_info == NULL) {
6031                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6032                 return CAMERA_ERROR_INVALID_PARAMETER;
6033         }
6034         sock_fd = pc->cb_info->fd;
6035         LOGD("Enter, remote_handle : %x", pc->remote_handle);
6036         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
6037         LOGD("ret : 0x%x", ret);
6038         return ret;
6039 }
6040
6041
6042 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
6043 {
6044         if (camera == NULL) {
6045                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6046                 return CAMERA_ERROR_INVALID_PARAMETER;
6047         }
6048
6049         int ret = CAMERA_ERROR_NONE;
6050         camera_cli_s *pc = (camera_cli_s *)camera;
6051         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
6052         int sock_fd;
6053         if (pc->cb_info == NULL) {
6054                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6055                 return CAMERA_ERROR_INVALID_PARAMETER;
6056         }
6057         sock_fd = pc->cb_info->fd;
6058         int set_enable = (int)enable;
6059
6060         LOGD("Enter, remote_handle : %x", pc->remote_handle);
6061         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable);
6062         LOGD("ret : 0x%x", ret);
6063         return ret;
6064 }
6065
6066
6067 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
6068 {
6069         if (camera == NULL) {
6070                 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
6071                 return CAMERA_ERROR_INVALID_PARAMETER;
6072         }
6073         if (enabled == NULL) {
6074                 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
6075                 return CAMERA_ERROR_INVALID_PARAMETER;
6076         }
6077         int ret = CAMERA_ERROR_NONE;
6078         camera_cli_s *pc = (camera_cli_s *)camera;
6079         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
6080         int sock_fd;
6081         if (pc->cb_info == NULL) {
6082                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6083                 return CAMERA_ERROR_INVALID_PARAMETER;
6084         }
6085         sock_fd = pc->cb_info->fd;
6086         int get_enabled;
6087
6088         LOGD("Enter, remote_handle : %x", pc->remote_handle);
6089         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
6090
6091         if (ret == CAMERA_ERROR_NONE) {
6092                 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
6093                 *enabled = (bool)get_enabled;
6094         }
6095         LOGD("ret : 0x%x", ret);
6096         return ret;
6097 }
6098
6099
6100 bool camera_attr_is_supported_auto_contrast(camera_h camera)
6101 {
6102         if (camera == NULL) {
6103                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6104                 return false;
6105         }
6106
6107         int ret = CAMERA_ERROR_NONE;
6108         camera_cli_s *pc = (camera_cli_s *)camera;
6109         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
6110         int sock_fd;
6111         if (pc->cb_info == NULL) {
6112                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6113                 return CAMERA_ERROR_INVALID_PARAMETER;
6114         }
6115         sock_fd = pc->cb_info->fd;
6116         LOGD("Enter, remote_handle : %x", pc->remote_handle);
6117         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
6118         LOGD("ret : 0x%x", ret);
6119         return ret;
6120 }
6121
6122
6123 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
6124 {
6125         if (camera == NULL) {
6126                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6127                 return CAMERA_ERROR_INVALID_PARAMETER;
6128         }
6129
6130         int ret = CAMERA_ERROR_NONE;
6131         camera_cli_s *pc = (camera_cli_s *)camera;
6132         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
6133         int sock_fd;
6134         if (pc->cb_info == NULL) {
6135                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6136                 return CAMERA_ERROR_INVALID_PARAMETER;
6137         }
6138         sock_fd = pc->cb_info->fd;
6139         int set_disable = (int)disable;
6140
6141         LOGD("Enter, remote_handle : %x", pc->remote_handle);
6142         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_disable);
6143         LOGD("ret : 0x%x", ret);
6144         return ret;
6145 }
6146
6147
6148 int camera_attr_set_pan(camera_h camera, camera_attr_ptz_move_type_e move_type, int pan_step)
6149 {
6150         if (camera == NULL) {
6151                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6152                 return CAMERA_ERROR_INVALID_PARAMETER;
6153         }
6154
6155         camera_cli_s *pc = (camera_cli_s *)camera;
6156         if (pc->cb_info == NULL) {
6157                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6158                 return CAMERA_ERROR_INVALID_PARAMETER;
6159         }
6160
6161         int ret = CAMERA_ERROR_NONE;
6162         int sock_fd = pc->cb_info->fd;
6163         int set_move_type = (int)move_type;
6164         int set_pan_step = pan_step;
6165         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PAN;
6166
6167         LOGD("Enter, remote_handle : %x", pc->remote_handle);
6168         muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, set_move_type, INT, set_pan_step);
6169         LOGD("ret : 0x%x", ret);
6170         return ret;
6171 }
6172
6173
6174 int camera_attr_get_pan(camera_h camera, int *pan_step)
6175 {
6176         if (camera == NULL || pan_step == NULL) {
6177                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6178                 return CAMERA_ERROR_INVALID_PARAMETER;
6179         }
6180
6181         camera_cli_s *pc = (camera_cli_s *)camera;
6182         if (pc->cb_info == NULL) {
6183                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6184                 return CAMERA_ERROR_INVALID_PARAMETER;
6185         }
6186
6187         int ret = CAMERA_ERROR_NONE;
6188         int sock_fd = pc->cb_info->fd;
6189         int get_pan_step;
6190         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN;
6191
6192         LOGD("Enter, remote_handle : %x", pc->remote_handle);
6193         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
6194
6195         if (ret == CAMERA_ERROR_NONE) {
6196                 muse_camera_msg_get(get_pan_step, pc->cb_info->recv_msg);
6197                 *pan_step = get_pan_step;
6198         }
6199         LOGD("ret : 0x%x", ret);
6200         return ret;
6201 }
6202
6203
6204 int camera_attr_get_pan_range(camera_h camera, int *min, int *max)
6205 {
6206         if (camera == NULL || min == NULL || max == NULL) {
6207                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6208                 return CAMERA_ERROR_INVALID_PARAMETER;
6209         }
6210
6211         camera_cli_s *pc = (camera_cli_s *)camera;
6212         if (pc->cb_info == NULL) {
6213                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6214                 return CAMERA_ERROR_INVALID_PARAMETER;
6215         }
6216
6217         int ret = CAMERA_ERROR_NONE;
6218         int sock_fd = pc->cb_info->fd;
6219         int get_min;
6220         int get_max;
6221         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PAN_RANGE;
6222
6223         LOGD("Enter, remote_handle : %x", pc->remote_handle);
6224         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
6225
6226         if (ret == CAMERA_ERROR_NONE) {
6227                 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
6228                 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
6229                 *min = get_min;
6230                 *max = get_max;
6231         }
6232         LOGD("ret : 0x%x", ret);
6233         return ret;
6234 }
6235
6236
6237 int camera_attr_set_tilt(camera_h camera, camera_attr_ptz_move_type_e move_type, int tilt_step)
6238 {
6239         if (camera == NULL) {
6240                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6241                 return CAMERA_ERROR_INVALID_PARAMETER;
6242         }
6243
6244         camera_cli_s *pc = (camera_cli_s *)camera;
6245         if (pc->cb_info == NULL) {
6246                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6247                 return CAMERA_ERROR_INVALID_PARAMETER;
6248         }
6249
6250         int ret = CAMERA_ERROR_NONE;
6251         int sock_fd = pc->cb_info->fd;
6252         int set_move_type = (int)move_type;
6253         int set_tilt_step = tilt_step;
6254         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TILT;
6255
6256         LOGD("Enter, remote_handle : %x", pc->remote_handle);
6257         muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, set_move_type, INT, set_tilt_step);
6258         LOGD("ret : 0x%x", ret);
6259         return ret;
6260 }
6261
6262
6263 int camera_attr_get_tilt(camera_h camera, int *tilt_step)
6264 {
6265         if (camera == NULL || tilt_step == NULL) {
6266                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6267                 return CAMERA_ERROR_INVALID_PARAMETER;
6268         }
6269
6270         camera_cli_s *pc = (camera_cli_s *)camera;
6271         if (pc->cb_info == NULL) {
6272                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6273                 return CAMERA_ERROR_INVALID_PARAMETER;
6274         }
6275
6276         int ret = CAMERA_ERROR_NONE;
6277         int sock_fd = pc->cb_info->fd;
6278         int get_tilt_step;
6279         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT;
6280
6281         LOGD("Enter, remote_handle : %x", pc->remote_handle);
6282         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
6283
6284         if (ret == CAMERA_ERROR_NONE) {
6285                 muse_camera_msg_get(get_tilt_step, pc->cb_info->recv_msg);
6286                 *tilt_step = get_tilt_step;
6287         }
6288         LOGD("ret : 0x%x", ret);
6289         return ret;
6290 }
6291
6292
6293 int camera_attr_get_tilt_range(camera_h camera, int *min, int *max)
6294 {
6295         if (camera == NULL || min == NULL || max == NULL) {
6296                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6297                 return CAMERA_ERROR_INVALID_PARAMETER;
6298         }
6299
6300         camera_cli_s *pc = (camera_cli_s *)camera;
6301         if (pc->cb_info == NULL) {
6302                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6303                 return CAMERA_ERROR_INVALID_PARAMETER;
6304         }
6305
6306         int ret = CAMERA_ERROR_NONE;
6307         int sock_fd = pc->cb_info->fd;
6308         int get_min;
6309         int get_max;
6310         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TILT_RANGE;
6311
6312         LOGD("Enter, remote_handle : %x", pc->remote_handle);
6313         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
6314
6315         if (ret == CAMERA_ERROR_NONE) {
6316                 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
6317                 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
6318                 *min = get_min;
6319                 *max = get_max;
6320         }
6321         LOGD("ret : 0x%x", ret);
6322         return ret;
6323 }
6324
6325
6326 int camera_attr_set_ptz_type(camera_h camera, camera_attr_ptz_type_e ptz_type)
6327 {
6328         if (camera == NULL) {
6329                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6330                 return CAMERA_ERROR_INVALID_PARAMETER;
6331         }
6332
6333         camera_cli_s *pc = (camera_cli_s *)camera;
6334         if (pc->cb_info == NULL) {
6335                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6336                 return CAMERA_ERROR_INVALID_PARAMETER;
6337         }
6338
6339         int ret = CAMERA_ERROR_NONE;
6340         int sock_fd = pc->cb_info->fd;
6341         int set_ptz_type = (int)ptz_type;
6342         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PTZ_TYPE;
6343
6344         LOGD("Enter, remote_handle : %x", pc->remote_handle);
6345         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_ptz_type);
6346         LOGD("ret : 0x%x", ret);
6347         return ret;
6348 }
6349
6350
6351 int camera_attr_foreach_supported_ptz_type(camera_h camera, camera_attr_supported_ptz_type_cb foreach_cb, void *user_data)
6352 {
6353         if (camera == NULL || foreach_cb == NULL) {
6354                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6355                 return CAMERA_ERROR_INVALID_PARAMETER;
6356         }
6357         int ret = CAMERA_ERROR_NONE;
6358
6359         camera_cli_s *pc = (camera_cli_s *)camera;
6360         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_PTZ_TYPE;
6361         int sock_fd;
6362         if (pc->cb_info == NULL) {
6363                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6364                 return CAMERA_ERROR_INVALID_PARAMETER;
6365         }
6366         sock_fd = pc->cb_info->fd;
6367         LOGD("Enter, handle :%x", pc->remote_handle);
6368         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = foreach_cb;
6369         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PTZ_TYPE] = user_data;
6370
6371         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
6372         LOGD("ret : 0x%x", ret);
6373         return ret;
6374 }
6375
6376
6377 int camera_attr_set_display_roi_area(camera_h camera, int x, int y, int width, int height)
6378 {
6379         if (camera == NULL) {
6380                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6381                 return CAMERA_ERROR_INVALID_PARAMETER;
6382         }
6383
6384         camera_cli_s *pc = (camera_cli_s *)camera;
6385         if (pc->cb_info == NULL) {
6386                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6387                 return CAMERA_ERROR_INVALID_PARAMETER;
6388         }
6389
6390         int ret = CAMERA_ERROR_NONE;
6391         int sock_fd = pc->cb_info->fd;
6392         int set_display_roi_area[4] = {x, y, width, height};
6393         muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY_ROI_AREA;
6394
6395         LOGD("Enter, remote_handle : %x", pc->remote_handle);
6396
6397 #ifdef EVAS_RENDERER_SUPPORT
6398         if(CHECK_PREVIEW_CB(pc->cb_info, PREVIEW_CB_TYPE_EVAS)) {
6399                 g_mutex_lock(&pc->cb_info->evas_mutex);
6400
6401                 ret = mm_evas_renderer_set_roi_area(pc->cb_info->evas_info, x, y, width, height);
6402
6403                 g_mutex_unlock(&pc->cb_info->evas_mutex);
6404
6405                 if (ret != MM_ERROR_NONE) {
6406                         LOGE("mm_evas_renderer_set_roi_area error 0x%x", ret);
6407                         return CAMERA_ERROR_INVALID_OPERATION;
6408                 }
6409         }
6410 #endif /* EVAS_RENDERER_SUPPORT */
6411
6412         muse_camera_msg_send_array(api, sock_fd, pc->cb_info, ret,
6413                 set_display_roi_area, sizeof(set_display_roi_area), sizeof(int));
6414
6415         LOGD("ret : 0x%x", ret);
6416
6417         return ret;
6418 }
6419
6420
6421 int camera_attr_get_display_roi_area(camera_h camera, int *x, int *y, int *width, int *height)
6422 {
6423         if (camera == NULL || x == NULL || y == NULL || width == NULL || height == NULL) {
6424                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6425                 return CAMERA_ERROR_INVALID_PARAMETER;
6426         }
6427
6428         camera_cli_s *pc = (camera_cli_s *)camera;
6429         if (pc->cb_info == NULL) {
6430                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
6431                 return CAMERA_ERROR_INVALID_PARAMETER;
6432         }
6433
6434         int ret = CAMERA_ERROR_NONE;
6435         int sock_fd = pc->cb_info->fd;
6436         int get_display_roi_area[4] = {0,};
6437         muse_camera_api_e api = MUSE_CAMERA_API_GET_DISPLAY_ROI_AREA;
6438
6439         LOGD("Enter, remote_handle : %x", pc->remote_handle);
6440
6441         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
6442
6443         if (ret == CAMERA_ERROR_NONE) {
6444                 muse_camera_msg_get_array(get_display_roi_area, pc->cb_info->recv_msg);
6445
6446                 *x = get_display_roi_area[0];
6447                 *y = get_display_roi_area[1];
6448                 *width = get_display_roi_area[2];
6449                 *height = get_display_roi_area[3];
6450
6451                 LOGD("ret : 0x%x", ret);
6452         } else {
6453                 LOGE("Returned value is not valid : 0x%x", ret);
6454         }
6455
6456         return ret;
6457 }