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