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