[Release version 0.2.45] Fix TSAM-1058 - Distorted Camera View in Landscape
[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         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 = (camera_idle_event_s *)malloc(sizeof(camera_idle_event_s));
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                 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                                                 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 (muse_camera_msg_get(api_class, parse_str[i]))
1531                                 LOGD("camera api_class[%d]", api_class);
1532
1533                         if (api_class == MUSE_CAMERA_API_CLASS_IMMEDIATE) {
1534                                 g_mutex_lock(&cb_info->api_mutex[api]);
1535
1536                                 if (!muse_camera_msg_get(ret, parse_str[i])) {
1537                                         LOGE("failed to get camera ret");
1538                                         g_mutex_unlock(&cb_info->api_mutex[api]);
1539                                         continue;
1540                                 }
1541
1542                                 cb_info->api_ret[api] = ret;
1543                                 cb_info->api_activating[api] = 1;
1544
1545                                 if (api == MUSE_CAMERA_API_CREATE) {
1546                                         if (ret != CAMERA_ERROR_NONE) {
1547                                                 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1548                                                 LOGE("camera create error 0x%x. close client cb handler", ret);
1549                                         }
1550                                 } else if (api == MUSE_CAMERA_API_DESTROY) {
1551                                         if (ret == CAMERA_ERROR_NONE) {
1552                                                 g_atomic_int_set(&cb_info->msg_recv_running, 0);
1553                                                 LOGD("camera destroy done. close client cb handler");
1554                                         }
1555                                 }
1556
1557                                 g_cond_signal(&cb_info->api_cond[api]);
1558                                 g_mutex_unlock(&cb_info->api_mutex[api]);
1559                         } else if (api_class == MUSE_CAMERA_API_CLASS_THREAD_SUB || api == MUSE_CAMERA_CB_EVENT) {
1560                                 camera_message_s *cam_msg = g_new0(camera_message_s, 1);
1561                                 if (cam_msg == NULL) {
1562                                         LOGE("failed to alloc cam_msg");
1563                                         continue;
1564                                 }
1565
1566                                 cam_msg->api = api;
1567                                 memcpy(cam_msg->recv_msg, parse_str[i], sizeof(cam_msg->recv_msg));
1568
1569                                 LOGD("add camera message to queue : api %d", api);
1570
1571                                 g_mutex_lock(&cb_info->msg_handler_mutex);
1572                                 g_queue_push_tail(cb_info->msg_queue, (gpointer)cam_msg);
1573                                 g_cond_signal(&cb_info->msg_handler_cond);
1574                                 g_mutex_unlock(&cb_info->msg_handler_mutex);
1575                         } else {
1576                                 LOGW("unknown camera api %d and api_class %d", api, api_class);
1577                         }
1578                 }
1579
1580         }
1581
1582         LOGD("client cb exit");
1583
1584 CB_HANDLER_EXIT:
1585         if (parse_str) {
1586                 for (i = 0 ; i < CAMERA_PARSE_STRING_SIZE ; i++) {
1587                         if (parse_str[i]) {
1588                                 free(parse_str[i]);
1589                                 parse_str[i] = NULL;
1590                         }
1591                 }
1592
1593                 free(parse_str);
1594                 parse_str = NULL;
1595         }
1596
1597         return NULL;
1598 }
1599
1600 static camera_cb_info_s *_client_callback_new(gint sockfd)
1601 {
1602         camera_cb_info_s *cb_info = NULL;
1603         gint *tmp_activating = NULL;
1604         gint *tmp_ret = NULL;
1605         gint i = 0;
1606
1607         g_return_val_if_fail(sockfd > 0, NULL);
1608
1609         cb_info = g_new0(camera_cb_info_s, 1);
1610         if (cb_info == NULL) {
1611                 LOGE("cb_info failed");
1612                 goto ErrorExit;
1613         }
1614
1615         g_mutex_init(&cb_info->msg_handler_mutex);
1616         g_cond_init(&cb_info->msg_handler_cond);
1617         g_mutex_init(&cb_info->idle_event_mutex);
1618         g_cond_init(&cb_info->idle_event_cond);
1619
1620         for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
1621                 g_mutex_init(&cb_info->api_mutex[i]);
1622                 g_cond_init(&cb_info->api_cond[i]);
1623         }
1624
1625         tmp_activating = g_new0(gint, MUSE_CAMERA_API_MAX);
1626         if (tmp_activating == NULL) {
1627                 LOGE("tmp_activating failed");
1628                 goto ErrorExit;
1629         }
1630
1631         tmp_ret = g_new0(gint, MUSE_CAMERA_API_MAX);
1632         if (tmp_ret == NULL) {
1633                 LOGE("tmp_ret failed");
1634                 goto ErrorExit;
1635         }
1636
1637         cb_info->msg_queue = g_queue_new();
1638         if (cb_info->msg_queue == NULL) {
1639                 LOGE("msg_queue new failed");
1640                 goto ErrorExit;
1641         }
1642
1643         g_atomic_int_set(&cb_info->msg_handler_running, 1);
1644         cb_info->msg_handler_thread = g_thread_try_new("camera_msg_handler",
1645                 _camera_msg_handler_func, (gpointer)cb_info, NULL);
1646         if (cb_info->msg_handler_thread == NULL) {
1647                 LOGE("message handler thread creation failed");
1648                 goto ErrorExit;
1649         }
1650
1651         cb_info->fd = sockfd;
1652         cb_info->api_activating = tmp_activating;
1653         cb_info->api_ret = tmp_ret;
1654
1655         g_atomic_int_set(&cb_info->msg_recv_running, 1);
1656         cb_info->msg_recv_thread = g_thread_try_new("camera_msg_recv",
1657                 _camera_msg_recv_func, (gpointer)cb_info, NULL);
1658         if (cb_info->msg_recv_thread == NULL) {
1659                 LOGE("message receive thread creation failed");
1660                 goto ErrorExit;
1661         }
1662
1663         return cb_info;
1664
1665 ErrorExit:
1666         if (cb_info) {
1667                 if (cb_info->msg_handler_thread) {
1668                         g_mutex_lock(&cb_info->msg_handler_mutex);
1669                         g_atomic_int_set(&cb_info->msg_handler_running, 0);
1670                         g_cond_signal(&cb_info->msg_handler_cond);
1671                         g_mutex_unlock(&cb_info->msg_handler_mutex);
1672
1673                         g_thread_join(cb_info->msg_handler_thread);
1674                         g_thread_unref(cb_info->msg_handler_thread);
1675                         cb_info->msg_handler_thread = NULL;
1676                 }
1677
1678                 for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
1679                         g_mutex_clear(&cb_info->api_mutex[i]);
1680                         g_cond_clear(&cb_info->api_cond[i]);
1681                 }
1682
1683                 g_mutex_clear(&cb_info->msg_handler_mutex);
1684                 g_cond_clear(&cb_info->msg_handler_cond);
1685                 g_mutex_clear(&cb_info->idle_event_mutex);
1686                 g_cond_clear(&cb_info->idle_event_cond);
1687
1688                 if (cb_info->msg_queue) {
1689                         g_queue_free(cb_info->msg_queue);
1690                         cb_info->msg_queue = NULL;
1691                 }
1692
1693                 g_free(cb_info);
1694                 cb_info = NULL;
1695         }
1696
1697         if (tmp_activating) {
1698                 g_free(tmp_activating);
1699                 tmp_activating = NULL;
1700         }
1701         if (tmp_ret) {
1702                 g_free(tmp_ret);
1703                 tmp_ret = NULL;
1704         }
1705
1706         return NULL;
1707 }
1708
1709 static void _client_callback_destroy(camera_cb_info_s *cb_info)
1710 {
1711         gint i = 0;
1712
1713         g_return_if_fail(cb_info != NULL);
1714
1715         LOGD("MSG receive thread[%p] destroy", cb_info->msg_recv_thread);
1716
1717         g_thread_join(cb_info->msg_recv_thread);
1718         g_thread_unref(cb_info->msg_recv_thread);
1719         cb_info->msg_recv_thread = NULL;
1720
1721         LOGD("msg thread removed");
1722
1723         g_mutex_lock(&cb_info->msg_handler_mutex);
1724         g_atomic_int_set(&cb_info->msg_handler_running, 0);
1725         g_cond_signal(&cb_info->msg_handler_cond);
1726         g_mutex_unlock(&cb_info->msg_handler_mutex);
1727
1728         g_thread_join(cb_info->msg_handler_thread);
1729         g_thread_unref(cb_info->msg_handler_thread);
1730         cb_info->msg_handler_thread = NULL;
1731
1732         g_queue_free(cb_info->msg_queue);
1733         cb_info->msg_queue = NULL;
1734
1735         for (i = 0 ; i < MUSE_CAMERA_API_MAX ; i++) {
1736                 g_mutex_clear(&cb_info->api_mutex[i]);
1737                 g_cond_clear(&cb_info->api_cond[i]);
1738         }
1739
1740         g_mutex_clear(&cb_info->msg_handler_mutex);
1741         g_cond_clear(&cb_info->msg_handler_cond);
1742         g_mutex_clear(&cb_info->idle_event_mutex);
1743         g_cond_clear(&cb_info->idle_event_cond);
1744
1745         LOGD("event thread removed");
1746
1747         if (cb_info->fd > -1) {
1748                 muse_core_connection_close(cb_info->fd);
1749                 cb_info->fd = -1;
1750         }
1751
1752         if (cb_info->bufmgr) {
1753                 tbm_bufmgr_deinit(cb_info->bufmgr);
1754                 cb_info->bufmgr = NULL;
1755         }
1756         if (cb_info->api_activating) {
1757                 g_free(cb_info->api_activating);
1758                 cb_info->api_activating = NULL;
1759         }
1760         if (cb_info->api_ret) {
1761                 g_free(cb_info->api_ret);
1762                 cb_info->api_ret = NULL;
1763         }
1764         if (cb_info->pkt_fmt) {
1765                 media_format_unref(cb_info->pkt_fmt);
1766                 cb_info->pkt_fmt = NULL;
1767         }
1768
1769         g_free(cb_info);
1770         cb_info = NULL;
1771
1772         return;
1773 }
1774
1775 int camera_create(camera_device_e device, camera_h *camera)
1776 {
1777         int sock_fd = -1;
1778         char *sndMsg;
1779         int ret = CAMERA_ERROR_NONE;
1780         int pid = 0;
1781         camera_cli_s *pc = NULL;
1782         tbm_bufmgr bufmgr = NULL;
1783
1784         muse_camera_api_e api = MUSE_CAMERA_API_CREATE;
1785         muse_core_api_module_e muse_module = MUSE_CAMERA;
1786         int device_type = (int)device;
1787
1788         if (camera == NULL) {
1789                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1790                 return CAMERA_ERROR_INVALID_PARAMETER;
1791         }
1792
1793         bufmgr = tbm_bufmgr_init(-1);
1794         if (bufmgr == NULL) {
1795                 LOGE("get tbm bufmgr failed");
1796                 return CAMERA_ERROR_INVALID_OPERATION;
1797         }
1798
1799         sock_fd = muse_core_client_new();
1800         if (sock_fd < 0) {
1801                 LOGE("muse_core_client_new failed - returned fd %d", sock_fd);
1802                 ret = CAMERA_ERROR_INVALID_OPERATION;
1803                 goto ErrorExit;
1804         }
1805
1806         pid = getpid();
1807
1808         sndMsg = muse_core_msg_json_factory_new(api,
1809                 MUSE_TYPE_INT, "module", muse_module,
1810                 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
1811                 MUSE_TYPE_INT, "pid", pid,
1812                 0);
1813
1814         muse_core_ipc_send_msg(sock_fd, sndMsg);
1815         muse_core_msg_json_factory_free(sndMsg);
1816
1817         pc = g_new0(camera_cli_s, 1);
1818         if (pc == NULL) {
1819                 LOGE("camera_cli_s alloc failed");
1820                 ret = CAMERA_ERROR_OUT_OF_MEMORY;
1821                 goto ErrorExit;
1822         }
1823
1824         pc->cb_info = _client_callback_new(sock_fd);
1825         if (pc->cb_info == NULL) {
1826                 LOGE("cb_info alloc failed");
1827                 ret = CAMERA_ERROR_OUT_OF_MEMORY;
1828                 goto ErrorExit;
1829         }
1830
1831         LOGD("cb info : %d", pc->cb_info->fd);
1832
1833         ret = _client_wait_for_cb_return(api, pc->cb_info, CALLBACK_TIME_OUT);
1834         if (ret == CAMERA_ERROR_NONE) {
1835                 intptr_t handle = 0;
1836                 muse_camera_msg_get_pointer(handle, pc->cb_info->recv_msg);
1837                 if (handle == 0) {
1838                         LOGE("Receiving Handle Failed!!");
1839                         ret = CAMERA_ERROR_INVALID_OPERATION;
1840                         goto ErrorExit;
1841                 }
1842
1843                 pc->remote_handle = handle;
1844                 pc->cb_info->bufmgr = bufmgr;
1845
1846                 ret = camera_set_display((camera_h)pc, CAMERA_DISPLAY_TYPE_NONE, NULL);
1847                 if (ret != CAMERA_ERROR_NONE) {
1848                         LOGE("init display failed 0x%x", ret);
1849                         goto ErrorExit;
1850                 }
1851
1852                 LOGD("camera create 0x%x", pc->remote_handle);
1853                 *camera = (camera_h)pc;
1854         } else {
1855                 goto ErrorExit;
1856         }
1857
1858         return ret;
1859
1860 ErrorExit:
1861         tbm_bufmgr_deinit(bufmgr);
1862         bufmgr = NULL;
1863
1864         if (pc) {
1865                 _client_callback_destroy(pc->cb_info);
1866                 pc->cb_info = NULL;
1867                 g_free(pc);
1868                 pc = NULL;
1869         }
1870
1871         LOGE("camera create error : 0x%x", ret);
1872
1873         return ret;
1874 }
1875
1876 int camera_destroy(camera_h camera)
1877 {
1878         if (camera == NULL) {
1879                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1880                 return CAMERA_ERROR_INVALID_PARAMETER;
1881         }
1882
1883         int ret = CAMERA_ERROR_NONE;
1884         muse_camera_api_e api = MUSE_CAMERA_API_DESTROY;
1885         camera_cli_s *pc = (camera_cli_s *)camera;
1886         int sock_fd = 0;
1887
1888         LOGD("ENTER");
1889
1890         if (pc->cb_info == NULL) {
1891                 LOGE("cb_info NULL, INVALID_PARAMETER");
1892                 return CAMERA_ERROR_INVALID_PARAMETER;
1893         }
1894
1895         sock_fd = pc->cb_info->fd;
1896
1897         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
1898         if (ret == CAMERA_ERROR_NONE) {
1899                 _camera_remove_idle_event_all(pc->cb_info);
1900                 _client_callback_destroy(pc->cb_info);
1901                 pc->cb_info = NULL;
1902
1903                 g_free(pc);
1904                 pc = NULL;
1905         } else {
1906                 LOGE("camera destroy error : 0x%x", ret);
1907         }
1908
1909         return ret;
1910 }
1911
1912 int camera_start_preview(camera_h camera)
1913 {
1914         int ret = CAMERA_ERROR_NONE;
1915         muse_camera_api_e api = MUSE_CAMERA_API_START_PREVIEW;
1916         camera_cli_s *pc = (camera_cli_s *)camera;
1917         int sock_fd = 0;
1918
1919         if (camera == NULL) {
1920                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1921                 return CAMERA_ERROR_INVALID_PARAMETER;
1922         }
1923
1924         if (pc->cb_info == NULL) {
1925                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1926                 return CAMERA_ERROR_INVALID_PARAMETER;
1927         }
1928
1929         LOGD("start");
1930
1931         sock_fd = pc->cb_info->fd;
1932
1933         muse_camera_msg_send_longtime(api, sock_fd, pc->cb_info, ret);
1934
1935         if (ret != CAMERA_ERROR_NONE) {
1936                 LOGE("start preview failed 0x%x", ret);
1937                 return ret;
1938         }
1939
1940         LOGD("ret : 0x%x", ret);
1941
1942         return CAMERA_ERROR_NONE;
1943 }
1944
1945 int camera_stop_preview(camera_h camera)
1946 {
1947         int ret = CAMERA_ERROR_NONE;
1948         int sock_fd = 0;
1949         camera_cli_s *pc = NULL;
1950         muse_camera_api_e api = MUSE_CAMERA_API_STOP_PREVIEW;
1951
1952         if (camera == NULL) {
1953                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1954                 return CAMERA_ERROR_INVALID_PARAMETER;
1955         }
1956
1957         pc = (camera_cli_s *)camera;
1958
1959         if (pc->cb_info == NULL) {
1960                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1961                 return CAMERA_ERROR_INVALID_PARAMETER;
1962         }
1963
1964         sock_fd = pc->cb_info->fd;
1965
1966         LOGD("Enter");
1967
1968         /* send stop preview message */
1969         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
1970
1971         LOGD("ret : 0x%x", ret);
1972
1973         return ret;
1974 }
1975
1976 int camera_start_capture(camera_h camera, camera_capturing_cb capturing_cb, camera_capture_completed_cb completed_cb, void *user_data)
1977 {
1978         if (camera == NULL) {
1979                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1980                 return CAMERA_ERROR_INVALID_PARAMETER;
1981         }
1982         int ret = CAMERA_ERROR_NONE;
1983
1984         camera_cli_s *pc = (camera_cli_s *)camera;
1985         muse_camera_api_e api = MUSE_CAMERA_API_START_CAPTURE;
1986         int sock_fd;
1987         int is_capturing_cb = 0;
1988         int is_completed_cb = 0;
1989         LOGD("Enter, handle :%x", pc->remote_handle);
1990
1991         if (pc->cb_info == NULL) {
1992                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
1993                 return CAMERA_ERROR_INVALID_PARAMETER;
1994         }
1995
1996         sock_fd = pc->cb_info->fd;
1997
1998         if (capturing_cb != NULL) {
1999                 is_capturing_cb = 1;
2000                 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2001                 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2002         }
2003
2004         if (completed_cb != NULL) {
2005                 is_completed_cb = 1;
2006                 pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2007                 pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = user_data;
2008         }
2009
2010         muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, is_capturing_cb, INT, is_completed_cb);
2011         LOGD("is_capturing_cb :%d, is_completed_cb : %d", is_capturing_cb, is_completed_cb);
2012         LOGD("ret : 0x%x", ret);
2013         return ret;
2014 }
2015
2016 bool camera_is_supported_continuous_capture(camera_h camera)
2017 {
2018         if (camera == NULL) {
2019                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2020                 return false;
2021         }
2022
2023         int ret = CAMERA_ERROR_NONE;
2024         camera_cli_s *pc = (camera_cli_s *)camera;
2025         muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_CONTINUOUS_CAPTURE;
2026         int sock_fd;
2027
2028         if (pc->cb_info == NULL) {
2029                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2030                 return CAMERA_ERROR_INVALID_PARAMETER;
2031         }
2032
2033         sock_fd = pc->cb_info->fd;
2034
2035         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2036         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2037         LOGD("ret : 0x%x", ret);
2038         return (bool)ret;
2039 }
2040
2041 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)
2042 {
2043         if (camera == NULL) {
2044                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2045                 return CAMERA_ERROR_INVALID_PARAMETER;
2046         }
2047
2048         int ret = CAMERA_ERROR_NONE;
2049
2050         camera_cli_s *pc = (camera_cli_s *)camera;
2051         muse_camera_api_e api = MUSE_CAMERA_API_START_CONTINUOUS_CAPTURE;
2052
2053         LOGD("Enter, handle :%x", pc->remote_handle);
2054
2055         int sock_fd;
2056         if (pc->cb_info == NULL) {
2057                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2058                 return CAMERA_ERROR_INVALID_PARAMETER;
2059         }
2060         sock_fd = pc->cb_info->fd;
2061
2062         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = capturing_cb;
2063         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_CAPTURE] = user_data;
2064         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE] = completed_cb;
2065
2066         muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, count, INT, interval);
2067
2068         LOGD("ret : 0x%x", ret);
2069
2070         return ret;
2071 }
2072
2073 int camera_stop_continuous_capture(camera_h camera)
2074 {
2075         if (camera == NULL) {
2076                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2077                 return CAMERA_ERROR_INVALID_PARAMETER;
2078         }
2079
2080
2081         int ret = CAMERA_ERROR_NONE;
2082
2083         camera_cli_s *pc = (camera_cli_s *)camera;
2084         muse_camera_api_e api = MUSE_CAMERA_API_STOP_CONTINUOUS_CAPTURE;
2085         LOGD("Enter,  handle :%x", pc->remote_handle);
2086         int sock_fd;
2087         if (pc->cb_info == NULL) {
2088                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2089                 return CAMERA_ERROR_INVALID_PARAMETER;
2090         }
2091         sock_fd = pc->cb_info->fd;
2092         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2093         LOGD("ret : 0x%x", ret);
2094         return ret;
2095 }
2096
2097 bool camera_is_supported_face_detection(camera_h camera)
2098 {
2099         if (camera == NULL) {
2100                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2101                 return false;
2102         }
2103         int ret = CAMERA_ERROR_NONE;
2104
2105         camera_cli_s *pc = (camera_cli_s *)camera;
2106         muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_FACE_DETECTION;
2107         int sock_fd;
2108         if (pc->cb_info == NULL) {
2109                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2110                 return CAMERA_ERROR_INVALID_PARAMETER;
2111         }
2112         sock_fd = pc->cb_info->fd;
2113
2114         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2115         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2116         LOGD("ret : 0x%x", ret);
2117         return (bool)ret;
2118 }
2119
2120 bool camera_is_supported_zero_shutter_lag(camera_h camera)
2121 {
2122         if (camera == NULL) {
2123                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2124                 return false;
2125         }
2126         int ret = CAMERA_ERROR_NONE;
2127
2128         camera_cli_s *pc = (camera_cli_s *)camera;
2129         muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_ZERO_SHUTTER_LAG;
2130         int sock_fd;
2131         if (pc->cb_info == NULL) {
2132                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2133                 return CAMERA_ERROR_INVALID_PARAMETER;
2134         }
2135         sock_fd = pc->cb_info->fd;
2136
2137         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2138         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2139         LOGD("ret : 0x%x", ret);
2140         return (bool)ret;
2141 }
2142
2143 bool camera_is_supported_media_packet_preview_cb(camera_h camera)
2144 {
2145         if (camera == NULL) {
2146                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2147                 return false;
2148         }
2149
2150         int ret = CAMERA_ERROR_NONE;
2151
2152         camera_cli_s *pc = (camera_cli_s *)camera;
2153         muse_camera_api_e api = MUSE_CAMERA_API_SUPPORT_MEDIA_PACKET_PREVIEW_CB;
2154         int sock_fd;
2155         if (pc->cb_info == NULL) {
2156                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2157                 return CAMERA_ERROR_INVALID_PARAMETER;
2158         }
2159         sock_fd = pc->cb_info->fd;
2160
2161         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2162         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2163         LOGD("ret : 0x%x", ret);
2164         return (bool)ret;
2165 }
2166
2167 int camera_get_device_count(camera_h camera, int *device_count)
2168 {
2169         if (camera == NULL || device_count == NULL) {
2170                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2171                 return CAMERA_ERROR_INVALID_PARAMETER;
2172         }
2173         int ret = CAMERA_ERROR_NONE;
2174
2175         camera_cli_s *pc = (camera_cli_s *)camera;
2176         muse_camera_api_e api = MUSE_CAMERA_API_GET_DEVICE_COUNT;
2177         int sock_fd;
2178         if (pc->cb_info == NULL) {
2179                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2180                 return CAMERA_ERROR_INVALID_PARAMETER;
2181         }
2182         sock_fd = pc->cb_info->fd;
2183         int get_device_count;
2184
2185         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2186         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2187
2188         if (ret == CAMERA_ERROR_NONE) {
2189                 muse_camera_msg_get(get_device_count, pc->cb_info->recv_msg);
2190                 *device_count = get_device_count;
2191         }
2192         LOGD("ret : 0x%x", ret);
2193         return ret;
2194 }
2195
2196 int camera_start_face_detection(camera_h camera, camera_face_detected_cb callback, void *user_data)
2197 {
2198         if (camera == NULL) {
2199                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2200                 return CAMERA_ERROR_INVALID_PARAMETER;
2201         }
2202
2203         int ret = CAMERA_ERROR_NONE;
2204
2205         camera_cli_s *pc = (camera_cli_s *)camera;
2206         muse_camera_api_e api = MUSE_CAMERA_API_START_FACE_DETECTION;
2207
2208         LOGD("Enter, handle :%x", pc->remote_handle);
2209         int sock_fd;
2210         if (pc->cb_info == NULL) {
2211                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2212                 return CAMERA_ERROR_INVALID_PARAMETER;
2213         }
2214         sock_fd = pc->cb_info->fd;
2215         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = callback;
2216         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION] = user_data;
2217
2218         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2219         LOGD("ret : 0x%x", ret);
2220         return ret;
2221 }
2222
2223 int camera_stop_face_detection(camera_h camera)
2224 {
2225         if (camera == NULL) {
2226                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2227                 return CAMERA_ERROR_INVALID_PARAMETER;
2228         }
2229
2230         int ret = CAMERA_ERROR_NONE;
2231
2232         camera_cli_s *pc = (camera_cli_s *)camera;
2233         muse_camera_api_e api = MUSE_CAMERA_API_STOP_FACE_DETECTION;
2234         LOGD("Enter,  handle :%x", pc->remote_handle);
2235         int sock_fd;
2236         if (pc->cb_info == NULL) {
2237                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2238                 return CAMERA_ERROR_INVALID_PARAMETER;
2239         }
2240         sock_fd = pc->cb_info->fd;
2241         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2242         LOGD("ret : 0x%x", ret);
2243         return ret;
2244 }
2245
2246 int camera_get_state(camera_h camera, camera_state_e * state)
2247 {
2248         if (camera == NULL || state == NULL) {
2249                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2250                 return CAMERA_ERROR_INVALID_PARAMETER;
2251         }
2252         int ret = CAMERA_ERROR_NONE;
2253
2254         camera_cli_s *pc = (camera_cli_s *)camera;
2255         muse_camera_api_e api = MUSE_CAMERA_API_GET_STATE;
2256         int sock_fd;
2257         if (pc->cb_info == NULL) {
2258                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2259                 return CAMERA_ERROR_INVALID_PARAMETER;
2260         }
2261         sock_fd = pc->cb_info->fd;
2262         int get_state;
2263
2264         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2265         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2266
2267         if (ret == CAMERA_ERROR_NONE) {
2268                 muse_camera_msg_get(get_state, pc->cb_info->recv_msg);
2269                 *state = (camera_state_e)get_state;
2270         }
2271         LOGD("ret : 0x%x", ret);
2272         return ret;
2273 }
2274
2275 int camera_start_focusing(camera_h camera, bool continuous)
2276 {
2277         if (camera == NULL) {
2278                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2279                 return CAMERA_ERROR_INVALID_PARAMETER;
2280         }
2281
2282         int ret = CAMERA_ERROR_NONE;
2283
2284         camera_cli_s *pc = (camera_cli_s *)camera;
2285         muse_camera_api_e api = MUSE_CAMERA_API_START_FOCUSING;
2286         int sock_fd;
2287         if (pc->cb_info == NULL) {
2288                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2289                 return CAMERA_ERROR_INVALID_PARAMETER;
2290         }
2291         sock_fd = pc->cb_info->fd;
2292         int is_continuous = (int)continuous;
2293
2294         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2295         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, is_continuous);
2296         LOGD("ret : 0x%x", ret);
2297         return ret;
2298 }
2299
2300 int camera_cancel_focusing(camera_h camera)
2301 {
2302         if (camera == NULL) {
2303                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2304                 return CAMERA_ERROR_INVALID_PARAMETER;
2305         }
2306
2307         int ret = CAMERA_ERROR_NONE;
2308
2309         camera_cli_s *pc = (camera_cli_s *)camera;
2310         muse_camera_api_e api = MUSE_CAMERA_API_CANCEL_FOCUSING;
2311         int sock_fd;
2312         if (pc->cb_info == NULL) {
2313                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2314                 return CAMERA_ERROR_INVALID_PARAMETER;
2315         }
2316         sock_fd = pc->cb_info->fd;
2317
2318         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2319         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2320         LOGD("ret : 0x%x", ret);
2321         return ret;
2322 }
2323
2324 int camera_set_display(camera_h camera, camera_display_type_e type, camera_display_h display)
2325 {
2326         int ret = CAMERA_ERROR_NONE;
2327         void *set_display_handle = NULL;
2328         Evas_Object *obj = NULL;
2329         const char *object_type = NULL;
2330 #ifdef HAVE_WAYLAND
2331         camera_wl_info_s *wl_info = NULL;
2332 #endif /* HAVE_WAYLAND */
2333
2334         if (camera == NULL) {
2335                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2336                 return CAMERA_ERROR_INVALID_PARAMETER;
2337         }
2338
2339         if (type < CAMERA_DISPLAY_TYPE_OVERLAY || type > CAMERA_DISPLAY_TYPE_NONE) {
2340                 LOGE("invalid type %d", type);
2341                 return CAMERA_ERROR_INVALID_PARAMETER;
2342         }
2343
2344         if (type != CAMERA_DISPLAY_TYPE_NONE && display == NULL) {
2345                 LOGE("display type[%d] is not NONE, but display handle is NULL", type);
2346                 return CAMERA_ERROR_INVALID_PARAMETER;
2347         }
2348
2349         camera_cli_s *pc = (camera_cli_s *)camera;
2350         muse_camera_api_e api = MUSE_CAMERA_API_SET_DISPLAY;
2351         int sock_fd;
2352         if (pc->cb_info == NULL) {
2353                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2354                 return CAMERA_ERROR_INVALID_PARAMETER;
2355         }
2356         sock_fd = pc->cb_info->fd;
2357
2358         LOGD("Enter, remote_handle : %x display : 0x%x", pc->remote_handle, display);
2359
2360         if (type == CAMERA_DISPLAY_TYPE_NONE) {
2361                 set_display_handle = 0;
2362                 LOGD("display type NONE");
2363         } else {
2364                 obj = (Evas_Object *)display;
2365                 object_type = evas_object_type_get(obj);
2366                 if (object_type) {
2367                         if (type == CAMERA_DISPLAY_TYPE_OVERLAY && !strcmp(object_type, "elm_win")) {
2368 #ifdef HAVE_WAYLAND
2369                                 /* get wayland parent id */
2370                                 if (_get_wl_info(obj, &pc->wl_info) != CAMERA_ERROR_NONE) {
2371                                         LOGE("failed to get wayland info");
2372                                         return CAMERA_ERROR_INVALID_OPERATION;
2373                                 }
2374
2375                                 set_display_handle = (void *)&pc->wl_info;
2376 #else /* HAVE_WAYLAND */
2377                                 /* x window overlay surface */
2378                                 set_display_handle = (void *)elm_win_xwindow_get(obj);
2379 #endif /* HAVE_WAYLAND */
2380                                 LOGD("display type OVERLAY : handle %p", set_display_handle);
2381                         } else if (type == CAMERA_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
2382                                 /* evas object surface */
2383                                 set_display_handle = (void *)display;
2384                                 LOGD("display type EVAS : handle %p", set_display_handle);
2385                         } else {
2386                                 LOGE("unknown evas object [%p,%s] or type [%d] mismatch", obj, object_type, type);
2387                                 return CAMERA_ERROR_INVALID_PARAMETER;
2388                         }
2389                 } else {
2390                         LOGE("failed to get evas object type from %p", obj);
2391                         return CAMERA_ERROR_INVALID_PARAMETER;
2392                 }
2393         }
2394
2395         pc->display_handle = (intptr_t)set_display_handle;
2396
2397         if (type == CAMERA_DISPLAY_TYPE_OVERLAY) {
2398 #ifdef HAVE_WAYLAND
2399                 wl_info = &pc->wl_info;
2400                 muse_camera_msg_send_array_and_value(api, sock_fd, pc->cb_info, ret,
2401                         wl_info, 5, sizeof(int), INT, type);
2402
2403                 LOGD("wayland parent id : %d, window %d,%d,%dx%d",
2404                         wl_info->parent_id, wl_info->window_x, wl_info->window_y,
2405                         wl_info->window_width, wl_info->window_height);
2406 #else /* HAVE_WAYLAND */
2407                 muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, type, INT, set_display_handle);
2408
2409                 LOGD("x id : %d", (int)set_display_handle);
2410 #endif /* HAVE_WAYLAND */
2411         } else
2412                 muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, type);
2413
2414         if (ret != CAMERA_ERROR_NONE)
2415                 LOGE("set display error 0x%x", ret);
2416
2417         return ret;
2418 }
2419
2420 int camera_set_preview_resolution(camera_h camera,  int width, int height)
2421 {
2422         if (camera == NULL) {
2423                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2424                 return CAMERA_ERROR_INVALID_PARAMETER;
2425         }
2426         int ret = CAMERA_ERROR_NONE;
2427
2428         camera_cli_s *pc = (camera_cli_s *)camera;
2429         muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_RESOLUTION;
2430         int sock_fd;
2431         if (pc->cb_info == NULL) {
2432                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2433                 return CAMERA_ERROR_INVALID_PARAMETER;
2434         }
2435         sock_fd = pc->cb_info->fd;
2436
2437         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2438         muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, width, INT, height);
2439         LOGD("ret : 0x%x", ret);
2440         return ret;
2441 }
2442
2443
2444 int camera_set_capture_resolution(camera_h camera,  int width, int height)
2445 {
2446         if (camera == NULL) {
2447                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2448                 return CAMERA_ERROR_INVALID_PARAMETER;
2449         }
2450
2451         int ret = CAMERA_ERROR_NONE;
2452
2453         camera_cli_s *pc = (camera_cli_s *)camera;
2454         muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_RESOLUTION;
2455         int sock_fd;
2456         if (pc->cb_info == NULL) {
2457                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2458                 return CAMERA_ERROR_INVALID_PARAMETER;
2459         }
2460         sock_fd = pc->cb_info->fd;
2461
2462         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2463         muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, width, INT, height);
2464         LOGD("ret : 0x%x", ret);
2465         return ret;
2466 }
2467
2468 int camera_set_capture_format(camera_h camera, camera_pixel_format_e format)
2469 {
2470         if (camera == NULL) {
2471                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2472                 return CAMERA_ERROR_INVALID_PARAMETER;
2473         }
2474
2475         int ret = CAMERA_ERROR_NONE;
2476         int set_format = (int)format;
2477
2478         camera_cli_s *pc = (camera_cli_s *)camera;
2479         muse_camera_api_e api = MUSE_CAMERA_API_SET_CAPTURE_FORMAT;
2480         int sock_fd;
2481         if (pc->cb_info == NULL) {
2482                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2483                 return CAMERA_ERROR_INVALID_PARAMETER;
2484         }
2485         sock_fd = pc->cb_info->fd;
2486
2487         LOGD("Enter, remote_handle : %x, capture_format: %d", pc->remote_handle, set_format);
2488         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_format);
2489         LOGD("ret : 0x%x", ret);
2490         return ret;
2491 }
2492
2493 int camera_set_preview_format(camera_h camera, camera_pixel_format_e format)
2494 {
2495         if (camera == NULL) {
2496                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2497                 return CAMERA_ERROR_INVALID_PARAMETER;
2498         }
2499
2500         int ret = CAMERA_ERROR_NONE;
2501         int set_format = (int)format;
2502
2503         camera_cli_s *pc = (camera_cli_s *)camera;
2504         muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_FORMAT;
2505         int sock_fd;
2506         if (pc->cb_info == NULL) {
2507                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2508                 return CAMERA_ERROR_INVALID_PARAMETER;
2509         }
2510         sock_fd = pc->cb_info->fd;
2511
2512         LOGD("Enter, remote_handle : %x, capture_format: %d", pc->remote_handle, set_format);
2513         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_format);
2514         LOGD("ret : 0x%x", ret);
2515         return ret;
2516 }
2517
2518 int camera_get_preview_resolution(camera_h camera,  int *width, int *height)
2519 {
2520         if (camera == NULL || width == NULL || height == NULL) {
2521                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2522                 return CAMERA_ERROR_INVALID_PARAMETER;
2523         }
2524
2525
2526         int ret = CAMERA_ERROR_NONE;
2527
2528         camera_cli_s *pc = (camera_cli_s *)camera;
2529         muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_RESOLUTION;
2530         int sock_fd;
2531         if (pc->cb_info == NULL) {
2532                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2533                 return CAMERA_ERROR_INVALID_PARAMETER;
2534         }
2535         sock_fd = pc->cb_info->fd;
2536         int get_width;
2537         int get_height;
2538
2539         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2540         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2541
2542         if (ret == CAMERA_ERROR_NONE) {
2543                 muse_camera_msg_get(get_width, pc->cb_info->recv_msg);
2544                 muse_camera_msg_get(get_height, pc->cb_info->recv_msg);
2545                 *width = get_width;
2546                 *height = get_height;
2547         }
2548         LOGD("ret : 0x%x", ret);
2549         return ret;
2550 }
2551
2552 int camera_set_display_rotation(camera_h camera, camera_rotation_e rotation)
2553 {
2554         int ret = CAMERA_ERROR_NONE;
2555         int set_rotation = (int)rotation;
2556         camera_cli_s *pc = NULL;
2557
2558         if (camera == NULL) {
2559                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2560                 return CAMERA_ERROR_INVALID_PARAMETER;
2561         }
2562
2563         if (rotation < CAMERA_ROTATION_NONE || rotation > CAMERA_ROTATION_270) {
2564                 LOGE("Invalid rotation %d", rotation);
2565                 return CAMERA_ERROR_INVALID_PARAMETER;
2566         }
2567
2568         pc = (camera_cli_s *)camera;
2569
2570         if (pc->cb_info == NULL) {
2571                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2572                 return CAMERA_ERROR_INVALID_PARAMETER;
2573         }
2574
2575         muse_camera_msg_send1(MUSE_CAMERA_API_SET_DISPLAY_ROTATION,
2576                 pc->cb_info->fd, pc->cb_info, ret, INT, set_rotation);
2577
2578         return ret;
2579 }
2580
2581 int camera_get_display_rotation(camera_h camera, camera_rotation_e *rotation)
2582 {
2583         int ret = CAMERA_ERROR_NONE;
2584         int get_rotation = CAMERA_ROTATION_NONE;
2585         camera_cli_s *pc = NULL;
2586
2587         if (camera == NULL || rotation == NULL) {
2588                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2589                 return CAMERA_ERROR_INVALID_PARAMETER;
2590         }
2591
2592         pc = (camera_cli_s *)camera;
2593
2594         if (pc->cb_info == NULL) {
2595                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2596                 return CAMERA_ERROR_INVALID_PARAMETER;
2597         }
2598
2599         muse_camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_ROTATION,
2600                 pc->cb_info->fd, pc->cb_info, ret);
2601
2602         if (ret == CAMERA_ERROR_NONE) {
2603                 muse_camera_msg_get(get_rotation, pc->cb_info->recv_msg);
2604                 *rotation = (camera_rotation_e)get_rotation;
2605         }
2606
2607         return ret;
2608 }
2609
2610 int camera_set_display_flip(camera_h camera, camera_flip_e flip)
2611 {
2612         int ret = CAMERA_ERROR_NONE;
2613         int set_flip = (int)flip;
2614         camera_cli_s *pc = NULL;
2615
2616         if (camera == NULL) {
2617                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2618                 return CAMERA_ERROR_INVALID_PARAMETER;
2619         }
2620
2621         if (flip < CAMERA_FLIP_NONE || flip > CAMERA_FLIP_BOTH) {
2622                 LOGE("Invalid flip %d", flip);
2623                 return CAMERA_ERROR_INVALID_PARAMETER;
2624         }
2625
2626         pc = (camera_cli_s *)camera;
2627
2628         if (pc->cb_info == NULL) {
2629                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2630                 return CAMERA_ERROR_INVALID_PARAMETER;
2631         }
2632
2633         muse_camera_msg_send1(MUSE_CAMERA_API_SET_DISPLAY_FLIP,
2634                 pc->cb_info->fd, pc->cb_info, ret, INT, set_flip);
2635
2636         return ret;
2637 }
2638
2639 int camera_get_display_flip(camera_h camera, camera_flip_e *flip)
2640 {
2641         int ret = CAMERA_ERROR_NONE;
2642         int get_flip = CAMERA_FLIP_NONE;
2643         camera_cli_s *pc = NULL;
2644
2645         if (camera == NULL || flip == NULL) {
2646                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2647                 return CAMERA_ERROR_INVALID_PARAMETER;
2648         }
2649
2650         pc = (camera_cli_s *)camera;
2651
2652         if (pc->cb_info == NULL) {
2653                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2654                 return CAMERA_ERROR_INVALID_PARAMETER;
2655         }
2656
2657         muse_camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_FLIP,
2658                 pc->cb_info->fd, pc->cb_info, ret);
2659
2660         if (ret == CAMERA_ERROR_NONE) {
2661                 muse_camera_msg_get(get_flip, pc->cb_info->recv_msg);
2662                 *flip = (camera_flip_e)get_flip;
2663         }
2664
2665         return ret;
2666 }
2667
2668 int camera_set_display_visible(camera_h camera, bool visible)
2669 {
2670         int ret = CAMERA_ERROR_NONE;
2671         int set_visible = (int)visible;
2672         camera_cli_s *pc = NULL;
2673
2674         if (camera == NULL) {
2675                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2676                 return CAMERA_ERROR_INVALID_PARAMETER;
2677         }
2678
2679         pc = (camera_cli_s *)camera;
2680
2681         if (pc->cb_info == NULL) {
2682                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2683                 return CAMERA_ERROR_INVALID_PARAMETER;
2684         }
2685
2686         muse_camera_msg_send1(MUSE_CAMERA_API_SET_DISPLAY_VISIBLE,
2687                 pc->cb_info->fd, pc->cb_info, ret, INT, set_visible);
2688
2689         return ret;
2690 }
2691
2692 int camera_is_display_visible(camera_h camera, bool *visible)
2693 {
2694         int ret = CAMERA_ERROR_NONE;
2695         int get_visible = true;
2696         camera_cli_s *pc = NULL;
2697
2698         if (camera == NULL || visible == NULL) {
2699                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2700                 return CAMERA_ERROR_INVALID_PARAMETER;
2701         }
2702
2703         pc = (camera_cli_s *)camera;
2704
2705         if (pc->cb_info == NULL) {
2706                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2707                 return CAMERA_ERROR_INVALID_PARAMETER;
2708         }
2709
2710         muse_camera_msg_send(MUSE_CAMERA_API_IS_DISPLAY_VISIBLE,
2711                 pc->cb_info->fd, pc->cb_info, ret);
2712
2713         if (ret == CAMERA_ERROR_NONE) {
2714                 muse_camera_msg_get(get_visible, pc->cb_info->recv_msg);
2715                 *visible = (bool)get_visible;
2716         }
2717
2718         return ret;
2719 }
2720
2721 int camera_set_display_mode(camera_h camera, camera_display_mode_e mode)
2722 {
2723         int ret = CAMERA_ERROR_NONE;
2724         int set_mode = (int)mode;
2725         camera_cli_s *pc = NULL;
2726
2727         if (camera == NULL) {
2728                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2729                 return CAMERA_ERROR_INVALID_PARAMETER;
2730         }
2731
2732         if (mode < CAMERA_DISPLAY_MODE_LETTER_BOX || mode > CAMERA_DISPLAY_MODE_CROPPED_FULL) {
2733                 LOGE("Invalid mode %d", mode);
2734                 return CAMERA_ERROR_INVALID_PARAMETER;
2735         }
2736
2737         pc = (camera_cli_s *)camera;
2738
2739         if (pc->cb_info == NULL) {
2740                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2741                 return CAMERA_ERROR_INVALID_PARAMETER;
2742         }
2743
2744         muse_camera_msg_send1(MUSE_CAMERA_API_SET_DISPLAY_MODE,
2745                 pc->cb_info->fd, pc->cb_info, ret, INT, set_mode);
2746
2747         return ret;
2748 }
2749
2750 int camera_get_display_mode(camera_h camera, camera_display_mode_e *mode)
2751 {
2752         int ret = CAMERA_ERROR_NONE;
2753         int get_mode = CAMERA_DISPLAY_MODE_LETTER_BOX;
2754         camera_cli_s *pc = NULL;
2755
2756         if (camera == NULL || mode == NULL) {
2757                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2758                 return CAMERA_ERROR_INVALID_PARAMETER;
2759         }
2760
2761         pc = (camera_cli_s *)camera;
2762
2763         if (pc->cb_info == NULL) {
2764                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2765                 return CAMERA_ERROR_INVALID_PARAMETER;
2766         }
2767
2768         muse_camera_msg_send(MUSE_CAMERA_API_GET_DISPLAY_MODE,
2769                 pc->cb_info->fd, pc->cb_info, ret);
2770
2771         if (ret == CAMERA_ERROR_NONE) {
2772                 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
2773                 *mode = (camera_display_mode_e)get_mode;
2774         }
2775
2776         return ret;
2777 }
2778
2779 int camera_get_capture_resolution(camera_h camera, int *width, int *height)
2780 {
2781         if (camera == NULL || width == NULL || height == NULL) {
2782                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2783                 return CAMERA_ERROR_INVALID_PARAMETER;
2784         }
2785         int ret = CAMERA_ERROR_NONE;
2786
2787         camera_cli_s *pc = (camera_cli_s *)camera;
2788         muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_RESOLUTION;
2789         int sock_fd;
2790         if (pc->cb_info == NULL) {
2791                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2792                 return CAMERA_ERROR_INVALID_PARAMETER;
2793         }
2794         sock_fd = pc->cb_info->fd;
2795         int get_width;
2796         int get_height;
2797
2798         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2799         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2800
2801         if (ret == CAMERA_ERROR_NONE) {
2802                 muse_camera_msg_get(get_width, pc->cb_info->recv_msg);
2803                 muse_camera_msg_get(get_height, pc->cb_info->recv_msg);
2804                 *width = get_width;
2805                 *height = get_height;
2806         }
2807         LOGD("ret : 0x%x", ret);
2808         return ret;
2809 }
2810
2811 int camera_get_capture_format(camera_h camera, camera_pixel_format_e *format)
2812 {
2813         if (camera == NULL || format == NULL) {
2814                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2815                 return CAMERA_ERROR_INVALID_PARAMETER;
2816         }
2817         int ret = CAMERA_ERROR_NONE;
2818
2819         camera_cli_s *pc = (camera_cli_s *)camera;
2820         muse_camera_api_e api = MUSE_CAMERA_API_GET_CAPTURE_FORMAT;
2821         int get_format;
2822         int sock_fd;
2823         if (pc->cb_info == NULL) {
2824                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2825                 return CAMERA_ERROR_INVALID_PARAMETER;
2826         }
2827         sock_fd = pc->cb_info->fd;
2828
2829         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2830         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2831
2832         if (ret == CAMERA_ERROR_NONE) {
2833                 muse_camera_msg_get(get_format, pc->cb_info->recv_msg);
2834                 *format = (camera_pixel_format_e)get_format;
2835         }
2836         LOGD("ret : 0x%x", ret);
2837         return ret;
2838 }
2839
2840 int camera_get_preview_format(camera_h camera, camera_pixel_format_e *format)
2841 {
2842         if (camera == NULL || format == NULL) {
2843                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2844                 return CAMERA_ERROR_INVALID_PARAMETER;
2845         }
2846
2847         int ret = CAMERA_ERROR_NONE;
2848
2849         camera_cli_s *pc = (camera_cli_s *)camera;
2850         muse_camera_api_e api = MUSE_CAMERA_API_GET_PREVIEW_FORMAT;
2851         int get_format;
2852         int sock_fd;
2853         if (pc->cb_info == NULL) {
2854                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2855                 return CAMERA_ERROR_INVALID_PARAMETER;
2856         }
2857         sock_fd = pc->cb_info->fd;
2858
2859         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2860         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2861
2862         if (ret == CAMERA_ERROR_NONE) {
2863                 muse_camera_msg_get(get_format, pc->cb_info->recv_msg);
2864                 *format = (camera_pixel_format_e)get_format;
2865         }
2866         LOGD("ret : 0x%x", ret);
2867         return ret;
2868 }
2869
2870 int camera_get_facing_direction(camera_h camera, camera_facing_direction_e *facing_direciton)
2871 {
2872         if (camera == NULL || facing_direciton == NULL) {
2873                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2874                 return CAMERA_ERROR_INVALID_PARAMETER;
2875         }
2876
2877         int ret = CAMERA_ERROR_NONE;
2878
2879         camera_cli_s *pc = (camera_cli_s *)camera;
2880         muse_camera_api_e api = MUSE_CAMERA_API_GET_FACING_DIRECTION;
2881         int sock_fd;
2882         if (pc->cb_info == NULL) {
2883                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2884                 return CAMERA_ERROR_INVALID_PARAMETER;
2885         }
2886         sock_fd = pc->cb_info->fd;
2887         int get_facing_direction;
2888
2889         LOGD("Enter, remote_handle : %x", pc->remote_handle);
2890         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2891
2892         if (ret == CAMERA_ERROR_NONE) {
2893                 muse_camera_msg_get(get_facing_direction, pc->cb_info->recv_msg);
2894                 *facing_direciton = (camera_facing_direction_e)get_facing_direction;
2895         }
2896         LOGD("ret : 0x%x", ret);
2897         return ret;
2898 }
2899
2900 int camera_set_preview_cb(camera_h camera, camera_preview_cb callback, void *user_data)
2901 {
2902         if (camera == NULL || callback == NULL) {
2903                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2904                 return CAMERA_ERROR_INVALID_PARAMETER;
2905         }
2906         int ret = CAMERA_ERROR_NONE;
2907
2908         camera_cli_s *pc = (camera_cli_s *)camera;
2909         int sock_fd;
2910         if (pc->cb_info == NULL) {
2911                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2912                 return CAMERA_ERROR_INVALID_PARAMETER;
2913         }
2914         sock_fd = pc->cb_info->fd;
2915         muse_camera_api_e api = MUSE_CAMERA_API_SET_PREVIEW_CB;
2916
2917         LOGD("Enter, handle :%x", pc->remote_handle);
2918
2919         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = callback;
2920         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = user_data;
2921
2922         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2923         LOGD("ret : 0x%x", ret);
2924         return ret;
2925 }
2926
2927 int camera_unset_preview_cb(camera_h camera)
2928 {
2929         if (camera == NULL) {
2930                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2931                 return CAMERA_ERROR_INVALID_PARAMETER;
2932         }
2933
2934         int ret = CAMERA_ERROR_NONE;
2935
2936         camera_cli_s *pc = (camera_cli_s *)camera;
2937         muse_camera_api_e api = MUSE_CAMERA_API_UNSET_PREVIEW_CB;
2938
2939         LOGD("Enter, handle :%x", pc->remote_handle);
2940
2941         int sock_fd;
2942         if (pc->cb_info == NULL) {
2943                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2944                 return CAMERA_ERROR_INVALID_PARAMETER;
2945         }
2946         sock_fd = pc->cb_info->fd;
2947         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = (void *)NULL;
2948         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_PREVIEW] = (void *)NULL;
2949
2950         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2951         LOGD("ret : 0x%x", ret);
2952         return ret;
2953 }
2954
2955 int camera_set_media_packet_preview_cb(camera_h camera, camera_media_packet_preview_cb callback, void *user_data)
2956 {
2957         if (camera == NULL) {
2958                 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
2959                 return CAMERA_ERROR_INVALID_PARAMETER;
2960         }
2961
2962         if (camera_is_supported_media_packet_preview_cb(camera) == false) {
2963                 LOGE("NOT SUPPORTED");
2964                 return CAMERA_ERROR_NOT_SUPPORTED;
2965         }
2966
2967         if (callback == NULL) {
2968                 LOGE("INVALID_PARAMETER(0x%08x) - callback", CAMERA_ERROR_INVALID_PARAMETER);
2969                 return CAMERA_ERROR_INVALID_PARAMETER;
2970         }
2971
2972         int ret = CAMERA_ERROR_NONE;
2973
2974         camera_cli_s *pc = (camera_cli_s *)camera;
2975         muse_camera_api_e api = MUSE_CAMERA_API_SET_MEDIA_PACKET_PREVIEW_CB;
2976
2977         LOGD("Enter, handle :%x", pc->remote_handle);
2978
2979         int sock_fd;
2980         if (pc->cb_info == NULL) {
2981                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2982                 return CAMERA_ERROR_INVALID_PARAMETER;
2983         }
2984         sock_fd = pc->cb_info->fd;
2985         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = callback;
2986         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = user_data;
2987
2988         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
2989         LOGD("ret : 0x%x", ret);
2990         return ret;
2991 }
2992
2993 int camera_unset_media_packet_preview_cb(camera_h camera)
2994 {
2995         if (camera == NULL) {
2996                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
2997                 return CAMERA_ERROR_INVALID_PARAMETER;
2998         }
2999
3000         int ret = CAMERA_ERROR_NONE;
3001
3002         camera_cli_s *pc = (camera_cli_s *)camera;
3003         muse_camera_api_e api = MUSE_CAMERA_API_UNSET_MEDIA_PACKET_PREVIEW_CB;
3004
3005         LOGD("Enter, handle :%x", pc->remote_handle);
3006
3007         int sock_fd;
3008         if (pc->cb_info == NULL) {
3009                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3010                 return CAMERA_ERROR_INVALID_PARAMETER;
3011         }
3012         sock_fd = pc->cb_info->fd;
3013         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)NULL;
3014         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] = (void *)NULL;
3015
3016         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3017         LOGD("ret : 0x%x", ret);
3018         return ret;
3019 }
3020
3021 int camera_set_state_changed_cb(camera_h camera, camera_state_changed_cb callback, void *user_data)
3022 {
3023         if (camera == NULL || callback == NULL) {
3024                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3025                 return CAMERA_ERROR_INVALID_PARAMETER;
3026         }
3027         int ret = CAMERA_ERROR_NONE;
3028
3029         camera_cli_s *pc = (camera_cli_s *)camera;
3030         muse_camera_api_e api = MUSE_CAMERA_API_SET_STATE_CHANGED_CB;
3031
3032         LOGD("Enter, handle :%x", pc->remote_handle);
3033
3034         int sock_fd;
3035         if (pc->cb_info == NULL) {
3036                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3037                 return CAMERA_ERROR_INVALID_PARAMETER;
3038         }
3039         sock_fd = pc->cb_info->fd;
3040         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = callback;
3041         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = user_data;
3042
3043         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3044         LOGD("ret : 0x%x", ret);
3045         return ret;
3046 }
3047 int camera_unset_state_changed_cb(camera_h camera)
3048 {
3049         if (camera == NULL) {
3050                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3051                 return CAMERA_ERROR_INVALID_PARAMETER;
3052         }
3053         int ret = CAMERA_ERROR_NONE;
3054
3055         camera_cli_s *pc = (camera_cli_s *)camera;
3056         muse_camera_api_e api = MUSE_CAMERA_API_UNSET_STATE_CHANGED_CB;
3057
3058         LOGD("Enter, handle :%x", pc->remote_handle);
3059
3060         int sock_fd;
3061         if (pc->cb_info == NULL) {
3062                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3063                 return CAMERA_ERROR_INVALID_PARAMETER;
3064         }
3065         sock_fd = pc->cb_info->fd;
3066         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void *)NULL;
3067         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE] = (void *)NULL;
3068
3069         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3070         LOGD("ret : 0x%x", ret);
3071         return ret;
3072 }
3073
3074 int camera_set_interrupted_cb(camera_h camera, camera_interrupted_cb callback, void *user_data)
3075 {
3076         if (camera == NULL || callback == NULL) {
3077                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3078                 return CAMERA_ERROR_INVALID_PARAMETER;
3079         }
3080         int ret = CAMERA_ERROR_NONE;
3081
3082         camera_cli_s *pc = (camera_cli_s *)camera;
3083         muse_camera_api_e api = MUSE_CAMERA_API_SET_INTERRUPTED_CB;
3084
3085         LOGD("Enter, handle :%x", pc->remote_handle);
3086
3087         int sock_fd;
3088         if (pc->cb_info == NULL) {
3089                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3090                 return CAMERA_ERROR_INVALID_PARAMETER;
3091         }
3092         sock_fd = pc->cb_info->fd;
3093         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = callback;
3094         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = user_data;
3095
3096         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3097         LOGD("ret : 0x%x", ret);
3098         return ret;
3099 }
3100
3101 int camera_unset_interrupted_cb(camera_h camera)
3102 {
3103         if (camera == NULL) {
3104                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3105                 return CAMERA_ERROR_INVALID_PARAMETER;
3106         }
3107         int ret = CAMERA_ERROR_NONE;
3108
3109         camera_cli_s *pc = (camera_cli_s *)camera;
3110         muse_camera_api_e api = MUSE_CAMERA_API_UNSET_INTERRUPTED_CB;
3111
3112         LOGD("Enter, handle :%x", pc->remote_handle);
3113
3114         int sock_fd;
3115         if (pc->cb_info == NULL) {
3116                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3117                 return CAMERA_ERROR_INVALID_PARAMETER;
3118         }
3119         sock_fd = pc->cb_info->fd;
3120         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = (void *)NULL;
3121         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_INTERRUPTED] = (void *)NULL;
3122
3123         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3124         LOGD("ret : 0x%x", ret);
3125         return ret;
3126 }
3127
3128 int camera_set_focus_changed_cb(camera_h camera, camera_focus_changed_cb callback, void *user_data)
3129 {
3130         if (camera == NULL || callback == NULL) {
3131                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3132                 return CAMERA_ERROR_INVALID_PARAMETER;
3133         }
3134         int ret = CAMERA_ERROR_NONE;
3135
3136         camera_cli_s *pc = (camera_cli_s *)camera;
3137         muse_camera_api_e api = MUSE_CAMERA_API_SET_FOCUS_CHANGED_CB;
3138
3139         LOGD("Enter, handle :%x", pc->remote_handle);
3140
3141         int sock_fd;
3142         if (pc->cb_info == NULL) {
3143                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3144                 return CAMERA_ERROR_INVALID_PARAMETER;
3145         }
3146         sock_fd = pc->cb_info->fd;
3147         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = callback;
3148         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = user_data;
3149
3150         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3151         LOGD("ret : 0x%x", ret);
3152         return ret;
3153 }
3154
3155 int camera_unset_focus_changed_cb(camera_h camera)
3156 {
3157         if (camera == NULL) {
3158                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3159                 return CAMERA_ERROR_INVALID_PARAMETER;
3160         }
3161         int ret = CAMERA_ERROR_NONE;
3162
3163         camera_cli_s *pc = (camera_cli_s *)camera;
3164         muse_camera_api_e api = MUSE_CAMERA_API_UNSET_FOCUS_CHANGED_CB;
3165
3166         LOGD("Enter, handle :%x", pc->remote_handle);
3167
3168         int sock_fd;
3169         if (pc->cb_info == NULL) {
3170                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3171                 return CAMERA_ERROR_INVALID_PARAMETER;
3172         }
3173         sock_fd = pc->cb_info->fd;
3174         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void *)NULL;
3175         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE] = (void *)NULL;
3176
3177         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3178         LOGD("ret : 0x%x", ret);
3179         return ret;
3180 }
3181
3182 int camera_set_error_cb(camera_h camera, camera_error_cb callback, void *user_data)
3183 {
3184         if (camera == NULL || callback == NULL) {
3185                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3186                 return CAMERA_ERROR_INVALID_PARAMETER;
3187         }
3188         int ret = CAMERA_ERROR_NONE;
3189
3190         camera_cli_s *pc = (camera_cli_s *)camera;
3191         muse_camera_api_e api = MUSE_CAMERA_API_SET_ERROR_CB;
3192
3193         LOGD("Enter, handle :%x", pc->remote_handle);
3194
3195         int sock_fd;
3196         if (pc->cb_info == NULL) {
3197                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3198                 return CAMERA_ERROR_INVALID_PARAMETER;
3199         }
3200         sock_fd = pc->cb_info->fd;
3201         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = callback;
3202         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = user_data;
3203
3204         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3205         LOGD("ret : 0x%x", ret);
3206         return ret;
3207 }
3208
3209 int camera_unset_error_cb(camera_h camera)
3210 {
3211         if (camera == NULL) {
3212                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3213                 return CAMERA_ERROR_INVALID_PARAMETER;
3214         }
3215         int ret = CAMERA_ERROR_NONE;
3216
3217         camera_cli_s *pc = (camera_cli_s *)camera;
3218         muse_camera_api_e api = MUSE_CAMERA_API_UNSET_ERROR_CB;
3219
3220         LOGD("Enter, handle :%x", pc->remote_handle);
3221
3222         int sock_fd;
3223         if (pc->cb_info == NULL) {
3224                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3225                 return CAMERA_ERROR_INVALID_PARAMETER;
3226         }
3227         sock_fd = pc->cb_info->fd;
3228         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_ERROR] = (void *)NULL;
3229         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_ERROR] = (void *)NULL;
3230
3231         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3232         LOGD("ret : 0x%x", ret);
3233         return ret;
3234 }
3235
3236 int camera_foreach_supported_preview_resolution(camera_h camera, camera_supported_preview_resolution_cb foreach_cb , void *user_data)
3237 {
3238         if (camera == NULL || foreach_cb == NULL) {
3239                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3240                 return CAMERA_ERROR_INVALID_PARAMETER;
3241         }
3242         int ret = CAMERA_ERROR_NONE;
3243
3244         camera_cli_s *pc = (camera_cli_s *)camera;
3245         muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_RESOLUTION;
3246
3247         LOGD("Enter, handle :%x", pc->remote_handle);
3248
3249         int sock_fd;
3250         if (pc->cb_info == NULL) {
3251                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3252                 return CAMERA_ERROR_INVALID_PARAMETER;
3253         }
3254         sock_fd = pc->cb_info->fd;
3255         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = foreach_cb;
3256         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION] = user_data;
3257
3258         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3259         LOGD("ret : 0x%x", ret);
3260         return ret;
3261 }
3262
3263 int camera_foreach_supported_capture_resolution(camera_h camera, camera_supported_capture_resolution_cb foreach_cb , void *user_data)
3264 {
3265         if (camera == NULL || foreach_cb == NULL) {
3266                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3267                 return CAMERA_ERROR_INVALID_PARAMETER;
3268         }
3269         int ret = CAMERA_ERROR_NONE;
3270
3271         camera_cli_s *pc = (camera_cli_s *)camera;
3272         muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_RESOLUTION;
3273
3274         LOGD("Enter, handle :%x", pc->remote_handle);
3275
3276         int sock_fd;
3277         if (pc->cb_info == NULL) {
3278                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3279                 return CAMERA_ERROR_INVALID_PARAMETER;
3280         }
3281         sock_fd = pc->cb_info->fd;
3282         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = foreach_cb;
3283         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION] = user_data;
3284
3285         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3286         LOGD("ret : 0x%x", ret);
3287         return ret;
3288 }
3289
3290 int camera_foreach_supported_capture_format(camera_h camera, camera_supported_capture_format_cb foreach_cb , void *user_data)
3291 {
3292         if (camera == NULL || foreach_cb == NULL) {
3293                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3294                 return CAMERA_ERROR_INVALID_PARAMETER;
3295         }
3296         int ret = CAMERA_ERROR_NONE;
3297
3298         camera_cli_s *pc = (camera_cli_s *)camera;
3299         muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_CAPTURE_FORMAT;
3300
3301         LOGD("Enter, handle :%x", pc->remote_handle);
3302
3303         int sock_fd;
3304         if (pc->cb_info == NULL) {
3305                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3306                 return CAMERA_ERROR_INVALID_PARAMETER;
3307         }
3308         sock_fd = pc->cb_info->fd;
3309         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = foreach_cb;
3310         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT] = user_data;
3311
3312         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3313         LOGD("ret : 0x%x", ret);
3314         return ret;
3315 }
3316
3317
3318 int camera_foreach_supported_preview_format(camera_h camera, camera_supported_preview_format_cb foreach_cb , void *user_data)
3319 {
3320         if (camera == NULL || foreach_cb == NULL) {
3321                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3322                 return CAMERA_ERROR_INVALID_PARAMETER;
3323         }
3324         int ret = CAMERA_ERROR_NONE;
3325
3326         camera_cli_s *pc = (camera_cli_s *)camera;
3327         muse_camera_api_e api = MUSE_CAMERA_API_SET_FOREACH_SUPPORTED_PREVIEW_FORMAT;
3328
3329         LOGD("Enter, handle :%x", pc->remote_handle);
3330
3331         int sock_fd;
3332         if (pc->cb_info == NULL) {
3333                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3334                 return CAMERA_ERROR_INVALID_PARAMETER;
3335         }
3336         sock_fd = pc->cb_info->fd;
3337         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = foreach_cb;
3338         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT] = user_data;
3339
3340         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3341         LOGD("ret : 0x%x", ret);
3342         return ret;
3343 }
3344
3345
3346 int camera_get_recommended_preview_resolution(camera_h camera, int *width, int *height)
3347 {
3348         if (camera == NULL || width == NULL || height == NULL) {
3349                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3350                 return CAMERA_ERROR_INVALID_PARAMETER;
3351         }
3352         int ret = CAMERA_ERROR_NONE;
3353
3354         camera_cli_s *pc = (camera_cli_s *)camera;
3355         muse_camera_api_e api = MUSE_CAMERA_API_GET_RECOMMENDED_PREVIEW_RESOLUTION;
3356         int sock_fd;
3357         if (pc->cb_info == NULL) {
3358                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3359                 return CAMERA_ERROR_INVALID_PARAMETER;
3360         }
3361         sock_fd = pc->cb_info->fd;
3362         int get_width;
3363         int get_height;
3364
3365         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3366         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3367
3368         if (ret == CAMERA_ERROR_NONE) {
3369                 muse_camera_msg_get(get_width, pc->cb_info->recv_msg);
3370                 muse_camera_msg_get(get_height, pc->cb_info->recv_msg);
3371                 *width = get_width;
3372                 *height = get_height;
3373         }
3374         LOGD("ret : 0x%x", ret);
3375         return ret;
3376 }
3377
3378
3379 int camera_attr_get_lens_orientation(camera_h camera, int *angle)
3380 {
3381         if (camera == NULL || angle == NULL) {
3382                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3383                 return CAMERA_ERROR_INVALID_PARAMETER;
3384         }
3385         int ret = CAMERA_ERROR_NONE;
3386
3387         camera_cli_s *pc = (camera_cli_s *)camera;
3388         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_LENS_ORIENTATION;
3389         int sock_fd;
3390         if (pc->cb_info == NULL) {
3391                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3392                 return CAMERA_ERROR_INVALID_PARAMETER;
3393         }
3394         sock_fd = pc->cb_info->fd;
3395         int get_angle;
3396
3397         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3398         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3399
3400         if (ret == CAMERA_ERROR_NONE) {
3401                 muse_camera_msg_get(get_angle, pc->cb_info->recv_msg);
3402                 *angle = get_angle;
3403         }
3404         LOGD("ret : 0x%x", ret);
3405         return ret;
3406 }
3407
3408 int camera_attr_set_theater_mode(camera_h camera, camera_attr_theater_mode_e mode)
3409 {
3410         if (camera == NULL) {
3411                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3412                 return CAMERA_ERROR_INVALID_PARAMETER;
3413         }
3414         int ret = CAMERA_ERROR_NONE;
3415         camera_cli_s *pc = (camera_cli_s *)camera;
3416         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_THEATER_MODE;
3417         int sock_fd;
3418         if (pc->cb_info == NULL) {
3419                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3420                 return CAMERA_ERROR_INVALID_PARAMETER;
3421         }
3422         sock_fd = pc->cb_info->fd;
3423         int set_mode = (int)mode;
3424         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3425         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
3426         LOGD("ret : 0x%x", ret);
3427         return ret;
3428 }
3429
3430 int camera_attr_get_theater_mode(camera_h camera, camera_attr_theater_mode_e *mode)
3431 {
3432         if (camera == NULL || mode == NULL) {
3433                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3434                 return CAMERA_ERROR_INVALID_PARAMETER;
3435         }
3436
3437         int ret = CAMERA_ERROR_NONE;
3438         camera_cli_s *pc = (camera_cli_s *)camera;
3439         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_THEATER_MODE;
3440         int sock_fd;
3441         if (pc->cb_info == NULL) {
3442                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3443                 return CAMERA_ERROR_INVALID_PARAMETER;
3444         }
3445         sock_fd = pc->cb_info->fd;
3446         int get_mode;
3447         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3448         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3449
3450         if (ret == CAMERA_ERROR_NONE) {
3451                 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
3452                 *mode = (camera_attr_theater_mode_e)get_mode;
3453         }
3454         LOGD("ret : 0x%x", ret);
3455         return ret;
3456 }
3457
3458 int camera_attr_foreach_supported_theater_mode(camera_h camera, camera_attr_supported_theater_mode_cb foreach_cb, void *user_data)
3459 {
3460         if (camera == NULL || foreach_cb == NULL) {
3461                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3462                 return CAMERA_ERROR_INVALID_PARAMETER;
3463         }
3464         int ret = CAMERA_ERROR_NONE;
3465
3466         camera_cli_s *pc = (camera_cli_s *)camera;
3467         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_THEATER_MODE;
3468
3469         LOGD("Enter, handle :%x", pc->remote_handle);
3470
3471         int sock_fd;
3472         if (pc->cb_info == NULL) {
3473                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3474                 return CAMERA_ERROR_INVALID_PARAMETER;
3475         }
3476         sock_fd = pc->cb_info->fd;
3477         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = foreach_cb;
3478         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE] = user_data;
3479
3480         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3481
3482         LOGD("Finish, return :%x", ret);
3483
3484         return ret;
3485 }
3486
3487 int camera_attr_set_preview_fps(camera_h camera,  camera_attr_fps_e fps)
3488 {
3489         if (camera == NULL) {
3490                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3491                 return CAMERA_ERROR_INVALID_PARAMETER;
3492         }
3493         int ret = CAMERA_ERROR_NONE;
3494         camera_cli_s *pc = (camera_cli_s *)camera;
3495         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_PREVIEW_FPS;
3496         int sock_fd;
3497         if (pc->cb_info == NULL) {
3498                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3499                 return CAMERA_ERROR_INVALID_PARAMETER;
3500         }
3501         sock_fd = pc->cb_info->fd;
3502         int set_fps = (int)fps;
3503         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3504         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_fps);
3505         LOGD("ret : 0x%x", ret);
3506         return ret;
3507 }
3508
3509
3510 int camera_attr_set_image_quality(camera_h camera,  int quality)
3511 {
3512         if (camera == NULL) {
3513                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3514                 return CAMERA_ERROR_INVALID_PARAMETER;
3515         }
3516         int ret = CAMERA_ERROR_NONE;
3517
3518         camera_cli_s *pc = (camera_cli_s *)camera;
3519         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_IMAGE_QUALITY;
3520         int sock_fd;
3521         if (pc->cb_info == NULL) {
3522                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3523                 return CAMERA_ERROR_INVALID_PARAMETER;
3524         }
3525         sock_fd = pc->cb_info->fd;
3526         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3527         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, quality);
3528         LOGD("ret : 0x%x", ret);
3529         return ret;
3530 }
3531
3532 int camera_attr_get_preview_fps(camera_h camera,  camera_attr_fps_e *fps)
3533 {
3534         if (camera == NULL || fps == NULL) {
3535                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3536                 return CAMERA_ERROR_INVALID_PARAMETER;
3537         }
3538         int ret = CAMERA_ERROR_NONE;
3539
3540         camera_cli_s *pc = (camera_cli_s *)camera;
3541         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_PREVIEW_FPS;
3542         int get_fps;
3543         int sock_fd;
3544         if (pc->cb_info == NULL) {
3545                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3546                 return CAMERA_ERROR_INVALID_PARAMETER;
3547         }
3548         sock_fd = pc->cb_info->fd;
3549
3550         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3551         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3552
3553         if (ret == CAMERA_ERROR_NONE) {
3554                 muse_camera_msg_get(get_fps, pc->cb_info->recv_msg);
3555                 *fps = (camera_attr_fps_e)get_fps;
3556         }
3557         LOGD("ret : 0x%x", ret);
3558         return ret;
3559 }
3560
3561
3562 int camera_attr_get_image_quality(camera_h camera, int *quality)
3563 {
3564         if (camera == NULL || quality == NULL) {
3565                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3566                 return CAMERA_ERROR_INVALID_PARAMETER;
3567         }
3568         int ret = CAMERA_ERROR_NONE;
3569
3570         camera_cli_s *pc = (camera_cli_s *)camera;
3571         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_IMAGE_QUALITY;
3572         int sock_fd;
3573         if (pc->cb_info == NULL) {
3574                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3575                 return CAMERA_ERROR_INVALID_PARAMETER;
3576         }
3577         sock_fd = pc->cb_info->fd;
3578         int get_quality;
3579         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3580         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3581
3582         if (ret == CAMERA_ERROR_NONE) {
3583                 muse_camera_msg_get(get_quality, pc->cb_info->recv_msg);
3584                 *quality = get_quality;
3585         }
3586         LOGD("ret : 0x%x", ret);
3587         return ret;
3588 }
3589
3590
3591 int camera_attr_get_encoded_preview_bitrate(camera_h camera, int *bitrate)
3592 {
3593         if (camera == NULL || bitrate == NULL) {
3594                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3595                 return CAMERA_ERROR_INVALID_PARAMETER;
3596         }
3597
3598         int ret = CAMERA_ERROR_NONE;
3599
3600         camera_cli_s *pc = (camera_cli_s *)camera;
3601         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_BITRATE;
3602         int sock_fd;
3603         if (pc->cb_info == NULL) {
3604                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3605                 return CAMERA_ERROR_INVALID_PARAMETER;
3606         }
3607         sock_fd = pc->cb_info->fd;
3608         int get_bitrate;
3609
3610         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3611         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3612
3613         if (ret == CAMERA_ERROR_NONE) {
3614                 muse_camera_msg_get(get_bitrate, pc->cb_info->recv_msg);
3615                 *bitrate = get_bitrate;
3616         }
3617         LOGD("ret : 0x%x", ret);
3618         return ret;
3619 }
3620
3621
3622 int camera_attr_set_encoded_preview_bitrate(camera_h camera, int bitrate)
3623 {
3624         if (camera == NULL) {
3625                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3626                 return CAMERA_ERROR_INVALID_PARAMETER;
3627         }
3628
3629         int ret = CAMERA_ERROR_NONE;
3630
3631         camera_cli_s *pc = (camera_cli_s *)camera;
3632         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_BITRATE;
3633         int sock_fd;
3634         if (pc->cb_info == NULL) {
3635                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3636                 return CAMERA_ERROR_INVALID_PARAMETER;
3637         }
3638         sock_fd = pc->cb_info->fd;
3639         int set_bitrate = bitrate;
3640         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3641         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_bitrate);
3642         LOGD("ret : 0x%x", ret);
3643         return ret;
3644 }
3645
3646
3647 int camera_attr_get_encoded_preview_gop_interval(camera_h camera, int *interval)
3648 {
3649         if (camera == NULL || interval == NULL) {
3650                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3651                 return CAMERA_ERROR_INVALID_PARAMETER;
3652         }
3653
3654         int ret = CAMERA_ERROR_NONE;
3655
3656         camera_cli_s *pc = (camera_cli_s *)camera;
3657         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ENCODED_PREVIEW_GOP_INTERVAL;
3658         int sock_fd;
3659         if (pc->cb_info == NULL) {
3660                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3661                 return CAMERA_ERROR_INVALID_PARAMETER;
3662         }
3663         sock_fd = pc->cb_info->fd;
3664         int get_gop_interval;
3665
3666         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3667         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3668
3669         if (ret == CAMERA_ERROR_NONE) {
3670                 muse_camera_msg_get(get_gop_interval, pc->cb_info->recv_msg);
3671                 *interval = get_gop_interval;
3672         }
3673         LOGD("ret : 0x%x", ret);
3674         return ret;
3675 }
3676
3677
3678 int camera_attr_set_encoded_preview_gop_interval(camera_h camera, int interval)
3679 {
3680         if (camera == NULL) {
3681                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3682                 return CAMERA_ERROR_INVALID_PARAMETER;
3683         }
3684
3685         int ret = CAMERA_ERROR_NONE;
3686
3687         camera_cli_s *pc = (camera_cli_s *)camera;
3688         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ENCODED_PREVIEW_GOP_INTERVAL;
3689         int sock_fd;
3690         if (pc->cb_info == NULL) {
3691                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3692                 return CAMERA_ERROR_INVALID_PARAMETER;
3693         }
3694         sock_fd = pc->cb_info->fd;
3695         int set_gop_interval = interval;
3696         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3697         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_gop_interval);
3698         LOGD("ret : 0x%x", ret);
3699         return ret;
3700 }
3701
3702
3703 int camera_attr_set_zoom(camera_h camera, int zoom)
3704 {
3705         if (camera == NULL) {
3706                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3707                 return CAMERA_ERROR_INVALID_PARAMETER;
3708         }
3709         int ret = CAMERA_ERROR_NONE;
3710
3711         camera_cli_s *pc = (camera_cli_s *)camera;
3712         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ZOOM;
3713         int sock_fd;
3714         if (pc->cb_info == NULL) {
3715                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3716                 return CAMERA_ERROR_INVALID_PARAMETER;
3717         }
3718         sock_fd = pc->cb_info->fd;
3719
3720         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3721         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, zoom);
3722         LOGD("ret : 0x%x", ret);
3723         return ret;
3724 }
3725
3726 int camera_attr_set_af_mode(camera_h camera,  camera_attr_af_mode_e mode)
3727 {
3728         if (camera == NULL) {
3729                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3730                 return CAMERA_ERROR_INVALID_PARAMETER;
3731         }
3732         int ret = CAMERA_ERROR_NONE;
3733
3734         camera_cli_s *pc = (camera_cli_s *)camera;
3735         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_MODE;
3736         int sock_fd;
3737         if (pc->cb_info == NULL) {
3738                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3739                 return CAMERA_ERROR_INVALID_PARAMETER;
3740         }
3741         sock_fd = pc->cb_info->fd;
3742         int set_mode = (int)mode;
3743         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3744         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
3745         LOGD("ret : 0x%x", ret);
3746         return ret;
3747 }
3748
3749 int camera_attr_set_af_area(camera_h camera, int x, int y)
3750 {
3751         if (camera == NULL) {
3752                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3753                 return CAMERA_ERROR_INVALID_PARAMETER;
3754         }
3755         int ret = CAMERA_ERROR_NONE;
3756         camera_cli_s *pc = (camera_cli_s *)camera;
3757         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_AF_AREA;
3758         int sock_fd = pc->cb_info->fd;
3759         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3760         muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, x, INT, y);
3761         LOGD("ret : 0x%x", ret);
3762         return ret;
3763 }
3764
3765
3766 int camera_attr_clear_af_area(camera_h camera)
3767 {
3768         if (camera == NULL) {
3769                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3770                 return CAMERA_ERROR_INVALID_PARAMETER;
3771         }
3772         int ret = CAMERA_ERROR_NONE;
3773
3774         camera_cli_s *pc = (camera_cli_s *)camera;
3775         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_CLEAR_AF_AREA;
3776         int sock_fd;
3777         if (pc->cb_info == NULL) {
3778                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3779                 return CAMERA_ERROR_INVALID_PARAMETER;
3780         }
3781         sock_fd = pc->cb_info->fd;
3782         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3783         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
3784         LOGD("ret : 0x%x", ret);
3785         return ret;
3786 }
3787
3788
3789 int camera_attr_set_exposure_mode(camera_h camera,  camera_attr_exposure_mode_e mode)
3790 {
3791         if (camera == NULL) {
3792                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3793                 return CAMERA_ERROR_INVALID_PARAMETER;
3794         }
3795
3796         if (mode < CAMERA_ATTR_EXPOSURE_MODE_OFF || mode > CAMERA_ATTR_EXPOSURE_MODE_CUSTOM) {
3797                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3798                 return CAMERA_ERROR_INVALID_PARAMETER;
3799         }
3800
3801         int ret = CAMERA_ERROR_NONE;
3802         camera_cli_s *pc = (camera_cli_s *)camera;
3803         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE_MODE;
3804         int set_mode = (int)mode;
3805         int sock_fd;
3806         if (pc->cb_info == NULL) {
3807                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3808                 return CAMERA_ERROR_INVALID_PARAMETER;
3809         }
3810         sock_fd = pc->cb_info->fd;
3811         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3812         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
3813         LOGD("ret : 0x%x", ret);
3814         return ret;
3815 }
3816
3817
3818 int camera_attr_set_exposure(camera_h camera, int value)
3819 {
3820         if (camera == NULL) {
3821                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3822                 return CAMERA_ERROR_INVALID_PARAMETER;
3823         }
3824         int ret = CAMERA_ERROR_NONE;
3825
3826         camera_cli_s *pc = (camera_cli_s *)camera;
3827         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EXPOSURE;
3828         int sock_fd;
3829         if (pc->cb_info == NULL) {
3830                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3831                 return CAMERA_ERROR_INVALID_PARAMETER;
3832         }
3833         sock_fd = pc->cb_info->fd;
3834
3835         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3836         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, value);
3837         LOGD("ret : 0x%x", ret);
3838         return ret;
3839 }
3840
3841
3842 int camera_attr_set_iso(camera_h camera, camera_attr_iso_e iso)
3843 {
3844         if (camera == NULL) {
3845                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3846                 return CAMERA_ERROR_INVALID_PARAMETER;
3847         }
3848         int ret = CAMERA_ERROR_NONE;
3849
3850         camera_cli_s *pc = (camera_cli_s *)camera;
3851         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_ISO;
3852         int sock_fd;
3853         if (pc->cb_info == NULL) {
3854                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3855                 return CAMERA_ERROR_INVALID_PARAMETER;
3856         }
3857         sock_fd = pc->cb_info->fd;
3858         int set_iso = (int)iso;
3859         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3860         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_iso);
3861         LOGD("ret : 0x%x", ret);
3862         return ret;
3863 }
3864
3865
3866 int camera_attr_set_brightness(camera_h camera, int level)
3867 {
3868         if (camera == NULL) {
3869                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3870                 return CAMERA_ERROR_INVALID_PARAMETER;
3871         }
3872         int ret = CAMERA_ERROR_NONE;
3873
3874         camera_cli_s *pc = (camera_cli_s *)camera;
3875         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_BRIGHTNESS;
3876         int sock_fd;
3877         if (pc->cb_info == NULL) {
3878                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3879                 return CAMERA_ERROR_INVALID_PARAMETER;
3880         }
3881         sock_fd = pc->cb_info->fd;
3882
3883         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3884         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, level);
3885         LOGD("ret : 0x%x", ret);
3886         return ret;
3887 }
3888
3889
3890 int camera_attr_set_contrast(camera_h camera, int level)
3891 {
3892         if (camera == NULL) {
3893                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3894                 return CAMERA_ERROR_INVALID_PARAMETER;
3895         }
3896         int ret = CAMERA_ERROR_NONE;
3897
3898         camera_cli_s *pc = (camera_cli_s *)camera;
3899         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_CONTRAST;
3900         int sock_fd;
3901         if (pc->cb_info == NULL) {
3902                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3903                 return CAMERA_ERROR_INVALID_PARAMETER;
3904         }
3905         sock_fd = pc->cb_info->fd;
3906
3907         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3908         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, level);
3909         LOGD("ret : 0x%x", ret);
3910         return ret;
3911 }
3912
3913
3914 int camera_attr_set_whitebalance(camera_h camera, camera_attr_whitebalance_e wb)
3915 {
3916         if (camera == NULL) {
3917                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3918                 return CAMERA_ERROR_INVALID_PARAMETER;
3919         }
3920
3921         if (wb < CAMERA_ATTR_WHITE_BALANCE_NONE || wb > CAMERA_ATTR_WHITE_BALANCE_CUSTOM) {
3922                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_NOT_SUPPORTED);
3923                 return CAMERA_ERROR_NOT_SUPPORTED;
3924         }
3925
3926         int ret = CAMERA_ERROR_NONE;
3927
3928         camera_cli_s *pc = (camera_cli_s *)camera;
3929         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_WHITEBALANCE;
3930         int sock_fd;
3931         if (pc->cb_info == NULL) {
3932                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3933                 return CAMERA_ERROR_INVALID_PARAMETER;
3934         }
3935         sock_fd = pc->cb_info->fd;
3936         int set_whitebalance = (int)wb;
3937         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3938         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_whitebalance);
3939         LOGD("ret : 0x%x", ret);
3940         return ret;
3941 }
3942
3943
3944 int camera_attr_set_effect(camera_h camera, camera_attr_effect_mode_e effect)
3945 {
3946         if (camera == NULL) {
3947                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3948                 return CAMERA_ERROR_INVALID_PARAMETER;
3949         }
3950         int ret = CAMERA_ERROR_NONE;
3951
3952         camera_cli_s *pc = (camera_cli_s *)camera;
3953         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_EFFECT;
3954         int sock_fd;
3955         if (pc->cb_info == NULL) {
3956                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3957                 return CAMERA_ERROR_INVALID_PARAMETER;
3958         }
3959         sock_fd = pc->cb_info->fd;
3960         int set_effect = (int)effect;
3961         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3962         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_effect);
3963         LOGD("ret : 0x%x", ret);
3964         return ret;
3965 }
3966
3967
3968 int camera_attr_set_scene_mode(camera_h camera, camera_attr_scene_mode_e mode)
3969 {
3970         if (camera == NULL) {
3971                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3972                 return CAMERA_ERROR_INVALID_PARAMETER;
3973         }
3974         int ret = CAMERA_ERROR_NONE;
3975
3976         camera_cli_s *pc = (camera_cli_s *)camera;
3977         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_SCENE_MODE;
3978         int sock_fd;
3979         if (pc->cb_info == NULL) {
3980                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3981                 return CAMERA_ERROR_INVALID_PARAMETER;
3982         }
3983         sock_fd = pc->cb_info->fd;
3984         int set_mode = (int)mode;
3985         LOGD("Enter, remote_handle : %x", pc->remote_handle);
3986         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
3987         LOGD("ret : 0x%x", ret);
3988         return ret;
3989 }
3990
3991
3992 int camera_attr_enable_tag(camera_h camera, bool enable)
3993 {
3994         if (camera == NULL) {
3995                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
3996                 return CAMERA_ERROR_INVALID_PARAMETER;
3997         }
3998         int ret = CAMERA_ERROR_NONE;
3999         camera_cli_s *pc = (camera_cli_s *)camera;
4000         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_TAG;
4001         int sock_fd;
4002         if (pc->cb_info == NULL) {
4003                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4004                 return CAMERA_ERROR_INVALID_PARAMETER;
4005         }
4006         sock_fd = pc->cb_info->fd;
4007         int set_enable = (int)enable;
4008
4009         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4010         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable);
4011         LOGD("ret : 0x%x", ret);
4012         return ret;
4013 }
4014
4015
4016 int camera_attr_set_tag_image_description(camera_h camera, const char *description)
4017 {
4018         if (camera == NULL) {
4019                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4020                 return CAMERA_ERROR_INVALID_PARAMETER;
4021         }
4022         if (description == NULL) {
4023                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4024                 return CAMERA_ERROR_INVALID_PARAMETER;
4025         }
4026         int ret = CAMERA_ERROR_NONE;
4027         camera_cli_s *pc = (camera_cli_s *)camera;
4028         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_IMAGE_DESCRIPTION;
4029         int sock_fd;
4030         if (pc->cb_info == NULL) {
4031                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4032                 return CAMERA_ERROR_INVALID_PARAMETER;
4033         }
4034         sock_fd = pc->cb_info->fd;
4035         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4036         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, STRING, description);
4037         LOGD("ret : 0x%x", ret);
4038         return ret;
4039 }
4040
4041
4042 int camera_attr_set_tag_orientation(camera_h camera,  camera_attr_tag_orientation_e orientation)
4043 {
4044         if (camera == NULL) {
4045                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4046                 return CAMERA_ERROR_INVALID_PARAMETER;
4047         }
4048         int ret = CAMERA_ERROR_NONE;
4049         camera_cli_s *pc = (camera_cli_s *)camera;
4050         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_ORIENTATION;
4051         int sock_fd;
4052         if (pc->cb_info == NULL) {
4053                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4054                 return CAMERA_ERROR_INVALID_PARAMETER;
4055         }
4056         sock_fd = pc->cb_info->fd;
4057         int set_orientation = (int)orientation;
4058
4059         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4060         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_orientation);
4061         LOGD("ret : 0x%x", ret);
4062         return ret;
4063 }
4064
4065
4066 int camera_attr_set_tag_software(camera_h camera,  const char *software)
4067 {
4068         if (camera == NULL) {
4069                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4070                 return CAMERA_ERROR_INVALID_PARAMETER;
4071         }
4072         if (software == NULL) {
4073                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4074                 return CAMERA_ERROR_INVALID_PARAMETER;
4075         }
4076         int ret = CAMERA_ERROR_NONE;
4077         camera_cli_s *pc = (camera_cli_s *)camera;
4078         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_TAG_SOFTWARE;
4079         int sock_fd;
4080         if (pc->cb_info == NULL) {
4081                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4082                 return CAMERA_ERROR_INVALID_PARAMETER;
4083         }
4084         sock_fd = pc->cb_info->fd;
4085         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4086         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, STRING, software);
4087         LOGD("ret : 0x%x", ret);
4088         return ret;
4089 }
4090
4091
4092 int camera_attr_set_geotag(camera_h camera, double latitude , double longitude, double altitude)
4093 {
4094         if (camera == NULL) {
4095                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4096                 return CAMERA_ERROR_INVALID_PARAMETER;
4097         }
4098         int ret = CAMERA_ERROR_NONE;
4099         camera_cli_s *pc = (camera_cli_s *)camera;
4100         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_GEOTAG;
4101         int sock_fd;
4102         if (pc->cb_info == NULL) {
4103                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4104                 return CAMERA_ERROR_INVALID_PARAMETER;
4105         }
4106         sock_fd = pc->cb_info->fd;
4107         double set_geotag[3] = { latitude, longitude, altitude };
4108
4109         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4110         muse_camera_msg_send_array(api, sock_fd, pc->cb_info, ret,
4111                                                                         set_geotag, sizeof(set_geotag), sizeof(double));
4112         LOGD("ret : 0x%x", ret);
4113         return ret;
4114 }
4115
4116
4117 int camera_attr_remove_geotag(camera_h camera)
4118 {
4119         if (camera == NULL) {
4120                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4121                 return CAMERA_ERROR_INVALID_PARAMETER;
4122         }
4123         int ret = CAMERA_ERROR_NONE;
4124         camera_cli_s *pc = (camera_cli_s *)camera;
4125         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_REMOVE_GEOTAG;
4126         int sock_fd;
4127         if (pc->cb_info == NULL) {
4128                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4129                 return CAMERA_ERROR_INVALID_PARAMETER;
4130         }
4131         sock_fd = pc->cb_info->fd;
4132         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4133         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4134         LOGD("ret : 0x%x", ret);
4135         return ret;
4136 }
4137
4138
4139 int camera_attr_set_flash_mode(camera_h camera, camera_attr_flash_mode_e mode)
4140 {
4141         if (camera == NULL) {
4142                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4143                 return CAMERA_ERROR_INVALID_PARAMETER;
4144         }
4145         int ret = CAMERA_ERROR_NONE;
4146         camera_cli_s *pc = (camera_cli_s *)camera;
4147         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_FLASH_MODE;
4148         int sock_fd;
4149         if (pc->cb_info == NULL) {
4150                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4151                 return CAMERA_ERROR_INVALID_PARAMETER;
4152         }
4153         sock_fd = pc->cb_info->fd;
4154         int set_mode = (int)mode;
4155
4156         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4157         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
4158         LOGD("ret : 0x%x", ret);
4159         return ret;
4160 }
4161
4162
4163 int camera_attr_get_zoom(camera_h camera, int *zoom)
4164 {
4165         if (camera == NULL || zoom == NULL) {
4166                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4167                 return CAMERA_ERROR_INVALID_PARAMETER;
4168         }
4169         int ret = CAMERA_ERROR_NONE;
4170
4171         camera_cli_s *pc = (camera_cli_s *)camera;
4172         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM;
4173         int get_zoom;
4174         int sock_fd;
4175         if (pc->cb_info == NULL) {
4176                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4177                 return CAMERA_ERROR_INVALID_PARAMETER;
4178         }
4179         sock_fd = pc->cb_info->fd;
4180
4181         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4182         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4183
4184         if (ret == CAMERA_ERROR_NONE) {
4185                 muse_camera_msg_get(get_zoom, pc->cb_info->recv_msg);
4186                 *zoom = get_zoom;
4187         }
4188         LOGD("ret : 0x%x", ret);
4189         return ret;
4190 }
4191
4192
4193 int camera_attr_get_zoom_range(camera_h camera, int *min, int *max)
4194 {
4195         if (camera == NULL || min == NULL || max == NULL) {
4196                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4197                 return CAMERA_ERROR_INVALID_PARAMETER;
4198         }
4199         int ret = CAMERA_ERROR_NONE;
4200         camera_cli_s *pc = (camera_cli_s *)camera;
4201         int sock_fd;
4202         if (pc->cb_info == NULL) {
4203                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4204                 return CAMERA_ERROR_INVALID_PARAMETER;
4205         }
4206         sock_fd = pc->cb_info->fd;
4207         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ZOOM_RANGE;
4208         int get_min;
4209         int get_max;
4210
4211         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4212         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4213
4214         if (ret == CAMERA_ERROR_NONE) {
4215                 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
4216                 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
4217                 *min = get_min;
4218                 *max = get_max;
4219         }
4220         LOGD("ret : 0x%x", ret);
4221         return ret;
4222 }
4223
4224
4225 int camera_attr_get_af_mode(camera_h camera, camera_attr_af_mode_e *mode)
4226 {
4227         if (camera == NULL || mode == NULL) {
4228                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4229                 return CAMERA_ERROR_INVALID_PARAMETER;
4230         }
4231         int ret = CAMERA_ERROR_NONE;
4232         camera_cli_s *pc = (camera_cli_s *)camera;
4233         int sock_fd;
4234         if (pc->cb_info == NULL) {
4235                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4236                 return CAMERA_ERROR_INVALID_PARAMETER;
4237         }
4238         sock_fd = pc->cb_info->fd;
4239         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_AF_MODE;
4240         int get_mode;
4241
4242         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4243         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4244
4245         if (ret == CAMERA_ERROR_NONE) {
4246                 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
4247                 *mode = (camera_attr_af_mode_e)get_mode;
4248         }
4249         LOGD("ret : 0x%x", ret);
4250         return ret;
4251 }
4252
4253
4254 int camera_attr_get_exposure_mode(camera_h camera, camera_attr_exposure_mode_e *mode)
4255 {
4256         if (camera == NULL || mode == NULL) {
4257                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4258                 return CAMERA_ERROR_INVALID_PARAMETER;
4259         }
4260         int ret = CAMERA_ERROR_NONE;
4261         camera_cli_s *pc = (camera_cli_s *)camera;
4262         int sock_fd;
4263         if (pc->cb_info == NULL) {
4264                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4265                 return CAMERA_ERROR_INVALID_PARAMETER;
4266         }
4267         sock_fd = pc->cb_info->fd;
4268         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_MODE;
4269         int get_mode;
4270
4271         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4272         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4273
4274         if (ret == CAMERA_ERROR_NONE) {
4275                 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
4276                 *mode = (camera_attr_exposure_mode_e)get_mode;
4277         }
4278         LOGD("ret : 0x%x", ret);
4279         return ret;
4280 }
4281
4282 int camera_attr_get_exposure(camera_h camera, int *value)
4283 {
4284         if (camera == NULL || value == NULL) {
4285                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4286                 return CAMERA_ERROR_INVALID_PARAMETER;
4287         }
4288         int ret = CAMERA_ERROR_NONE;
4289         camera_cli_s *pc = (camera_cli_s *)camera;
4290         int sock_fd;
4291         if (pc->cb_info == NULL) {
4292                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4293                 return CAMERA_ERROR_INVALID_PARAMETER;
4294         }
4295         sock_fd = pc->cb_info->fd;
4296         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE;
4297         int get_value;
4298
4299         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4300         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4301
4302         if (ret == CAMERA_ERROR_NONE) {
4303                 muse_camera_msg_get(get_value, pc->cb_info->recv_msg);
4304                 *value = get_value;
4305         }
4306         LOGD("ret : 0x%x", ret);
4307         return ret;
4308 }
4309
4310
4311 int camera_attr_get_exposure_range(camera_h camera, int *min, int *max)
4312 {
4313         if (camera == NULL || min == NULL || max == NULL) {
4314                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4315                 return CAMERA_ERROR_INVALID_PARAMETER;
4316         }
4317         int ret = CAMERA_ERROR_NONE;
4318         camera_cli_s *pc = (camera_cli_s *)camera;
4319         int sock_fd;
4320         if (pc->cb_info == NULL) {
4321                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4322                 return CAMERA_ERROR_INVALID_PARAMETER;
4323         }
4324         sock_fd = pc->cb_info->fd;
4325         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EXPOSURE_RANGE;
4326         int get_min;
4327         int get_max;
4328
4329         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4330         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4331
4332         if (ret == CAMERA_ERROR_NONE) {
4333                 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
4334                 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
4335                 *min = get_min;
4336                 *max = get_max;
4337         }
4338         LOGD("ret : 0x%x", ret);
4339         return ret;
4340 }
4341
4342
4343 int camera_attr_get_iso(camera_h camera, camera_attr_iso_e *iso)
4344 {
4345         if (camera == NULL || iso == NULL) {
4346                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4347                 return CAMERA_ERROR_INVALID_PARAMETER;
4348         }
4349         int ret = CAMERA_ERROR_NONE;
4350         camera_cli_s *pc = (camera_cli_s *)camera;
4351         int sock_fd;
4352         if (pc->cb_info == NULL) {
4353                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4354                 return CAMERA_ERROR_INVALID_PARAMETER;
4355         }
4356         sock_fd = pc->cb_info->fd;
4357         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_ISO;
4358         int get_iso;
4359
4360         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4361         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4362
4363         if (ret == CAMERA_ERROR_NONE) {
4364                 muse_camera_msg_get(get_iso, pc->cb_info->recv_msg);
4365                 *iso = (camera_attr_iso_e)get_iso;
4366         }
4367         LOGD("ret : 0x%x", ret);
4368         return ret;
4369 }
4370
4371
4372 int camera_attr_get_brightness(camera_h camera,  int *level)
4373 {
4374         if (camera == NULL || level == NULL) {
4375                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4376                 return CAMERA_ERROR_INVALID_PARAMETER;
4377         }
4378         int ret = CAMERA_ERROR_NONE;
4379         camera_cli_s *pc = (camera_cli_s *)camera;
4380         int sock_fd;
4381         if (pc->cb_info == NULL) {
4382                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4383                 return CAMERA_ERROR_INVALID_PARAMETER;
4384         }
4385         sock_fd = pc->cb_info->fd;
4386         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS;
4387         int get_level;
4388
4389         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4390         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4391
4392         if (ret == CAMERA_ERROR_NONE) {
4393                 muse_camera_msg_get(get_level, pc->cb_info->recv_msg);
4394                 *level = get_level;
4395         }
4396         LOGD("ret : 0x%x", ret);
4397         return ret;
4398 }
4399
4400
4401 int camera_attr_get_brightness_range(camera_h camera, int *min, int *max)
4402 {
4403         if (camera == NULL || min == NULL || max == NULL) {
4404                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4405                 return CAMERA_ERROR_INVALID_PARAMETER;
4406         }
4407         int ret = CAMERA_ERROR_NONE;
4408         camera_cli_s *pc = (camera_cli_s *)camera;
4409         int sock_fd;
4410         if (pc->cb_info == NULL) {
4411                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4412                 return CAMERA_ERROR_INVALID_PARAMETER;
4413         }
4414         sock_fd = pc->cb_info->fd;
4415         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_BRIGHTNESS_RANGE;
4416         int get_min;
4417         int get_max;
4418
4419         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4420         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4421
4422         if (ret == CAMERA_ERROR_NONE) {
4423                 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
4424                 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
4425                 *min = get_min;
4426                 *max = get_max;
4427         }
4428         LOGD("ret : 0x%x", ret);
4429         return ret;
4430 }
4431
4432
4433 int camera_attr_get_contrast(camera_h camera,  int *level)
4434 {
4435         if (camera == NULL || level == NULL) {
4436                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4437                 return CAMERA_ERROR_INVALID_PARAMETER;
4438         }
4439         int ret = CAMERA_ERROR_NONE;
4440         camera_cli_s *pc = (camera_cli_s *)camera;
4441         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST;
4442         int sock_fd;
4443         if (pc->cb_info == NULL) {
4444                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4445                 return CAMERA_ERROR_INVALID_PARAMETER;
4446         }
4447         sock_fd = pc->cb_info->fd;
4448         int get_level;
4449
4450         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4451         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4452
4453         if (ret == CAMERA_ERROR_NONE) {
4454                 muse_camera_msg_get(get_level, pc->cb_info->recv_msg);
4455                 *level = get_level;
4456         }
4457         LOGD("ret : 0x%x", ret);
4458         return ret;
4459 }
4460
4461
4462 int camera_attr_get_contrast_range(camera_h camera, int *min , int *max)
4463 {
4464         if (camera == NULL || min == NULL || max == NULL) {
4465                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4466                 return CAMERA_ERROR_INVALID_PARAMETER;
4467         }
4468         int ret = CAMERA_ERROR_NONE;
4469         camera_cli_s *pc = (camera_cli_s *)camera;
4470         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_CONTRAST_RANGE;
4471         int sock_fd;
4472         if (pc->cb_info == NULL) {
4473                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4474                 return CAMERA_ERROR_INVALID_PARAMETER;
4475         }
4476         sock_fd = pc->cb_info->fd;
4477         int get_min;
4478         int get_max;
4479
4480         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4481         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4482
4483         if (ret == CAMERA_ERROR_NONE) {
4484                 muse_camera_msg_get(get_min, pc->cb_info->recv_msg);
4485                 muse_camera_msg_get(get_max, pc->cb_info->recv_msg);
4486                 *min = get_min;
4487                 *max = get_max;
4488         }
4489         LOGD("ret : 0x%x", ret);
4490         return ret;
4491 }
4492
4493
4494 int camera_attr_get_whitebalance(camera_h camera,  camera_attr_whitebalance_e *wb)
4495 {
4496         if (camera == NULL || wb == NULL) {
4497                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4498                 return CAMERA_ERROR_INVALID_PARAMETER;
4499         }
4500         int ret = CAMERA_ERROR_NONE;
4501         camera_cli_s *pc = (camera_cli_s *)camera;
4502         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_WHITEBALANCE;
4503         int sock_fd;
4504         if (pc->cb_info == NULL) {
4505                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4506                 return CAMERA_ERROR_INVALID_PARAMETER;
4507         }
4508         sock_fd = pc->cb_info->fd;
4509         int get_wb;
4510
4511         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4512         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4513
4514         if (ret == CAMERA_ERROR_NONE) {
4515                 muse_camera_msg_get(get_wb, pc->cb_info->recv_msg);
4516                 *wb = (camera_attr_whitebalance_e)get_wb;
4517         }
4518         LOGD("ret : 0x%x", ret);
4519         return ret;
4520 }
4521
4522
4523 int camera_attr_get_effect(camera_h camera, camera_attr_effect_mode_e *effect)
4524 {
4525         if (camera == NULL || effect == NULL) {
4526                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4527                 return CAMERA_ERROR_INVALID_PARAMETER;
4528         }
4529
4530         int ret = CAMERA_ERROR_NONE;
4531         camera_cli_s *pc = (camera_cli_s *)camera;
4532         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_EFFECT;
4533         int sock_fd;
4534         if (pc->cb_info == NULL) {
4535                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4536                 return CAMERA_ERROR_INVALID_PARAMETER;
4537         }
4538         sock_fd = pc->cb_info->fd;
4539         int get_effect;
4540
4541         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4542         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4543
4544         if (ret == CAMERA_ERROR_NONE) {
4545                 muse_camera_msg_get(get_effect, pc->cb_info->recv_msg);
4546                 *effect = (camera_attr_effect_mode_e)get_effect;
4547         }
4548         LOGD("ret : 0x%x", ret);
4549         return ret;
4550 }
4551
4552
4553 int camera_attr_get_scene_mode(camera_h camera,  camera_attr_scene_mode_e *mode)
4554 {
4555         if (camera == NULL || mode == NULL) {
4556                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4557                 return CAMERA_ERROR_INVALID_PARAMETER;
4558         }
4559
4560         int ret = CAMERA_ERROR_NONE;
4561         camera_cli_s *pc = (camera_cli_s *)camera;
4562         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_SCENE_MODE;
4563         int sock_fd;
4564         if (pc->cb_info == NULL) {
4565                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4566                 return CAMERA_ERROR_INVALID_PARAMETER;
4567         }
4568         sock_fd = pc->cb_info->fd;
4569         int get_mode;
4570
4571         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4572         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4573
4574         if (ret == CAMERA_ERROR_NONE) {
4575                 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
4576                 *mode = (camera_attr_scene_mode_e)get_mode;
4577         }
4578         LOGD("ret : 0x%x", ret);
4579         return ret;
4580 }
4581
4582
4583 int camera_attr_is_enabled_tag(camera_h camera,  bool *enable)
4584 {
4585         if (camera == NULL || enable == NULL) {
4586                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4587                 return CAMERA_ERROR_INVALID_PARAMETER;
4588         }
4589
4590         int ret = CAMERA_ERROR_NONE;
4591         camera_cli_s *pc = (camera_cli_s *)camera;
4592         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_TAG;
4593         int sock_fd;
4594         if (pc->cb_info == NULL) {
4595                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4596                 return CAMERA_ERROR_INVALID_PARAMETER;
4597         }
4598         sock_fd = pc->cb_info->fd;
4599         int get_enabled;
4600
4601         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4602         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4603
4604         if (ret == CAMERA_ERROR_NONE) {
4605                 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
4606                 *enable = (bool)get_enabled;
4607         }
4608         LOGD("ret : 0x%x", ret);
4609         return ret;
4610 }
4611
4612
4613 int camera_attr_get_tag_image_description(camera_h camera,  char **description)
4614 {
4615         if (camera == NULL || description == NULL) {
4616                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4617                 return CAMERA_ERROR_INVALID_PARAMETER;
4618         }
4619
4620         int ret = CAMERA_ERROR_NONE;
4621         camera_cli_s *pc = (camera_cli_s *)camera;
4622         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_IMAGE_DESCRIPTION;
4623         int sock_fd;
4624         if (pc->cb_info == NULL) {
4625                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4626                 return CAMERA_ERROR_INVALID_PARAMETER;
4627         }
4628         sock_fd = pc->cb_info->fd;
4629         char get_description[MUSE_CAMERA_MSG_MAX_LENGTH] = {0,};
4630
4631         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4632         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4633
4634         if (ret == CAMERA_ERROR_NONE) {
4635                 muse_camera_msg_get_string(get_description, pc->cb_info->recv_msg);
4636                 *description = strdup(get_description);
4637         }
4638         LOGD("ret : 0x%x", ret);
4639         return ret;
4640 }
4641
4642
4643 int camera_attr_get_tag_orientation(camera_h camera, camera_attr_tag_orientation_e *orientation)
4644 {
4645         if (camera == NULL || orientation == NULL) {
4646                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4647                 return CAMERA_ERROR_INVALID_PARAMETER;
4648         }
4649
4650         int ret = CAMERA_ERROR_NONE;
4651         camera_cli_s *pc = (camera_cli_s *)camera;
4652         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_ORIENTATION;
4653         int sock_fd;
4654         if (pc->cb_info == NULL) {
4655                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4656                 return CAMERA_ERROR_INVALID_PARAMETER;
4657         }
4658         sock_fd = pc->cb_info->fd;
4659         int get_orientation;
4660
4661         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4662         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4663
4664         if (ret == CAMERA_ERROR_NONE) {
4665                 muse_camera_msg_get(get_orientation, pc->cb_info->recv_msg);
4666                 *orientation = (camera_attr_tag_orientation_e)get_orientation;
4667                 LOGD("success, orientation : %d", *orientation);
4668         }
4669         LOGD("ret : 0x%x", ret);
4670         return ret;
4671 }
4672
4673
4674 int camera_attr_get_tag_software(camera_h camera, char **software)
4675 {
4676         if (camera == NULL || software == NULL) {
4677                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4678                 return CAMERA_ERROR_INVALID_PARAMETER;
4679         }
4680
4681         int ret = CAMERA_ERROR_NONE;
4682         camera_cli_s *pc = (camera_cli_s *)camera;
4683         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_TAG_SOFTWARE;
4684         int sock_fd;
4685         if (pc->cb_info == NULL) {
4686                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4687                 return CAMERA_ERROR_INVALID_PARAMETER;
4688         }
4689         sock_fd = pc->cb_info->fd;
4690         char get_software[MUSE_CAMERA_MSG_MAX_LENGTH] = {0,};
4691
4692         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4693         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4694
4695         if (ret == CAMERA_ERROR_NONE) {
4696                 muse_camera_msg_get_string(get_software, pc->cb_info->recv_msg);
4697                 *software = strdup(get_software);
4698         }
4699         LOGD("ret : 0x%x", ret);
4700         return ret;
4701 }
4702
4703
4704 int camera_attr_get_geotag(camera_h camera, double *latitude , double *longitude, double *altitude)
4705 {
4706         if (camera == NULL || latitude == NULL || longitude == NULL || altitude == NULL) {
4707                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4708                 return CAMERA_ERROR_INVALID_PARAMETER;
4709         }
4710
4711         int ret = CAMERA_ERROR_NONE;
4712         camera_cli_s *pc = (camera_cli_s *)camera;
4713         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_GEOTAG;
4714         double get_geotag[3] = {0,};
4715         int sock_fd;
4716         if (pc->cb_info == NULL) {
4717                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4718                 return CAMERA_ERROR_INVALID_PARAMETER;
4719         }
4720         sock_fd = pc->cb_info->fd;
4721         int valid = 0;
4722         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4723         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4724
4725         if (ret == CAMERA_ERROR_NONE) {
4726                 muse_camera_msg_get_array(get_geotag, pc->cb_info->recv_msg);
4727                 *latitude = get_geotag[0];
4728                 *longitude = get_geotag[1];
4729                 *altitude = get_geotag[2];
4730         } else {
4731                 LOGE("Returned value is not valid : 0x%x", valid);
4732         }
4733
4734         LOGD("ret : 0x%x", ret);
4735
4736         return ret;
4737 }
4738
4739
4740 int camera_attr_get_flash_mode(camera_h camera,  camera_attr_flash_mode_e *mode)
4741 {
4742         if (camera == NULL || mode == NULL) {
4743                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4744                 return CAMERA_ERROR_INVALID_PARAMETER;
4745         }
4746
4747         int ret = CAMERA_ERROR_NONE;
4748         camera_cli_s *pc = (camera_cli_s *)camera;
4749         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
4750         int sock_fd;
4751         if (pc->cb_info == NULL) {
4752                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4753                 return CAMERA_ERROR_INVALID_PARAMETER;
4754         }
4755         sock_fd = pc->cb_info->fd;
4756         int get_mode;
4757
4758         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4759         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4760
4761         if (ret == CAMERA_ERROR_NONE) {
4762                 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
4763                 *mode = (camera_attr_flash_mode_e)get_mode;
4764         }
4765         LOGD("ret : 0x%x", ret);
4766         return ret;
4767 }
4768
4769 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
4770 {
4771         int sock_fd = -1;
4772         char *sndMsg;
4773         int ret = CAMERA_ERROR_NONE;
4774         camera_cli_s *pc = NULL;
4775         int get_flash_state = 0;
4776
4777         /* create muse connection */
4778         muse_camera_api_e api = MUSE_CAMERA_API_GET_FLASH_STATE;
4779         muse_core_api_module_e muse_module = MUSE_CAMERA;
4780         int device_type = (int)device;
4781
4782         sock_fd = muse_core_client_new();
4783         if (sock_fd < 0) {
4784                 LOGE("muse_core_client_new failed - returned fd %d", sock_fd);
4785                 ret = CAMERA_ERROR_INVALID_OPERATION;
4786                 goto Exit;
4787         }
4788
4789         sndMsg = muse_core_msg_json_factory_new(api,
4790                 MUSE_TYPE_INT, "module", muse_module,
4791                 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
4792                 0);
4793
4794         muse_core_ipc_send_msg(sock_fd, sndMsg);
4795         muse_core_msg_json_factory_free(sndMsg);
4796
4797         pc = g_new0(camera_cli_s, 1);
4798         if (pc == NULL) {
4799                 LOGE("camera_cli_s alloc failed");
4800                 ret = CAMERA_ERROR_OUT_OF_MEMORY;
4801                 goto Exit;
4802         }
4803
4804         pc->cb_info = _client_callback_new(sock_fd);
4805         if (pc->cb_info == NULL) {
4806                 LOGE("cb_info alloc failed");
4807                 ret = CAMERA_ERROR_OUT_OF_MEMORY;
4808                 goto Exit;
4809         }
4810
4811         ret = _client_wait_for_cb_return(api, pc->cb_info, CALLBACK_TIME_OUT);
4812
4813         if (ret == CAMERA_ERROR_NONE) {
4814                 muse_camera_msg_get(get_flash_state, pc->cb_info->recv_msg);
4815                 *state = (camera_flash_state_e)get_flash_state;
4816         }
4817
4818         LOGD("Flash state : %d\n", *state);
4819
4820 Exit:
4821         /* release resources */
4822         if (pc) {
4823                 g_atomic_int_set(&pc->cb_info->msg_recv_running, 0);
4824                 g_atomic_int_set(&pc->cb_info->msg_handler_running, 0);
4825                 _client_callback_destroy(pc->cb_info);
4826                 pc->cb_info = NULL;
4827                 g_free(pc);
4828                 pc = NULL;
4829         }
4830
4831         return ret;
4832 }
4833
4834 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
4835 {
4836         if (camera == NULL || foreach_cb == NULL) {
4837                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4838                 return CAMERA_ERROR_INVALID_PARAMETER;
4839         }
4840         int ret = CAMERA_ERROR_NONE;
4841
4842         camera_cli_s *pc = (camera_cli_s *)camera;
4843         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
4844
4845         LOGD("Enter, handle :%x", pc->remote_handle);
4846
4847         int sock_fd;
4848         if (pc->cb_info == NULL) {
4849                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4850                 return CAMERA_ERROR_INVALID_PARAMETER;
4851         }
4852         sock_fd = pc->cb_info->fd;
4853         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
4854         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
4855
4856         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4857         LOGD("ret : 0x%x", ret);
4858         return ret;
4859 }
4860
4861
4862 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb , void *user_data)
4863 {
4864         if (camera == NULL || foreach_cb == NULL) {
4865                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4866                 return CAMERA_ERROR_INVALID_PARAMETER;
4867         }
4868         int ret = CAMERA_ERROR_NONE;
4869
4870         camera_cli_s *pc = (camera_cli_s *)camera;
4871         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
4872
4873         LOGD("Enter, handle :%x", pc->remote_handle);
4874
4875         int sock_fd;
4876         if (pc->cb_info == NULL) {
4877                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4878                 return CAMERA_ERROR_INVALID_PARAMETER;
4879         }
4880         sock_fd = pc->cb_info->fd;
4881         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
4882         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
4883
4884         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4885         LOGD("ret : 0x%x", ret);
4886         return ret;
4887 }
4888
4889
4890 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
4891 {
4892         if (camera == NULL || foreach_cb == NULL) {
4893                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4894                 return CAMERA_ERROR_INVALID_PARAMETER;
4895         }
4896         int ret = CAMERA_ERROR_NONE;
4897
4898         camera_cli_s *pc = (camera_cli_s *)camera;
4899         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
4900
4901         LOGD("Enter, handle :%x", pc->remote_handle);
4902
4903         int sock_fd;
4904         if (pc->cb_info == NULL) {
4905                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4906                 return CAMERA_ERROR_INVALID_PARAMETER;
4907         }
4908         sock_fd = pc->cb_info->fd;
4909         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
4910         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
4911
4912         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4913         LOGD("ret : 0x%x", ret);
4914         return ret;
4915 }
4916
4917
4918 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb , void *user_data)
4919 {
4920         if (camera == NULL || foreach_cb == NULL) {
4921                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4922                 return CAMERA_ERROR_INVALID_PARAMETER;
4923         }
4924         int ret = CAMERA_ERROR_NONE;
4925
4926         camera_cli_s *pc = (camera_cli_s *)camera;
4927         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
4928
4929         LOGD("Enter, handle :%x", pc->remote_handle);
4930
4931         int sock_fd;
4932         if (pc->cb_info == NULL) {
4933                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4934                 return CAMERA_ERROR_INVALID_PARAMETER;
4935         }
4936         sock_fd = pc->cb_info->fd;
4937         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
4938         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
4939
4940         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4941         LOGD("ret : 0x%x", ret);
4942         return ret;
4943 }
4944
4945
4946 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb , void *user_data)
4947 {
4948         if (camera == NULL || foreach_cb == NULL) {
4949                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4950                 return CAMERA_ERROR_INVALID_PARAMETER;
4951         }
4952         int ret = CAMERA_ERROR_NONE;
4953
4954         camera_cli_s *pc = (camera_cli_s *)camera;
4955         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
4956
4957         LOGD("Enter, handle :%x", pc->remote_handle);
4958
4959         int sock_fd;
4960         if (pc->cb_info == NULL) {
4961                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4962                 return CAMERA_ERROR_INVALID_PARAMETER;
4963         }
4964         sock_fd = pc->cb_info->fd;
4965         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
4966         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
4967
4968         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4969         LOGD("ret : 0x%x", ret);
4970         return ret;
4971 }
4972
4973
4974 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb , void *user_data)
4975 {
4976         if (camera == NULL || foreach_cb == NULL) {
4977                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4978                 return CAMERA_ERROR_INVALID_PARAMETER;
4979         }
4980         int ret = CAMERA_ERROR_NONE;
4981
4982         camera_cli_s *pc = (camera_cli_s *)camera;
4983         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
4984
4985         LOGD("Enter, handle :%x", pc->remote_handle);
4986
4987         int sock_fd;
4988         if (pc->cb_info == NULL) {
4989                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4990                 return CAMERA_ERROR_INVALID_PARAMETER;
4991         }
4992         sock_fd = pc->cb_info->fd;
4993         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
4994         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
4995
4996         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4997         LOGD("ret : 0x%x", ret);
4998         return ret;
4999 }
5000
5001
5002 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb , void *user_data)
5003 {
5004         if (camera == NULL || foreach_cb == NULL) {
5005                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5006                 return CAMERA_ERROR_INVALID_PARAMETER;
5007         }
5008         int ret = CAMERA_ERROR_NONE;
5009
5010         camera_cli_s *pc = (camera_cli_s *)camera;
5011         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5012
5013         LOGD("Enter, handle :%x", pc->remote_handle);
5014
5015         int sock_fd;
5016         if (pc->cb_info == NULL) {
5017                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5018                 return CAMERA_ERROR_INVALID_PARAMETER;
5019         }
5020         sock_fd = pc->cb_info->fd;
5021         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5022         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5023
5024         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5025         LOGD("ret : 0x%x", ret);
5026         return ret;
5027 }
5028
5029
5030 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb , void *user_data)
5031 {
5032         if (camera == NULL || foreach_cb == NULL) {
5033                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5034                 return CAMERA_ERROR_INVALID_PARAMETER;
5035         }
5036         int ret = CAMERA_ERROR_NONE;
5037
5038         camera_cli_s *pc = (camera_cli_s *)camera;
5039         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5040         int sock_fd;
5041         if (pc->cb_info == NULL) {
5042                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5043                 return CAMERA_ERROR_INVALID_PARAMETER;
5044         }
5045         sock_fd = pc->cb_info->fd;
5046         LOGD("Enter, handle :%x", pc->remote_handle);
5047         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5048         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5049
5050         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5051         LOGD("Enter, handle :%x", pc->remote_handle);
5052         return ret;
5053 }
5054
5055 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)
5056 {
5057         if (camera == NULL || foreach_cb == NULL) {
5058                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5059                 return CAMERA_ERROR_INVALID_PARAMETER;
5060         }
5061         int ret = CAMERA_ERROR_NONE;
5062
5063         camera_cli_s *pc = (camera_cli_s *)camera;
5064         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5065         int sock_fd;
5066         if (pc->cb_info == NULL) {
5067                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5068                 return CAMERA_ERROR_INVALID_PARAMETER;
5069         }
5070         sock_fd = pc->cb_info->fd;
5071         LOGD("Enter, handle :%x", pc->remote_handle);
5072         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5073         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5074
5075         muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, width, INT, height);
5076         LOGD("ret : 0x%x", ret);
5077         return ret;
5078 }
5079
5080 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5081 {
5082         if (camera == NULL || foreach_cb == NULL) {
5083                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5084                 return CAMERA_ERROR_INVALID_PARAMETER;
5085         }
5086         int ret = CAMERA_ERROR_NONE;
5087
5088         camera_cli_s *pc = (camera_cli_s *)camera;
5089         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5090         int sock_fd;
5091         if (pc->cb_info == NULL) {
5092                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5093                 return CAMERA_ERROR_INVALID_PARAMETER;
5094         }
5095         sock_fd = pc->cb_info->fd;
5096         LOGD("Enter, handle :%x", pc->remote_handle);
5097         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5098         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5099
5100         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5101         LOGD("ret : 0x%x", ret);
5102         return ret;
5103 }
5104
5105
5106 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5107 {
5108         if (camera == NULL || foreach_cb == NULL) {
5109                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5110                 return CAMERA_ERROR_INVALID_PARAMETER;
5111         }
5112         int ret = CAMERA_ERROR_NONE;
5113
5114         camera_cli_s *pc = (camera_cli_s *)camera;
5115         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5116         int sock_fd;
5117         if (pc->cb_info == NULL) {
5118                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5119                 return CAMERA_ERROR_INVALID_PARAMETER;
5120         }
5121         sock_fd = pc->cb_info->fd;
5122         LOGD("Enter, handle :%x", pc->remote_handle);
5123         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5124         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5125
5126         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5127         LOGD("ret : 0x%x", ret);
5128         return ret;
5129 }
5130
5131
5132 int camera_attr_set_stream_rotation(camera_h camera , camera_rotation_e rotation)
5133 {
5134         if (camera == NULL) {
5135                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5136                 return CAMERA_ERROR_INVALID_PARAMETER;
5137         }
5138
5139         int ret = CAMERA_ERROR_NONE;
5140         camera_cli_s *pc = (camera_cli_s *)camera;
5141         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5142         int sock_fd;
5143         if (pc->cb_info == NULL) {
5144                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5145                 return CAMERA_ERROR_INVALID_PARAMETER;
5146         }
5147         sock_fd = pc->cb_info->fd;
5148         int set_rotation = (int)rotation;
5149
5150         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5151         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_rotation);
5152         LOGD("ret : 0x%x", ret);
5153         return ret;
5154 }
5155
5156
5157 int camera_attr_get_stream_rotation(camera_h camera , camera_rotation_e *rotation)
5158 {
5159         if (camera == NULL || rotation == NULL) {
5160                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5161                 return CAMERA_ERROR_INVALID_PARAMETER;
5162         }
5163
5164         int ret = CAMERA_ERROR_NONE;
5165         camera_cli_s *pc = (camera_cli_s *)camera;
5166         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5167         int sock_fd;
5168         if (pc->cb_info == NULL) {
5169                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5170                 return CAMERA_ERROR_INVALID_PARAMETER;
5171         }
5172         sock_fd = pc->cb_info->fd;
5173         int get_rotation;
5174
5175         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5176         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5177
5178         if (ret == CAMERA_ERROR_NONE) {
5179                 muse_camera_msg_get(get_rotation, pc->cb_info->recv_msg);
5180                 *rotation = (camera_rotation_e)get_rotation;
5181         }
5182         LOGD("ret : 0x%x", ret);
5183         return ret;
5184 }
5185
5186
5187 int camera_attr_set_stream_flip(camera_h camera , camera_flip_e flip)
5188 {
5189         if (camera == NULL) {
5190                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5191                 return CAMERA_ERROR_INVALID_PARAMETER;
5192         }
5193
5194         int ret = CAMERA_ERROR_NONE;
5195         camera_cli_s *pc = (camera_cli_s *)camera;
5196         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5197         int sock_fd;
5198         if (pc->cb_info == NULL) {
5199                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5200                 return CAMERA_ERROR_INVALID_PARAMETER;
5201         }
5202         sock_fd = pc->cb_info->fd;
5203         int set_flip = (int)flip;
5204
5205         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5206         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_flip);
5207         LOGD("ret : 0x%x", ret);
5208         return ret;
5209 }
5210
5211
5212 int camera_attr_get_stream_flip(camera_h camera , camera_flip_e *flip)
5213 {
5214         if (camera == NULL || flip == NULL) {
5215                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5216                 return CAMERA_ERROR_INVALID_PARAMETER;
5217         }
5218
5219         int ret = CAMERA_ERROR_NONE;
5220         camera_cli_s *pc = (camera_cli_s *)camera;
5221         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5222         int sock_fd;
5223         if (pc->cb_info == NULL) {
5224                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5225                 return CAMERA_ERROR_INVALID_PARAMETER;
5226         }
5227         sock_fd = pc->cb_info->fd;
5228         int get_flip;
5229
5230         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5231         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5232
5233         if (ret == CAMERA_ERROR_NONE) {
5234                 muse_camera_msg_get(get_flip, pc->cb_info->recv_msg);
5235                 *flip = (camera_flip_e)get_flip;
5236         }
5237         LOGD("ret : 0x%x", ret);
5238         return ret;
5239 }
5240
5241 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5242 {
5243         if (camera == NULL) {
5244                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5245                 return CAMERA_ERROR_INVALID_PARAMETER;
5246         }
5247
5248         int ret = CAMERA_ERROR_NONE;
5249         camera_cli_s *pc = (camera_cli_s *)camera;
5250         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5251         int sock_fd;
5252         if (pc->cb_info == NULL) {
5253                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5254                 return CAMERA_ERROR_INVALID_PARAMETER;
5255         }
5256         sock_fd = pc->cb_info->fd;
5257         int set_mode = (int)mode;
5258
5259         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5260         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
5261         LOGD("ret : 0x%x", ret);
5262         return ret;
5263 }
5264
5265
5266 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5267 {
5268         if (camera == NULL) {
5269                 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
5270                 return CAMERA_ERROR_INVALID_PARAMETER;
5271         }
5272         if (mode == NULL) {
5273                 LOGE("CAMERA_ERROR_NOT_SUPPORTED(0x%08x) - mode", CAMERA_ERROR_NOT_SUPPORTED);
5274                 return CAMERA_ERROR_NOT_SUPPORTED;
5275         }
5276         int ret = CAMERA_ERROR_NONE;
5277         camera_cli_s *pc = (camera_cli_s *)camera;
5278         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5279         int sock_fd;
5280         if (pc->cb_info == NULL) {
5281                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5282                 return CAMERA_ERROR_INVALID_PARAMETER;
5283         }
5284         sock_fd = pc->cb_info->fd;
5285         int get_mode;
5286
5287         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5288         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5289
5290         if (ret == CAMERA_ERROR_NONE) {
5291                 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
5292                 *mode = (camera_attr_hdr_mode_e)get_mode;
5293         }
5294         LOGD("ret : 0x%x", ret);
5295         return ret;
5296 }
5297
5298
5299 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5300 {
5301         if (camera == NULL) {
5302                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5303                 return false;
5304         }
5305
5306         int ret = CAMERA_ERROR_NONE;
5307         camera_cli_s *pc = (camera_cli_s *)camera;
5308         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
5309         int sock_fd;
5310         if (pc->cb_info == NULL) {
5311                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5312                 return CAMERA_ERROR_INVALID_PARAMETER;
5313         }
5314         sock_fd = pc->cb_info->fd;
5315         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5316         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5317         LOGD("ret : 0x%x", ret);
5318         return (bool)ret;
5319 }
5320
5321
5322 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5323 {
5324         if (camera == NULL) {
5325                 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
5326                 return CAMERA_ERROR_INVALID_PARAMETER;
5327         }
5328         if (callback == NULL) {
5329                 LOGE("CAMERA_ERROR_NOT_SUPPORTED(0x%08x) - callback", CAMERA_ERROR_NOT_SUPPORTED);
5330                 return CAMERA_ERROR_NOT_SUPPORTED;
5331         }
5332         int ret = CAMERA_ERROR_NONE;
5333
5334         camera_cli_s *pc = (camera_cli_s *)camera;
5335         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5336         int sock_fd;
5337         if (pc->cb_info == NULL) {
5338                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5339                 return CAMERA_ERROR_INVALID_PARAMETER;
5340         }
5341         sock_fd = pc->cb_info->fd;
5342         LOGD("Enter, handle :%x", pc->remote_handle);
5343
5344         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5345         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5346
5347         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5348         LOGD("ret : 0x%x", ret);
5349         return ret;
5350 }
5351
5352
5353 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5354 {
5355         if (camera == NULL) {
5356                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5357                 return CAMERA_ERROR_INVALID_PARAMETER;
5358         }
5359
5360         int ret = CAMERA_ERROR_NONE;
5361
5362         camera_cli_s *pc = (camera_cli_s *)camera;
5363         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5364         int sock_fd;
5365         if (pc->cb_info == NULL) {
5366                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5367                 return CAMERA_ERROR_INVALID_PARAMETER;
5368         }
5369         sock_fd = pc->cb_info->fd;
5370         LOGD("Enter, handle :%x", pc->remote_handle);
5371
5372         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)NULL;
5373         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)NULL;
5374
5375         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5376         LOGD("ret : 0x%x", ret);
5377         return ret;
5378 }
5379
5380
5381 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
5382 {
5383         if (camera == NULL) {
5384                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5385                 return CAMERA_ERROR_INVALID_PARAMETER;
5386         }
5387
5388         int ret = CAMERA_ERROR_NONE;
5389         camera_cli_s *pc = (camera_cli_s *)camera;
5390         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
5391         int sock_fd;
5392         if (pc->cb_info == NULL) {
5393                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5394                 return CAMERA_ERROR_INVALID_PARAMETER;
5395         }
5396         sock_fd = pc->cb_info->fd;
5397         int set_enable = (int)enable;
5398
5399         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5400         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable);
5401         LOGD("ret : 0x%x", ret);
5402         return ret;
5403 }
5404
5405
5406 int camera_attr_is_enabled_anti_shake(camera_h camera , bool *enabled)
5407 {
5408         if (camera == NULL) {
5409                 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
5410                 return CAMERA_ERROR_INVALID_PARAMETER;
5411         }
5412         if (enabled == NULL) {
5413                 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
5414                 return CAMERA_ERROR_NOT_SUPPORTED;
5415         }
5416         int ret = CAMERA_ERROR_NONE;
5417         camera_cli_s *pc = (camera_cli_s *)camera;
5418         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
5419         int sock_fd;
5420         if (pc->cb_info == NULL) {
5421                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5422                 return CAMERA_ERROR_INVALID_PARAMETER;
5423         }
5424         sock_fd = pc->cb_info->fd;
5425         int get_enabled;
5426
5427         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5428         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5429
5430         if (ret == CAMERA_ERROR_NONE) {
5431                 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
5432                 *enabled = (bool)get_enabled;
5433         }
5434         LOGD("ret : 0x%x", ret);
5435         return ret;
5436 }
5437
5438
5439 bool camera_attr_is_supported_anti_shake(camera_h camera)
5440 {
5441
5442         if (camera == NULL) {
5443                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5444                 return false;
5445         }
5446
5447         int ret = CAMERA_ERROR_NONE;
5448         camera_cli_s *pc = (camera_cli_s *)camera;
5449         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
5450         int sock_fd;
5451         if (pc->cb_info == NULL) {
5452                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5453                 return CAMERA_ERROR_INVALID_PARAMETER;
5454         }
5455         sock_fd = pc->cb_info->fd;
5456         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5457         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5458         LOGD("ret : 0x%x", ret);
5459         return ret;
5460 }
5461
5462
5463 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
5464 {
5465         if (camera == NULL) {
5466                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5467                 return CAMERA_ERROR_INVALID_PARAMETER;
5468         }
5469
5470         int ret = CAMERA_ERROR_NONE;
5471         camera_cli_s *pc = (camera_cli_s *)camera;
5472         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
5473         int sock_fd;
5474         if (pc->cb_info == NULL) {
5475                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5476                 return CAMERA_ERROR_INVALID_PARAMETER;
5477         }
5478         sock_fd = pc->cb_info->fd;
5479         int set_enable = (int)enable;
5480
5481         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5482         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable);
5483         LOGD("ret : 0x%x", ret);
5484         return ret;
5485 }
5486
5487
5488 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
5489 {
5490         if (camera == NULL) {
5491                 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
5492                 return CAMERA_ERROR_INVALID_PARAMETER;
5493         }
5494         if (enabled == NULL) {
5495                 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
5496                 return CAMERA_ERROR_NOT_SUPPORTED;
5497         }
5498         int ret = CAMERA_ERROR_NONE;
5499         camera_cli_s *pc = (camera_cli_s *)camera;
5500         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
5501         int sock_fd;
5502         if (pc->cb_info == NULL) {
5503                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5504                 return CAMERA_ERROR_INVALID_PARAMETER;
5505         }
5506         sock_fd = pc->cb_info->fd;
5507         int get_enabled;
5508
5509         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5510         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5511
5512         if (ret == CAMERA_ERROR_NONE) {
5513                 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
5514                 *enabled = (bool)get_enabled;
5515         }
5516         LOGD("ret : 0x%x", ret);
5517         return ret;
5518 }
5519
5520
5521 bool camera_attr_is_supported_video_stabilization(camera_h camera)
5522 {
5523         if (camera == NULL) {
5524                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5525                 return false;
5526         }
5527
5528         int ret = CAMERA_ERROR_NONE;
5529         camera_cli_s *pc = (camera_cli_s *)camera;
5530         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
5531         int sock_fd;
5532         if (pc->cb_info == NULL) {
5533                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5534                 return CAMERA_ERROR_INVALID_PARAMETER;
5535         }
5536         sock_fd = pc->cb_info->fd;
5537         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5538         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5539         LOGD("ret : 0x%x", ret);
5540         return ret;
5541 }
5542
5543
5544 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
5545 {
5546         if (camera == NULL) {
5547                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5548                 return CAMERA_ERROR_INVALID_PARAMETER;
5549         }
5550
5551         int ret = CAMERA_ERROR_NONE;
5552         camera_cli_s *pc = (camera_cli_s *)camera;
5553         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
5554         int sock_fd;
5555         if (pc->cb_info == NULL) {
5556                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5557                 return CAMERA_ERROR_INVALID_PARAMETER;
5558         }
5559         sock_fd = pc->cb_info->fd;
5560         int set_enable = (int)enable;
5561
5562         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5563         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable);
5564         LOGD("ret : 0x%x", ret);
5565         return ret;
5566 }
5567
5568
5569 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
5570 {
5571         if (camera == NULL) {
5572                 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
5573                 return CAMERA_ERROR_INVALID_PARAMETER;
5574         }
5575         if (enabled == NULL) {
5576                 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
5577                 return CAMERA_ERROR_INVALID_PARAMETER;
5578         }
5579         int ret = CAMERA_ERROR_NONE;
5580         camera_cli_s *pc = (camera_cli_s *)camera;
5581         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
5582         int sock_fd;
5583         if (pc->cb_info == NULL) {
5584                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5585                 return CAMERA_ERROR_INVALID_PARAMETER;
5586         }
5587         sock_fd = pc->cb_info->fd;
5588         int get_enabled;
5589
5590         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5591         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5592
5593         if (ret == CAMERA_ERROR_NONE) {
5594                 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
5595                 *enabled = (bool)get_enabled;
5596         }
5597         LOGD("ret : 0x%x", ret);
5598         return ret;
5599 }
5600
5601
5602 bool camera_attr_is_supported_auto_contrast(camera_h camera)
5603 {
5604         if (camera == NULL) {
5605                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5606                 return false;
5607         }
5608
5609         int ret = CAMERA_ERROR_NONE;
5610         camera_cli_s *pc = (camera_cli_s *)camera;
5611         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
5612         int sock_fd;
5613         if (pc->cb_info == NULL) {
5614                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5615                 return CAMERA_ERROR_INVALID_PARAMETER;
5616         }
5617         sock_fd = pc->cb_info->fd;
5618         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5619         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5620         LOGD("ret : 0x%x", ret);
5621         return ret;
5622 }
5623
5624
5625 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
5626 {
5627         if (camera == NULL) {
5628                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5629                 return CAMERA_ERROR_INVALID_PARAMETER;
5630         }
5631
5632         int ret = CAMERA_ERROR_NONE;
5633         camera_cli_s *pc = (camera_cli_s *)camera;
5634         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
5635         int sock_fd;
5636         if (pc->cb_info == NULL) {
5637                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5638                 return CAMERA_ERROR_INVALID_PARAMETER;
5639         }
5640         sock_fd = pc->cb_info->fd;
5641         int set_disable = (int)disable;
5642
5643         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5644         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_disable);
5645         LOGD("ret : 0x%x", ret);
5646         return ret;
5647 }