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