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