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