[Release version 0.2.48] Fix coding rule violation
[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                 LOGD("done");
76         }
77
78         return;
79 }
80
81 static void __global_remove(void *data, struct wl_registry *wl_registry, uint32_t name)
82 {
83         LOGD("enter");
84         return;
85 }
86
87 static const struct wl_registry_listener _camera_wl_registry_listener = {
88         __global,
89         __global_remove
90 };
91
92 void __parent_id_getter(void *data, struct tizen_resource *tizen_resource, uint32_t id)
93 {
94         if (!data) {
95                 LOGE("NULL data");
96                 return;
97         }
98
99         *((unsigned int *)data) = id;
100
101         LOGD("[CLIENT] got parent_id [%u] from server", id);
102
103         return;
104 }
105
106 static const struct tizen_resource_listener _camera_tz_resource_listener = {
107         __parent_id_getter
108 };
109
110 int _get_wl_info(Evas_Object *obj, camera_wl_info_s *wl_info)
111 {
112         int ret = CAMERA_ERROR_NONE;
113         Ecore_Wl_Window *window = NULL;
114         struct wl_display *display = NULL;
115         struct wl_surface *surface = NULL;
116         struct wl_registry *registry = NULL;
117         struct tizen_surface *tz_surface = NULL;
118         struct tizen_resource *tz_resource = NULL;
119
120         if (!obj || !wl_info) {
121                 LOGE("NULL parameter %p %p", obj, wl_info);
122                 return CAMERA_ERROR_INVALID_OPERATION;
123         }
124
125         window = elm_win_wl_window_get(obj);
126         if (!window) {
127                 LOGE("failed to get wayland window");
128                 ret = CAMERA_ERROR_INVALID_OPERATION;
129                 goto _DONE;
130         }
131
132         surface = (struct wl_surface *)ecore_wl_window_surface_get(window);
133         if (!surface) {
134                 LOGE("failed to get wayland surface");
135                 ret = CAMERA_ERROR_INVALID_OPERATION;
136                 goto _DONE;
137         }
138
139         display = (struct wl_display *)ecore_wl_display_get();
140         if (!display) {
141                 LOGE("failed to get wayland display");
142                 ret = CAMERA_ERROR_INVALID_OPERATION;
143                 goto _DONE;
144         }
145
146         registry = wl_display_get_registry(display);
147         if (!registry) {
148                 LOGE("failed to get wayland registry");
149                 ret = CAMERA_ERROR_INVALID_OPERATION;
150                 goto _DONE;
151         }
152
153         wl_registry_add_listener(registry, &_camera_wl_registry_listener, &tz_surface);
154
155         wl_display_dispatch(display);
156         wl_display_roundtrip(display);
157
158         if (!tz_surface) {
159                 LOGE("failed to get tizen surface");
160                 ret = CAMERA_ERROR_INVALID_OPERATION;
161                 goto _DONE;
162         }
163
164         /* Get parent_id which is unique in a entire systemw. */
165         tz_resource = tizen_surface_get_tizen_resource(tz_surface, surface);
166         if (!tz_resource) {
167                 LOGE("failed to get tizen resurce");
168                 ret = CAMERA_ERROR_INVALID_OPERATION;
169                 goto _DONE;
170         }
171
172         wl_info->parent_id = 0;
173
174         tizen_resource_add_listener(tz_resource, &_camera_tz_resource_listener, &wl_info->parent_id);
175
176         wl_display_roundtrip(display);
177
178         if (wl_info->parent_id > 0) {
179                 int rotation = 0;
180                 Ecore_Evas *ecore_evas = NULL;
181                 ret = CAMERA_ERROR_NONE;
182
183                 wl_info->evas_obj = obj;
184
185                 evas_object_geometry_get(obj, &wl_info->window_x, &wl_info->window_y,
186                         &wl_info->window_width, &wl_info->window_height);
187
188                 ecore_evas = ecore_evas_ecore_evas_get(evas_object_evas_get(obj));
189                 if (ecore_evas) {
190                         rotation = ecore_evas_rotation_get(ecore_evas);
191                         if (rotation == 90 || rotation == 270) {
192                                 int temp = wl_info->window_width;
193
194                                 LOGD("swap width and height %d, %d", wl_info->window_width, wl_info->window_height);
195
196                                 wl_info->window_width = wl_info->window_height;
197                                 wl_info->window_height = temp;
198                         }
199                 } else {
200                         LOGW("failed to get ecore_evas.. skip rotation check");
201                 }
202
203                 LOGD("evas object : %p, rotation : %d, parent id : %u, window : %d,%d,%dx%d",
204                         wl_info->evas_obj, rotation, wl_info->parent_id,
205                         wl_info->window_x, wl_info->window_y,
206                         wl_info->window_width, wl_info->window_height);
207         } else {
208                 ret = CAMERA_ERROR_INVALID_OPERATION;
209                 LOGE("failed to get parent id");
210         }
211
212 _DONE:
213         if (tz_surface) {
214                 tizen_surface_destroy(tz_surface);
215                 tz_surface = NULL;
216         }
217
218         if (tz_resource) {
219                 tizen_resource_destroy(tz_resource);
220                 tz_resource = NULL;
221         }
222
223         if (registry) {
224                 wl_registry_destroy(registry);
225                 registry = NULL;
226         }
227
228         return ret;
229 }
230 #endif /* HAVE_WAYLAND */
231
232 static int _import_tbm_key(tbm_bufmgr bufmgr, unsigned int tbm_key, tbm_bo *bo, tbm_bo_handle *bo_handle)
233 {
234         tbm_bo tmp_bo = NULL;
235         tbm_bo_handle tmp_bo_handle = {NULL, };
236
237         if (bufmgr == NULL || bo == NULL || bo_handle == NULL || tbm_key == 0) {
238                 LOGE("invalid parameter - bufmgr %p, bo %p, bo_handle %p, key %d",
239                      bufmgr, bo, bo_handle, tbm_key);
240                 return false;
241         }
242
243         tmp_bo = tbm_bo_import(bufmgr, tbm_key);
244         if (tmp_bo == NULL) {
245                 LOGE("bo import failed - bufmgr %p, key %d", bufmgr, tbm_key);
246                 return false;
247         }
248
249         tmp_bo_handle = tbm_bo_map(tmp_bo, TBM_DEVICE_CPU, TBM_OPTION_READ);
250         if (tmp_bo_handle.ptr == NULL) {
251                 LOGE("bo map failed %p", tmp_bo);
252                 tbm_bo_unref(tmp_bo);
253                 tmp_bo = NULL;
254                 return false;
255         }
256
257         /* set bo and bo_handle */
258         *bo = tmp_bo;
259         *bo_handle = tmp_bo_handle;
260
261         return true;
262 }
263
264 static void _release_imported_bo(tbm_bo *bo)
265 {
266         if (bo == NULL || *bo == NULL) {
267                 LOGW("NULL bo");
268                 return;
269         }
270
271         tbm_bo_unmap(*bo);
272         tbm_bo_unref(*bo);
273         *bo = NULL;
274
275         return;
276 }
277
278 static int _client_wait_for_cb_return(muse_camera_api_e api, camera_cb_info_s *cb_info, int time_out)
279 {
280         int ret = CAMERA_ERROR_NONE;
281         gint64 end_time;
282
283         LOGD("Enter api : %d", api);
284
285         g_mutex_lock(&(cb_info->api_mutex[api]));
286
287         if (cb_info->api_activating[api] == 0) {
288                 end_time = g_get_monotonic_time() + time_out * G_TIME_SPAN_SECOND;
289                 if (g_cond_wait_until(&(cb_info->api_cond[api]), &(cb_info->api_mutex[api]), end_time)) {
290                         ret = cb_info->api_ret[api];
291                         cb_info->api_activating[api] = 0;
292
293                         LOGD("return value : 0x%x", ret);
294                 } else {
295                         ret = CAMERA_ERROR_INVALID_OPERATION;
296
297                         LOGE("api %d was TIMED OUT!", api);
298                 }
299         } else {
300                 ret = cb_info->api_ret[api];
301                 cb_info->api_activating[api] = 0;
302
303                 LOGD("condition is already checked for the api[%d], return[0x%x]", api, ret);
304         }
305
306         g_mutex_unlock(&(cb_info->api_mutex[api]));
307
308         return ret;
309 }
310
311 int _camera_get_tbm_surface_format(int in_format, uint32_t *out_format)
312 {
313         if (in_format <= MM_PIXEL_FORMAT_INVALID ||
314             in_format >= MM_PIXEL_FORMAT_NUM ||
315             out_format == NULL) {
316                 LOGE("INVALID_PARAMETER : in_format %d, out_format ptr %p", in_format, out_format);
317                 return CAMERA_ERROR_INVALID_PARAMETER;
318         }
319
320         switch (in_format) {
321         case MM_PIXEL_FORMAT_NV12:
322         case MM_PIXEL_FORMAT_NV12T:
323                 *out_format = TBM_FORMAT_NV12;
324                 break;
325         case MM_PIXEL_FORMAT_NV16:
326                 *out_format = TBM_FORMAT_NV16;
327                 break;
328         case MM_PIXEL_FORMAT_NV21:
329                 *out_format = TBM_FORMAT_NV21;
330                 break;
331         case MM_PIXEL_FORMAT_YUYV:
332                 *out_format = TBM_FORMAT_YUYV;
333                 break;
334         case MM_PIXEL_FORMAT_UYVY:
335         case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
336                 *out_format = TBM_FORMAT_UYVY;
337                 break;
338         case MM_PIXEL_FORMAT_422P:
339                 *out_format = TBM_FORMAT_YUV422;
340                 break;
341         case MM_PIXEL_FORMAT_I420:
342                 *out_format = TBM_FORMAT_YUV420;
343                 break;
344         case MM_PIXEL_FORMAT_YV12:
345                 *out_format = TBM_FORMAT_YVU420;
346                 break;
347         case MM_PIXEL_FORMAT_RGB565:
348                 *out_format = TBM_FORMAT_RGB565;
349                 break;
350         case MM_PIXEL_FORMAT_RGB888:
351                 *out_format = TBM_FORMAT_RGB888;
352                 break;
353         case MM_PIXEL_FORMAT_RGBA:
354                 *out_format = TBM_FORMAT_RGBA8888;
355                 break;
356         case MM_PIXEL_FORMAT_ARGB:
357                 *out_format = TBM_FORMAT_ARGB8888;
358                 break;
359         default:
360                 LOGE("invalid in_format %d", in_format);
361                 return CAMERA_ERROR_INVALID_PARAMETER;
362         }
363
364         return CAMERA_ERROR_NONE;
365 }
366
367
368 int _camera_get_media_packet_mimetype(int in_format, media_format_mimetype_e *mimetype)
369 {
370         if (in_format <= MM_PIXEL_FORMAT_INVALID ||
371             in_format >= MM_PIXEL_FORMAT_NUM ||
372             mimetype == NULL) {
373                 LOGE("INVALID_PARAMETER : in_format %d, mimetype ptr %p", in_format, mimetype);
374                 return CAMERA_ERROR_INVALID_PARAMETER;
375         }
376
377         switch (in_format) {
378         case MM_PIXEL_FORMAT_NV12:
379         case MM_PIXEL_FORMAT_NV12T:
380                 *mimetype = MEDIA_FORMAT_NV12;
381                 break;
382         case MM_PIXEL_FORMAT_NV16:
383                 *mimetype = MEDIA_FORMAT_NV16;
384                 break;
385         case MM_PIXEL_FORMAT_NV21:
386                 *mimetype = MEDIA_FORMAT_NV21;
387                 break;
388         case MM_PIXEL_FORMAT_YUYV:
389                 *mimetype = MEDIA_FORMAT_YUYV;
390                 break;
391         case MM_PIXEL_FORMAT_UYVY:
392         case MM_PIXEL_FORMAT_ITLV_JPEG_UYVY:
393                 *mimetype = MEDIA_FORMAT_UYVY;
394                 break;
395         case MM_PIXEL_FORMAT_422P:
396                 *mimetype = MEDIA_FORMAT_422P;
397                 break;
398         case MM_PIXEL_FORMAT_I420:
399                 *mimetype = MEDIA_FORMAT_I420;
400                 break;
401         case MM_PIXEL_FORMAT_YV12:
402                 *mimetype = MEDIA_FORMAT_YV12;
403                 break;
404         case MM_PIXEL_FORMAT_RGB565:
405                 *mimetype = MEDIA_FORMAT_RGB565;
406                 break;
407         case MM_PIXEL_FORMAT_RGB888:
408                 *mimetype = MEDIA_FORMAT_RGB888;
409                 break;
410         case MM_PIXEL_FORMAT_RGBA:
411                 *mimetype = MEDIA_FORMAT_RGBA;
412                 break;
413         case MM_PIXEL_FORMAT_ARGB:
414                 *mimetype = MEDIA_FORMAT_ARGB;
415                 break;
416         default:
417                 LOGE("invalid in_format %d", in_format);
418                 return CAMERA_ERROR_INVALID_PARAMETER;
419         }
420
421         return CAMERA_ERROR_NONE;
422 }
423
424 int _camera_media_packet_finalize(media_packet_h pkt, int error_code, void *user_data)
425 {
426         int i = 0;
427         int ret = 0;
428         camera_cb_info_s *cb_info = (camera_cb_info_s *)user_data;
429         camera_media_packet_data *mp_data = NULL;
430         tbm_surface_h tsurf = NULL;
431
432         if (pkt == NULL || cb_info == NULL) {
433                 LOGE("invalid parameter buffer %p, cb_info %p", pkt, cb_info);
434                 return MEDIA_PACKET_FINALIZE;
435         }
436
437         ret = media_packet_get_extra(pkt, (void **)&mp_data);
438         if (ret != MEDIA_PACKET_ERROR_NONE) {
439                 LOGE("media_packet_get_extra failed 0x%x", ret);
440                 return MEDIA_PACKET_FINALIZE;
441         }
442
443         /*LOGD("mp_data %p", mp_data);*/
444
445         if (mp_data) {
446                 int tbm_key = mp_data->tbm_key;
447
448                 /* release imported bo */
449                 for (i = 0 ; i < mp_data->num_buffer_key ; i++) {
450                         tbm_bo_unref(mp_data->buffer_bo[i]);
451                         mp_data->buffer_bo[i] = NULL;
452                 }
453
454                 /* unmap and unref tbm bo */
455                 _release_imported_bo(&mp_data->bo);
456
457                 /* return buffer */
458                 muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER,
459                         cb_info->fd, cb_info, INT, tbm_key);
460                 g_free(mp_data);
461                 mp_data = NULL;
462         }
463
464         ret = media_packet_get_tbm_surface(pkt, &tsurf);
465         if (ret != MEDIA_PACKET_ERROR_NONE) {
466                 LOGE("media_packet_get_tbm_surface failed 0x%x", ret);
467                 return MEDIA_PACKET_FINALIZE;
468         }
469
470         if (tsurf) {
471                 tbm_surface_destroy(tsurf);
472                 tsurf = NULL;
473         }
474
475         return MEDIA_PACKET_FINALIZE;
476 }
477
478 static void _client_user_callback(camera_cb_info_s *cb_info, char *recv_msg, muse_camera_event_e event)
479 {
480         int param1 = 0;
481         int param2 = 0;
482         int tbm_key = 0;
483         tbm_bo bo = NULL;
484         tbm_bo_handle bo_handle = {NULL, };
485
486         if (recv_msg == NULL || event >= MUSE_CAMERA_EVENT_TYPE_NUM) {
487                 LOGE("invalid parameter - camera msg %p, event %d", recv_msg, event);
488                 return;
489         }
490
491         LOGD("get camera msg %s, event %d", recv_msg, event);
492
493         if (event == MUSE_CAMERA_EVENT_TYPE_PREVIEW) {
494                 if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW] == NULL &&
495                         cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW] == NULL) {
496                         LOGW("all preview callback from user are NULL");
497                         return;
498                 }
499         } else if (cb_info->user_cb[event] == NULL) {
500                 LOGW("user callback for event %d is not set", event);
501                 return;
502         }
503
504         switch (event) {
505         case MUSE_CAMERA_EVENT_TYPE_STATE_CHANGE:
506                 {
507                         int previous = 0;
508                         int current = 0;
509                         int by_policy = 0;
510
511                         muse_camera_msg_get(previous, recv_msg);
512                         muse_camera_msg_get(current, recv_msg);
513                         muse_camera_msg_get(by_policy, recv_msg);
514
515                         LOGD("STATE CHANGE - previous %d, current %d, by_policy %d",
516                              previous, current, by_policy);
517
518                         ((camera_state_changed_cb)cb_info->user_cb[event])((camera_state_e)previous,
519                                 (camera_state_e)current, (bool)by_policy, cb_info->user_data[event]);
520                 }
521                 break;
522         case MUSE_CAMERA_EVENT_TYPE_FOCUS_CHANGE:
523                 {
524                         int state = 0;
525
526                         muse_camera_msg_get(state, recv_msg);
527
528                         LOGD("FOCUS state - %d", state);
529
530                         ((camera_focus_changed_cb)cb_info->user_cb[event])((camera_focus_state_e)state, cb_info->user_data[event]);
531                 }
532                 break;
533         case MUSE_CAMERA_EVENT_TYPE_CAPTURE_COMPLETE:
534                 LOGD("CAPTURE_COMPLETED");
535                 ((camera_capture_completed_cb)cb_info->user_cb[event])(cb_info->user_data[event]);
536                 break;
537         case MUSE_CAMERA_EVENT_TYPE_PREVIEW:
538         case MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW:
539                 {
540                         camera_preview_data_s frame;
541                         unsigned char *buf_pos = NULL;
542                         camera_stream_data_s *stream = NULL;
543                         int i = 0;
544                         int total_size = 0;
545                         int num_buffer_key = 0;
546                         int buffer_key[BUFFER_MAX_PLANE_NUM] = {0, };
547                         tbm_bo buffer_bo[BUFFER_MAX_PLANE_NUM] = {NULL, };
548                         tbm_bo_handle buffer_bo_handle[BUFFER_MAX_PLANE_NUM] = {{.ptr = NULL}, };
549                         camera_media_packet_data *mp_data = NULL;
550
551                         muse_camera_msg_get(tbm_key, recv_msg);
552                         muse_camera_msg_get(num_buffer_key, recv_msg);
553                         muse_camera_msg_get_array(buffer_key, recv_msg);
554
555                         memset(&frame, 0x0, sizeof(camera_preview_data_s));
556
557                         if (tbm_key <= 0) {
558                                 LOGE("invalid key %d", tbm_key);
559                                 break;
560                         }
561
562                         /* import tbm bo and get virtual address */
563                         if (!_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle)) {
564                                 LOGE("failed to import key %d", tbm_key);
565
566                                 muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER,
567                                         cb_info->fd, cb_info, INT, tbm_key);
568                                 break;
569                         }
570
571                         buf_pos = (unsigned char *)bo_handle.ptr;
572
573                         /* get stream info */
574                         stream = (camera_stream_data_s *)buf_pos;
575
576                         for (i = 0 ; i < num_buffer_key ; i++) {
577                                 /* import buffer bo and get virtual address */
578                                 if (!_import_tbm_key(cb_info->bufmgr, buffer_key[i], &buffer_bo[i], &buffer_bo_handle[i])) {
579                                         LOGE("failed to import buffer key %d", buffer_key[i]);
580
581                                         /* release imported bo */
582                                         for (i -= 1 ; i >= 0 ; i--)
583                                                 _release_imported_bo(&buffer_bo[i]);
584
585                                         _release_imported_bo(&bo);
586
587                                         /* send return buffer */
588                                         muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER,
589                                                 cb_info->fd, cb_info, INT, tbm_key);
590                                         return;
591                                 }
592                         }
593
594                         if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_PREVIEW]) {
595                                 /* set frame info */
596                                 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
597                                         frame.format  = MM_PIXEL_FORMAT_UYVY;
598                                 else
599                                         frame.format = stream->format;
600                                 frame.width = stream->width;
601                                 frame.height = stream->height;
602                                 frame.timestamp = stream->timestamp;
603                                 frame.num_of_planes = stream->num_planes;
604
605                                 if (num_buffer_key == 0) {
606                                         /* non-zero copy */
607                                         buf_pos += sizeof(camera_stream_data_s);
608
609                                         if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) {
610                                                 frame.data.encoded_plane.data = buf_pos;
611                                                 frame.data.encoded_plane.size = stream->data.encoded.length_data;
612                                                 total_size = stream->data.encoded.length_data;
613                                         } else {
614                                                 switch (stream->num_planes) {
615                                                 case 1:
616                                                         frame.data.single_plane.yuv = buf_pos;
617                                                         frame.data.single_plane.size = stream->data.yuv420.length_yuv;
618                                                         total_size = stream->data.yuv420.length_yuv;
619                                                         break;
620                                                 case 2:
621                                                         frame.data.double_plane.y = buf_pos;
622                                                         frame.data.double_plane.y_size = stream->data.yuv420sp.length_y;
623                                                         buf_pos += stream->data.yuv420sp.length_y;
624                                                         frame.data.double_plane.uv = buf_pos;
625                                                         frame.data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
626                                                         total_size = stream->data.yuv420sp.length_y + \
627                                                                 stream->data.yuv420sp.length_uv;
628                                                         break;
629                                                 case 3:
630                                                         frame.data.triple_plane.y = buf_pos;
631                                                         frame.data.triple_plane.y_size = stream->data.yuv420p.length_y;
632                                                         buf_pos += stream->data.yuv420p.length_y;
633                                                         frame.data.triple_plane.u = buf_pos;
634                                                         frame.data.triple_plane.u_size = stream->data.yuv420p.length_u;
635                                                         buf_pos += stream->data.yuv420p.length_u;
636                                                         frame.data.triple_plane.v = buf_pos;
637                                                         frame.data.triple_plane.v_size = stream->data.yuv420p.length_v;
638                                                         total_size = stream->data.yuv420p.length_y + \
639                                                                 stream->data.yuv420p.length_u + \
640                                                                 stream->data.yuv420p.length_v;
641                                                         break;
642                                                 default:
643                                                         break;
644                                                 }
645                                         }
646                                 } else {
647                                         /* zero copy */
648                                         switch (stream->num_planes) {
649                                         case 1:
650                                                 frame.data.single_plane.yuv = buffer_bo_handle[0].ptr;
651                                                 frame.data.single_plane.size = stream->data.yuv420.length_yuv;
652                                                 total_size = stream->data.yuv420.length_yuv;
653                                                 break;
654                                         case 2:
655                                                 frame.data.double_plane.y = buffer_bo_handle[0].ptr;
656                                                 if (stream->num_planes == (unsigned int)num_buffer_key)
657                                                         frame.data.double_plane.uv = buffer_bo_handle[1].ptr;
658                                                 else
659                                                         frame.data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
660                                                 frame.data.double_plane.y_size = stream->data.yuv420sp.length_y;
661                                                 frame.data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
662                                                 total_size = stream->data.yuv420sp.length_y + \
663                                                         stream->data.yuv420sp.length_uv;
664                                                 break;
665                                         case 3:
666                                                 frame.data.triple_plane.y = buffer_bo_handle[0].ptr;
667                                                 if (stream->num_planes == (unsigned int)num_buffer_key) {
668                                                         frame.data.triple_plane.u = buffer_bo_handle[1].ptr;
669                                                         frame.data.triple_plane.v = buffer_bo_handle[2].ptr;
670                                                 } else {
671                                                         frame.data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y;
672                                                         frame.data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u;
673                                                 }
674                                                 frame.data.triple_plane.y_size = stream->data.yuv420p.length_y;
675                                                 frame.data.triple_plane.u_size = stream->data.yuv420p.length_u;
676                                                 frame.data.triple_plane.v_size = stream->data.yuv420p.length_v;
677                                                 total_size = stream->data.yuv420p.length_y + \
678                                                         stream->data.yuv420p.length_u + \
679                                                         stream->data.yuv420p.length_v;
680                                                 break;
681                                         default:
682                                                 break;
683                                         }
684                                 }
685
686                                 /*
687                                 LOGD("PREVIEW_CB - format %d, %dx%d, size %d plane num %d",
688                                      frame.format, frame.width, frame.height, total_size, frame.num_of_planes);
689                                 */
690
691                                 ((camera_preview_cb)cb_info->user_cb[event])(&frame, cb_info->user_data[event]);
692
693                                 /*LOGD("PREVIEW_CB retuned");*/
694                         }
695
696                         if (cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW]) {
697                                 media_packet_h pkt = NULL;
698                                 tbm_surface_h tsurf = NULL;
699                                 uint32_t bo_format = 0;
700                                 int ret = 0;
701                                 media_format_mimetype_e mimetype = MEDIA_FORMAT_NV12;
702                                 bool make_pkt_fmt = false;
703                                 tbm_surface_info_s tsurf_info;
704
705                                 memset(&tsurf_info, 0x0, sizeof(tbm_surface_info_s));
706
707                                 /* unmap buffer bo */
708                                 for (i = 0 ; i < num_buffer_key ; i++) {
709                                         if (buffer_bo[i])
710                                                 tbm_bo_unmap(buffer_bo[i]);
711                                 }
712
713                                 /* create tbm surface */
714                                 for (i = 0 ; i < BUFFER_MAX_PLANE_NUM ; i++)
715                                         tsurf_info.planes[i].stride = stream->stride[i];
716
717                                 /* get tbm surface format */
718                                 ret = _camera_get_tbm_surface_format(stream->format, &bo_format);
719                                 ret |= _camera_get_media_packet_mimetype(stream->format, &mimetype);
720
721                                 if (num_buffer_key > 0 && ret == CAMERA_ERROR_NONE) {
722                                         tsurf_info.width = stream->width;
723                                         tsurf_info.height = stream->height;
724                                         tsurf_info.format = bo_format;
725                                         tsurf_info.bpp = tbm_surface_internal_get_bpp(bo_format);
726                                         tsurf_info.num_planes = tbm_surface_internal_get_num_planes(bo_format);
727
728                                         switch (bo_format) {
729                                         case TBM_FORMAT_NV12:
730                                         case TBM_FORMAT_NV21:
731                                                 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
732                                                 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
733                                                 tsurf_info.planes[0].offset = 0;
734                                                 if (num_buffer_key == 1)
735                                                         tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
736                                                 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
737                                                 break;
738                                         case TBM_FORMAT_YUV420:
739                                         case TBM_FORMAT_YVU420:
740                                                 tsurf_info.planes[0].size = stream->stride[0] * stream->elevation[0];
741                                                 tsurf_info.planes[1].size = stream->stride[1] * stream->elevation[1];
742                                                 tsurf_info.planes[2].size = stream->stride[2] * stream->elevation[2];
743                                                 tsurf_info.planes[0].offset = 0;
744                                                 if (num_buffer_key == 1) {
745                                                         tsurf_info.planes[1].offset = tsurf_info.planes[0].size;
746                                                         tsurf_info.planes[2].offset = tsurf_info.planes[0].size + tsurf_info.planes[1].size;
747                                                 }
748                                                 tsurf_info.size = tsurf_info.planes[0].size + tsurf_info.planes[1].size + tsurf_info.planes[2].size;
749                                                 break;
750                                         case TBM_FORMAT_UYVY:
751                                         case TBM_FORMAT_YUYV:
752                                                 tsurf_info.planes[0].size = (stream->stride[0] * stream->elevation[0]) << 1;
753                                                 tsurf_info.planes[0].offset = 0;
754                                                 tsurf_info.size = tsurf_info.planes[0].size;
755                                                 break;
756                                         default:
757                                                 break;
758                                         }
759
760                                         tsurf = tbm_surface_internal_create_with_bos(&tsurf_info, buffer_bo, num_buffer_key);
761                                         /*LOGD("tbm surface %p", tsurf);*/
762                                 }
763
764                                 if (tsurf) {
765                                         /* check media packet format */
766                                         if (cb_info->pkt_fmt) {
767                                                 int pkt_fmt_width = 0;
768                                                 int pkt_fmt_height = 0;
769                                                 media_format_mimetype_e pkt_fmt_mimetype = MEDIA_FORMAT_NV12;
770
771                                                 media_format_get_video_info(cb_info->pkt_fmt, &pkt_fmt_mimetype, &pkt_fmt_width, &pkt_fmt_height, NULL, NULL);
772                                                 if (pkt_fmt_mimetype != mimetype ||
773                                                     pkt_fmt_width != stream->width ||
774                                                     pkt_fmt_height != stream->height) {
775                                                         LOGW("different format. current 0x%x, %dx%d, new 0x%x, %dx%d",
776                                                              pkt_fmt_mimetype, pkt_fmt_width, pkt_fmt_height, mimetype, stream->width, stream->height);
777                                                         media_format_unref(cb_info->pkt_fmt);
778                                                         cb_info->pkt_fmt = NULL;
779                                                         make_pkt_fmt = true;
780                                                 }
781                                         } else {
782                                                 make_pkt_fmt = true;
783                                         }
784
785                                         /* create packet format */
786                                         if (make_pkt_fmt) {
787                                                 LOGW("make new pkt_fmt - mimetype 0x%x, %dx%d", mimetype, stream->width, stream->height);
788                                                 ret = media_format_create(&cb_info->pkt_fmt);
789                                                 if (ret == MEDIA_FORMAT_ERROR_NONE) {
790                                                         ret = media_format_set_video_mime(cb_info->pkt_fmt, mimetype);
791                                                         ret |= media_format_set_video_width(cb_info->pkt_fmt, stream->width);
792                                                         ret |= media_format_set_video_height(cb_info->pkt_fmt, stream->height);
793                                                         LOGW("media_format_set_video_mime,width,height ret : 0x%x", ret);
794                                                 } else {
795                                                         LOGW("media_format_create failed");
796                                                 }
797                                         }
798
799                                         /* create media packet */
800                                         ret = media_packet_create_from_tbm_surface(cb_info->pkt_fmt,
801                                                 tsurf, (media_packet_finalize_cb)_camera_media_packet_finalize,
802                                                 (void *)cb_info, &pkt);
803                                         if (ret != MEDIA_PACKET_ERROR_NONE) {
804                                                 LOGE("media_packet_create_from_tbm_surface failed");
805
806                                                 tbm_surface_destroy(tsurf);
807                                                 tsurf = NULL;
808                                         }
809                                 } else {
810                                         LOGE("failed to create tbm surface %dx%d, format %d, num_buffer_key %d",
811                                              stream->width, stream->height, stream->format, num_buffer_key);
812                                 }
813
814                                 if (pkt) {
815                                         /*LOGD("media packet %p, internal buffer %p", pkt, stream->internal_buffer);*/
816
817                                         mp_data = g_new0(camera_media_packet_data, 1);
818                                         if (mp_data) {
819                                                 mp_data->tbm_key = tbm_key;
820                                                 mp_data->num_buffer_key = num_buffer_key;
821                                                 mp_data->bo = bo;
822                                                 for (i = 0 ; i < num_buffer_key ; i++)
823                                                         mp_data->buffer_bo[i] = buffer_bo[i];
824
825                                                 /* set media packet data */
826                                                 ret = media_packet_set_extra(pkt, (void *)mp_data);
827                                                 if (ret != MEDIA_PACKET_ERROR_NONE) {
828                                                         LOGE("media_packet_set_extra failed");
829
830                                                         if (mp_data) {
831                                                                 g_free(mp_data);
832                                                                 mp_data = NULL;
833                                                         }
834
835                                                         media_packet_destroy(pkt);
836                                                         pkt = NULL;
837                                                 } else {
838                                                         int e_type = MUSE_CAMERA_EVENT_TYPE_MEDIA_PACKET_PREVIEW;
839
840                                                         /* set timestamp : msec -> nsec */
841                                                         if (media_packet_set_pts(pkt, (uint64_t)(stream->timestamp) * 1000000) != MEDIA_PACKET_ERROR_NONE)
842                                                                 LOGW("media_packet_set_pts failed");
843
844                                                         /* call media packet callback */
845                                                         ((camera_media_packet_preview_cb)cb_info->user_cb[e_type])(pkt, cb_info->user_data[e_type]);
846                                                 }
847                                         } else {
848                                                 LOGE("failed to alloc media packet data");
849                                         }
850                                 }
851                         }
852
853                         /* send message for preview callback return */
854                         muse_camera_msg_send_no_return(MUSE_CAMERA_API_PREVIEW_CB_RETURN, cb_info->fd, cb_info);
855
856                         if (mp_data == NULL) {
857                                 /* release imported bo */
858                                 for (i = 0 ; i < num_buffer_key ; i++)
859                                         _release_imported_bo(&buffer_bo[i]);
860
861                                 /* unmap and unref tbm bo */
862                                 _release_imported_bo(&bo);
863
864                                 /* return buffer */
865                                 muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER,
866                                         cb_info->fd, cb_info, INT, tbm_key);
867
868                                 /*LOGD("return buffer Done");*/
869                         }
870                 }
871                 break;
872         case MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS:
873                 {
874                         int percent = 0;
875
876                         muse_camera_msg_get(percent, recv_msg);
877
878                         LOGD("HDR progress - %d \%", percent);
879
880                         ((camera_attr_hdr_progress_cb)cb_info->user_cb[event])(percent, cb_info->user_data[event]);
881                 }
882                 break;
883         case MUSE_CAMERA_EVENT_TYPE_INTERRUPTED:
884                 {
885                         int policy = 0;
886                         int previous = 0;
887                         int current = 0;
888
889                         muse_camera_msg_get(policy, recv_msg);
890                         muse_camera_msg_get(previous, recv_msg);
891                         muse_camera_msg_get(current, recv_msg);
892
893                         LOGD("INTERRUPTED - policy %d, state previous %d, current %d",
894                              policy, previous, current);
895
896                         ((camera_interrupted_cb)cb_info->user_cb[event])((camera_policy_e)policy,
897                                 (camera_state_e)previous, (camera_state_e)current, cb_info->user_data[event]);
898                 }
899                 break;
900         case MUSE_CAMERA_EVENT_TYPE_FACE_DETECTION:
901                 {
902                         int count = 0;
903                         camera_detected_face_s *faces = NULL;
904
905                         muse_camera_msg_get(count, recv_msg);
906                         muse_camera_msg_get(tbm_key, recv_msg);
907
908                         if (count > 0 && tbm_key > 0) {
909                                 LOGD("FACE_DETECTION - count %d, tbm_key %d", count, tbm_key);
910
911                                 if (!_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle))
912                                         break;
913
914                                 /* set face info */
915                                 faces = bo_handle.ptr;
916
917                                 ((camera_face_detected_cb)cb_info->user_cb[event])(faces, count, cb_info->user_data[event]);
918
919 #if 0
920                                 {
921                                         int i = 0;
922
923                                         for (i = 0 ; i < count ; i++) {
924                                                 LOGD("id[%2d] - score %d, position (%d,%d,%dx%d)",
925                                                      i, faces[i].score, faces[i].x, faces[i].y, faces[i].width, faces[i].height);
926                                         }
927                                 }
928 #endif
929
930                                 /* release bo */
931                                 _release_imported_bo(&bo);
932
933                                 /* return buffer */
934                                 muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER,
935                                         cb_info->fd, cb_info, INT, tbm_key);
936
937                                 LOGD("return buffer done");
938                         } else {
939                                 LOGE("invalid message - count %d, key %d", count, tbm_key);
940                         }
941                 }
942                 break;
943         case MUSE_CAMERA_EVENT_TYPE_ERROR:
944                 {
945                         int error = 0;
946                         int current_state = 0;
947
948                         muse_camera_msg_get(error, recv_msg);
949                         muse_camera_msg_get(current_state, recv_msg);
950
951                         LOGE("ERROR - error 0x%x, current_state %d", error, current_state);
952
953                         ((camera_error_cb)cb_info->user_cb[event])((camera_error_e)error,
954                                 (camera_state_e)current_state, cb_info->user_data[event]);
955                 }
956                 break;
957         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_RESOLUTION:
958                 muse_camera_msg_get(param1, recv_msg);
959                 muse_camera_msg_get(param2, recv_msg);
960
961                 LOGD("SUPPORTED_PREVIEW_RESOLUTION - %d x %d", param1, param2);
962
963                 if (((camera_supported_preview_resolution_cb)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
964                         cb_info->user_cb[event] = NULL;
965                         cb_info->user_data[event] = NULL;
966                         LOGD("stop foreach callback for SUPPORTED_PREVIEW_RESOLUTION");
967                 }
968                 break;
969         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_RESOLUTION:
970                 muse_camera_msg_get(param1, recv_msg);
971                 muse_camera_msg_get(param2, recv_msg);
972
973                 LOGD("SUPPORTED_CAPTURE_RESOLUTION - %d x %d", param1, param2);
974
975                 if (((camera_supported_capture_resolution_cb)cb_info->user_cb[event])(param1, param2, cb_info->user_data[event]) == false) {
976                         cb_info->user_cb[event] = NULL;
977                         cb_info->user_data[event] = NULL;
978                         LOGD("stop foreach callback for SUPPORTED_CAPTURE_RESOLUTION");
979                 }
980                 break;
981         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_CAPTURE_FORMAT:
982                 muse_camera_msg_get(param1, recv_msg);
983
984                 LOGD("SUPPORTED_CAPTURE_FORMAT - %d ", param1);
985
986                 if (((camera_supported_capture_format_cb)cb_info->user_cb[event])((camera_pixel_format_e)param1, cb_info->user_data[event]) == false) {
987                         cb_info->user_cb[event] = NULL;
988                         cb_info->user_data[event] = NULL;
989                         LOGD("stop foreach callback for SUPPORTED_CAPTURE_FORMAT");
990                 }
991                 break;
992         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_PREVIEW_FORMAT:
993                 muse_camera_msg_get(param1, recv_msg);
994
995                 LOGD("SUPPORTED_PREVIEW_FORMAT - %d ", param1);
996
997                 if (((camera_supported_preview_format_cb)cb_info->user_cb[event])((camera_pixel_format_e)param1, cb_info->user_data[event]) == false) {
998                         cb_info->user_cb[event] = NULL;
999                         cb_info->user_data[event] = NULL;
1000                         LOGD("stop foreach callback for SUPPORTED_PREVIEW_FORMAT");
1001                 }
1002                 break;
1003         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE:
1004                 muse_camera_msg_get(param1, recv_msg);
1005
1006                 LOGD("SUPPORTED_AF_MODE - %d ", param1);
1007
1008                 if (((camera_attr_supported_af_mode_cb)cb_info->user_cb[event])((camera_attr_af_mode_e)param1, cb_info->user_data[event]) == false) {
1009                         cb_info->user_cb[event] = NULL;
1010                         cb_info->user_data[event] = NULL;
1011                         LOGD("stop foreach callback for SUPPORTED_AF_MODE");
1012                 }
1013                 break;
1014         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE:
1015                 muse_camera_msg_get(param1, recv_msg);
1016
1017                 LOGD("SUPPORTED_EXPOSURE_MODE - %d ", param1);
1018
1019                 if (((camera_attr_supported_exposure_mode_cb)cb_info->user_cb[event])((camera_attr_exposure_mode_e)param1, cb_info->user_data[event]) == false) {
1020                         cb_info->user_cb[event] = NULL;
1021                         cb_info->user_data[event] = NULL;
1022                         LOGD("stop foreach callback for SUPPORTED_EXPOSURE_MODE");
1023                 }
1024                 break;
1025         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO:
1026                 muse_camera_msg_get(param1, recv_msg);
1027
1028                 LOGD("SUPPORTED_ISO - %d ", param1);
1029
1030                 if (((camera_attr_supported_iso_cb)cb_info->user_cb[event])((camera_attr_iso_e)param1, cb_info->user_data[event]) == false) {
1031                         cb_info->user_cb[event] = NULL;
1032                         cb_info->user_data[event] = NULL;
1033                         LOGD("stop foreach callback for SUPPORTED_ISO");
1034                 }
1035                 break;
1036         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE:
1037                 muse_camera_msg_get(param1, recv_msg);
1038
1039                 LOGD("SUPPORTED_WHITEBALANCE - %d ", param1);
1040
1041                 if (((camera_attr_supported_whitebalance_cb)cb_info->user_cb[event])((camera_attr_whitebalance_e)param1, cb_info->user_data[event]) == false) {
1042                         cb_info->user_cb[event] = NULL;
1043                         cb_info->user_data[event] = NULL;
1044                         LOGD("stop foreach callback for SUPPORTED_WHITEBALANCE");
1045                 }
1046                 break;
1047         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT:
1048                 muse_camera_msg_get(param1, recv_msg);
1049
1050                 LOGD("SUPPORTED_EFFECT - %d ", param1);
1051
1052                 if (((camera_attr_supported_effect_cb)cb_info->user_cb[event])((camera_attr_effect_mode_e)param1, cb_info->user_data[event]) == false) {
1053                         cb_info->user_cb[event] = NULL;
1054                         cb_info->user_data[event] = NULL;
1055                         LOGD("stop foreach callback for SUPPORTED_EFFECT");
1056                 }
1057                 break;
1058         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE:
1059                 muse_camera_msg_get(param1, recv_msg);
1060
1061                 LOGD("SUPPORTED_SCENE_MODE - %d ", param1);
1062
1063                 if (((camera_attr_supported_scene_mode_cb)cb_info->user_cb[event])((camera_attr_scene_mode_e)param1, cb_info->user_data[event]) == false) {
1064                         cb_info->user_cb[event] = NULL;
1065                         cb_info->user_data[event] = NULL;
1066                         LOGD("stop foreach callback for SUPPORTED_SCENE_MODE");
1067                 }
1068                 break;
1069         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE:
1070                 muse_camera_msg_get(param1, recv_msg);
1071
1072                 LOGD("SUPPORTED_FLASH_MODE - %d ", param1);
1073
1074                 if (((camera_attr_supported_flash_mode_cb)cb_info->user_cb[event])((camera_attr_flash_mode_e)param1, cb_info->user_data[event]) == false) {
1075                         cb_info->user_cb[event] = NULL;
1076                         cb_info->user_data[event] = NULL;
1077                         LOGD("stop foreach callback for SUPPORTED_FLASH_MODE");
1078                 }
1079                 break;
1080         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS:
1081                 muse_camera_msg_get(param1, recv_msg);
1082
1083                 LOGD("SUPPORTED_FPS - %d ", param1);
1084
1085                 if (((camera_attr_supported_fps_cb)cb_info->user_cb[event])((camera_attr_fps_e)param1, cb_info->user_data[event]) == false) {
1086                         cb_info->user_cb[event] = NULL;
1087                         cb_info->user_data[event] = NULL;
1088                         LOGD("stop foreach callback for SUPPORTED_FPS");
1089                 }
1090                 break;
1091         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION:
1092                 muse_camera_msg_get(param1, recv_msg);
1093
1094                 LOGD("SUPPORTED_FPS_BY_RESOLUTION - %d ", param1);
1095
1096                 if (((camera_attr_supported_fps_cb)cb_info->user_cb[event])((camera_attr_fps_e)param1, cb_info->user_data[event]) == false) {
1097                         cb_info->user_cb[event] = NULL;
1098                         cb_info->user_data[event] = NULL;
1099                         LOGD("stop foreach callback for SUPPORTED_FPS_BY_RESOLUTION");
1100                 }
1101                 break;
1102         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP:
1103                 muse_camera_msg_get(param1, recv_msg);
1104
1105                 LOGD("SUPPORTED_STREAM_FLIP - %d ", param1);
1106
1107                 if (((camera_attr_supported_stream_flip_cb)cb_info->user_cb[event])((camera_flip_e)param1, cb_info->user_data[event]) == false) {
1108                         cb_info->user_cb[event] = NULL;
1109                         cb_info->user_data[event] = NULL;
1110                         LOGD("stop foreach callback for SUPPORTED_STREAM_FLIP");
1111                 }
1112                 break;
1113         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION:
1114                 muse_camera_msg_get(param1, recv_msg);
1115
1116                 LOGD("SUPPORTED_STREAM_ROTATION - %d ", param1);
1117
1118                 if (((camera_attr_supported_stream_rotation_cb)cb_info->user_cb[event])((camera_rotation_e)param1, cb_info->user_data[event]) == false) {
1119                         cb_info->user_cb[event] = NULL;
1120                         cb_info->user_data[event] = NULL;
1121                         LOGD("stop foreach callback for SUPPORTED_STREAM_ROTATION");
1122                 }
1123                 break;
1124         case MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_THEATER_MODE:
1125                 muse_camera_msg_get(param1, recv_msg);
1126
1127                 LOGD("SUPPORTED_THEATER_MODE - %d ", param1);
1128
1129                 if (((camera_attr_supported_theater_mode_cb)cb_info->user_cb[event])((camera_attr_theater_mode_e)param1, cb_info->user_data[event]) == false) {
1130                         cb_info->user_cb[event] = NULL;
1131                         cb_info->user_data[event] = NULL;
1132                         LOGD("stop foreach callback for SUPPORTED_THEATER_MODE");
1133                 }
1134                 break;
1135         case MUSE_CAMERA_EVENT_TYPE_CAPTURE:
1136                 {
1137                         camera_image_data_s *rImage = NULL;
1138                         camera_image_data_s *rPostview = NULL;
1139                         camera_image_data_s *rThumbnail = NULL;
1140                         unsigned char *buf_pos = NULL;
1141                         int is_postview = 0;
1142                         int is_thumbnail = 0;
1143
1144                         muse_camera_msg_get(tbm_key, recv_msg);
1145                         muse_camera_msg_get(is_postview, recv_msg);
1146                         muse_camera_msg_get(is_thumbnail, recv_msg);
1147
1148                         LOGD("camera capture callback came in. key %d, postview %d, thumbnail %d",
1149                              tbm_key, is_postview, is_thumbnail);
1150
1151                         if (tbm_key <= 0) {
1152                                 LOGE("invalid key %d", tbm_key);
1153                                 break;
1154                         }
1155
1156                         /* import tbm bo and get virtual address */
1157                         if (!_import_tbm_key(cb_info->bufmgr, tbm_key, &bo, &bo_handle))
1158                                 break;
1159
1160                         buf_pos = (unsigned char *)bo_handle.ptr;
1161                         rImage = (camera_image_data_s *)buf_pos;
1162                         rImage->data = buf_pos + sizeof(camera_image_data_s);
1163                         buf_pos += sizeof(camera_image_data_s) + rImage->size;
1164
1165                         if (is_postview) {
1166                                 rPostview = (camera_image_data_s *)buf_pos;
1167                                 LOGD("rPostview->size : %d", rPostview->size);
1168                                 rPostview->data = buf_pos + sizeof(camera_image_data_s);
1169                                 buf_pos += sizeof(camera_image_data_s) + rPostview->size;
1170                         }
1171
1172                         if (is_thumbnail) {
1173                                 rThumbnail = (camera_image_data_s *)buf_pos;
1174                                 LOGD("rThumbnail->size : %d", rThumbnail->size);
1175                                 rThumbnail->data = buf_pos + sizeof(camera_image_data_s);
1176                                 buf_pos += sizeof(camera_image_data_s) + rThumbnail->size;
1177                         }
1178
1179                         LOGD("image info %dx%d, size : %d", rImage->height, rImage->width, rImage->size);
1180
1181                         ((camera_capturing_cb)cb_info->user_cb[event])(rImage, rPostview, rThumbnail, cb_info->user_data[event]);
1182
1183                         /* unmap and unref tbm bo */
1184                         _release_imported_bo(&bo);
1185
1186                         /* return buffer */
1187                         muse_camera_msg_send1_no_return(MUSE_CAMERA_API_RETURN_BUFFER,
1188                                 cb_info->fd, cb_info, INT, tbm_key);
1189
1190                         LOGD("return buffer done");
1191                 }
1192                 break;
1193         case MUSE_CAMERA_EVENT_TYPE_VIDEO_FRAME_RENDER_ERROR:
1194                 break;
1195         default:
1196                 LOGW("Unknown event : %d", event);
1197                 break;
1198         }
1199
1200         return;
1201 }
1202
1203 static bool _camera_idle_event_callback(void *data)
1204 {
1205         camera_cb_info_s *cb_info = NULL;
1206         camera_idle_event_s *cam_idle_event = (camera_idle_event_s *)data;
1207
1208         if (cam_idle_event == NULL) {
1209                 LOGE("cam_idle_event is NULL");
1210                 return false;
1211         }
1212
1213         /* lock event */
1214         g_mutex_lock(&cam_idle_event->event_mutex);
1215
1216         cb_info = cam_idle_event->cb_info;
1217         if (cb_info == NULL) {
1218                 LOGW("camera cb_info is NULL. event %d", cam_idle_event->event);
1219                 goto IDLE_EVENT_CALLBACK_DONE;
1220         }
1221
1222         /* remove event from list */
1223         g_mutex_lock(&cb_info->idle_event_mutex);
1224         if (cb_info->idle_event_list)
1225                 cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1226
1227         /*LOGD("remove camera idle event %p, %p", cam_idle_event, cb_info->idle_event_list);*/
1228         g_mutex_unlock(&cb_info->idle_event_mutex);
1229
1230         /* user callback */
1231         _client_user_callback(cam_idle_event->cb_info, cam_idle_event->recv_msg, cam_idle_event->event);
1232
1233         /* send signal for waiting thread */
1234         g_cond_signal(&cb_info->idle_event_cond);
1235
1236 IDLE_EVENT_CALLBACK_DONE:
1237         /* unlock and release event */
1238         g_mutex_unlock(&cam_idle_event->event_mutex);
1239         g_mutex_clear(&cam_idle_event->event_mutex);
1240
1241         g_free(cam_idle_event);
1242         cam_idle_event = NULL;
1243
1244         return false;
1245 }
1246
1247 static void *_camera_msg_handler_func(gpointer data)
1248 {
1249         int ret = 0;
1250         int api = 0;
1251         int event = 0;
1252         int event_class = 0;
1253         camera_message_s *cam_msg = NULL;
1254         camera_idle_event_s *cam_idle_event = NULL;
1255         camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
1256
1257         if (cb_info == NULL) {
1258                 LOGE("cb_info NULL");
1259                 return NULL;
1260         }
1261
1262         LOGD("start");
1263
1264         g_mutex_lock(&cb_info->msg_handler_mutex);
1265
1266         while (g_atomic_int_get(&cb_info->msg_handler_running)) {
1267                 if (g_queue_is_empty(cb_info->msg_queue)) {
1268                         LOGD("signal wait...");
1269                         g_cond_wait(&cb_info->msg_handler_cond, &cb_info->msg_handler_mutex);
1270                         LOGD("signal received");
1271
1272                         if (g_atomic_int_get(&cb_info->msg_handler_running) == 0) {
1273                                 LOGD("stop event thread");
1274                                 break;
1275                         }
1276                 }
1277
1278                 cam_msg = (camera_message_s *)g_queue_pop_head(cb_info->msg_queue);
1279
1280                 g_mutex_unlock(&cb_info->msg_handler_mutex);
1281
1282                 if (cam_msg == NULL) {
1283                         LOGE("NULL message");
1284                         g_mutex_lock(&cb_info->msg_handler_mutex);
1285                         continue;
1286                 }
1287
1288                 api = cam_msg->api;
1289
1290                 if (api < MUSE_CAMERA_API_MAX) {
1291                         g_mutex_lock(&cb_info->api_mutex[api]);
1292
1293                         if (muse_camera_msg_get(ret, cam_msg->recv_msg)) {
1294                                 cb_info->api_ret[api] = ret;
1295                                 cb_info->api_activating[api] = 1;
1296
1297                                 LOGD("camera api %d - return 0x%x", ret);
1298
1299                                 g_cond_signal(&cb_info->api_cond[api]);
1300                         } else {
1301                                 LOGE("failed to get camera ret for api %d, msg %s", api, cam_msg->recv_msg);
1302                         }
1303
1304                         g_mutex_unlock(&cb_info->api_mutex[api]);
1305                 } else if (api == MUSE_CAMERA_CB_EVENT) {
1306                         event = -1;
1307                         event_class = -1;
1308
1309                         if (!muse_camera_msg_get(event, cam_msg->recv_msg) ||
1310                             !muse_camera_msg_get(event_class, cam_msg->recv_msg)) {
1311                                 LOGE("failed to get camera event %d, class %d", event, event_class);
1312
1313                                 g_free(cam_msg);
1314                                 cam_msg = NULL;
1315
1316                                 g_mutex_lock(&cb_info->msg_handler_mutex);
1317                                 continue;
1318                         }
1319
1320                         switch (event_class) {
1321                         case MUSE_CAMERA_EVENT_CLASS_THREAD_SUB:
1322                                 _client_user_callback(cb_info, cam_msg->recv_msg, event);
1323                                 break;
1324                         case MUSE_CAMERA_EVENT_CLASS_THREAD_MAIN:
1325                                 cam_idle_event = g_new0(camera_idle_event_s, 1);
1326                                 if (cam_idle_event == NULL) {
1327                                         LOGE("cam_idle_event alloc failed");
1328                                         break;
1329                                 }
1330
1331                                 cam_idle_event->event = event;
1332                                 cam_idle_event->cb_info = cb_info;
1333                                 g_mutex_init(&cam_idle_event->event_mutex);
1334                                 memcpy(cam_idle_event->recv_msg, cam_msg->recv_msg, sizeof(cam_idle_event->recv_msg));
1335
1336                                 LOGD("add camera event[%d, %p] to IDLE", event, cam_idle_event);
1337
1338                                 g_mutex_lock(&cb_info->idle_event_mutex);
1339                                 cb_info->idle_event_list = g_list_append(cb_info->idle_event_list, (gpointer)cam_idle_event);
1340                                 g_mutex_unlock(&cb_info->idle_event_mutex);
1341
1342                                 g_idle_add_full(G_PRIORITY_DEFAULT,
1343                                         (GSourceFunc)_camera_idle_event_callback,
1344                                         (gpointer)cam_idle_event,
1345                                         NULL);
1346                                 break;
1347                         default:
1348                                 LOGE("unknown camera event class %d", event_class);
1349                                 break;
1350                         }
1351                 } else {
1352                         LOGE("unknown camera api[%d] message[%s]", api, cam_msg->recv_msg);
1353                 }
1354
1355                 g_free(cam_msg);
1356                 cam_msg = NULL;
1357
1358                 g_mutex_lock(&cb_info->msg_handler_mutex);
1359         }
1360
1361         /* remove remained event */
1362         while (!g_queue_is_empty(cb_info->msg_queue)) {
1363                 cam_msg = (camera_message_s *)g_queue_pop_head(cb_info->msg_queue);
1364                 if (cam_msg) {
1365                         LOGD("remove camera message %p", cam_msg);
1366                         free(cam_msg);
1367                         cam_msg = NULL;
1368                 } else {
1369                         LOGW("NULL camera message");
1370                 }
1371         }
1372
1373         g_mutex_unlock(&cb_info->msg_handler_mutex);
1374
1375         LOGD("return");
1376
1377         return NULL;
1378 }
1379
1380 static void _camera_remove_idle_event_all(camera_cb_info_s *cb_info)
1381 {
1382         camera_idle_event_s *cam_idle_event = NULL;
1383         gboolean ret = TRUE;
1384         GList *list = NULL;
1385         gint64 end_time = 0;
1386
1387         if (cb_info == NULL) {
1388                 LOGE("cb_info is NULL");
1389                 return;
1390         }
1391
1392         g_mutex_lock(&cb_info->idle_event_mutex);
1393
1394         if (cb_info->idle_event_list == NULL) {
1395                 LOGD("No idle event is remained.");
1396         } else {
1397                 list = cb_info->idle_event_list;
1398
1399                 while (list) {
1400                         cam_idle_event = list->data;
1401                         list = g_list_next(list);
1402
1403                         if (!cam_idle_event) {
1404                                 LOGW("Fail to remove idle event. The event is NULL");
1405                         } else {
1406                                 if (g_mutex_trylock(&cam_idle_event->event_mutex)) {
1407                                         ret = g_idle_remove_by_data(cam_idle_event);
1408
1409                                         LOGD("remove idle event [%p], ret[%d]", cam_idle_event, ret);
1410
1411                                         if (ret == FALSE) {
1412                                                 cam_idle_event->cb_info = NULL;
1413                                                 LOGW("idle callback for event %p will be called later", cam_idle_event);
1414                                         }
1415
1416                                         cb_info->idle_event_list = g_list_remove(cb_info->idle_event_list, (gpointer)cam_idle_event);
1417
1418                                         g_mutex_unlock(&cam_idle_event->event_mutex);
1419
1420                                         if (ret == TRUE) {
1421                                                 g_mutex_clear(&cam_idle_event->event_mutex);
1422
1423                                                 g_free(cam_idle_event);
1424                                                 cam_idle_event = NULL;
1425
1426                                                 LOGD("remove idle event done");
1427                                         }
1428                                 } else {
1429                                         LOGW("event lock failed. it's being called...");
1430
1431                                         end_time = g_get_monotonic_time() + G_TIME_SPAN_MILLISECOND * 100;
1432
1433                                         if (g_cond_wait_until(&cb_info->idle_event_cond, &cb_info->idle_event_mutex, end_time))
1434                                                 LOGW("signal received");
1435                                         else
1436                                                 LOGW("timeout");
1437                                 }
1438                         }
1439                 }
1440
1441                 g_list_free(cb_info->idle_event_list);
1442                 cb_info->idle_event_list = NULL;
1443         }
1444
1445         g_mutex_unlock(&cb_info->idle_event_mutex);
1446
1447         return;
1448 }
1449
1450 static void *_camera_msg_recv_func(gpointer data)
1451 {
1452         int i = 0;
1453         int ret = 0;
1454         int api = 0;
1455         int api_class = 0;
1456         int num_token = 0;
1457         int str_pos = 0;
1458         int prev_pos = 0;
1459         char *recv_msg = NULL;
1460         char **parse_str = NULL;
1461         camera_cb_info_s *cb_info = (camera_cb_info_s *)data;
1462
1463         if (cb_info == NULL) {
1464                 LOGE("cb_info NULL");
1465                 return NULL;
1466         }
1467
1468         LOGD("start");
1469
1470         parse_str = (char **)malloc(sizeof(char *) * CAMERA_PARSE_STRING_SIZE);
1471         if (parse_str == NULL) {
1472                 LOGE("parse_str malloc failed");
1473                 return NULL;
1474         }
1475
1476         for (i = 0 ; i < CAMERA_PARSE_STRING_SIZE ; i++) {
1477                 parse_str[i] = (char *)malloc(sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
1478                 if (parse_str[i] == NULL) {
1479                         LOGE("parse_str[%d] malloc failed", i);
1480                         goto CB_HANDLER_EXIT;
1481                 }
1482         }
1483
1484         recv_msg = cb_info->recv_msg;
1485
1486         while (g_atomic_int_get(&cb_info->msg_recv_running)) {
1487                 ret = muse_core_ipc_recv_msg(cb_info->fd, recv_msg);
1488                 if (ret <= 0)
1489                         break;
1490                 recv_msg[ret] = '\0';
1491
1492                 str_pos = 0;
1493                 prev_pos = 0;
1494                 num_token = 0;
1495
1496                 /*LOGD("recvMSg : %s, length : %d", recv_msg, ret);*/
1497
1498                 /* Need to split the combined entering msgs.
1499                     This module supports up to 200 combined msgs. */
1500                 for (str_pos = 0; str_pos < ret; str_pos++) {
1501                         if (recv_msg[str_pos] == '}') {
1502                                 memset(parse_str[num_token], 0x0, sizeof(char) * MUSE_CAMERA_MSG_MAX_LENGTH);
1503                                 strncpy(parse_str[num_token], recv_msg + prev_pos, str_pos - prev_pos + 1);
1504                                 LOGD("splitted msg : [%s], Index : %d", parse_str[num_token], num_token);
1505                                 prev_pos = str_pos+1;
1506                                 num_token++;
1507                         }
1508                 }
1509
1510                 /*LOGD("num_token : %d", num_token);*/
1511
1512                 /* Re-construct to the useful single msg. */
1513                 for (i = 0; i < num_token; i++) {
1514                         if (i >= CAMERA_PARSE_STRING_SIZE) {
1515                                 LOGE("invalid token index %d", i);
1516                                 break;
1517                         }
1518
1519                         api = -1;
1520                         api_class = -1;
1521
1522                         if (!muse_camera_msg_get(api, parse_str[i])) {
1523                                 LOGE("failed to get camera api");
1524                                 continue;
1525                         }
1526
1527                         if (api != MUSE_CAMERA_CB_EVENT) {
1528                                 LOGD("check api_class");
1529                                 if (muse_camera_msg_get(api_class, parse_str[i]))
1530                                         LOGD("camera api_class[%d]", api_class);
1531                         }
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
4722         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4723
4724         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4725
4726         if (ret == CAMERA_ERROR_NONE) {
4727                 muse_camera_msg_get_array(get_geotag, pc->cb_info->recv_msg);
4728                 *latitude = get_geotag[0];
4729                 *longitude = get_geotag[1];
4730                 *altitude = get_geotag[2];
4731
4732                 LOGD("ret : 0x%x", ret);
4733         } else {
4734                 LOGE("Returned value is not valid : 0x%x", ret);
4735         }
4736
4737         return ret;
4738 }
4739
4740
4741 int camera_attr_get_flash_mode(camera_h camera,  camera_attr_flash_mode_e *mode)
4742 {
4743         if (camera == NULL || mode == NULL) {
4744                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4745                 return CAMERA_ERROR_INVALID_PARAMETER;
4746         }
4747
4748         int ret = CAMERA_ERROR_NONE;
4749         camera_cli_s *pc = (camera_cli_s *)camera;
4750         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_FLASH_MODE;
4751         int sock_fd;
4752         if (pc->cb_info == NULL) {
4753                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4754                 return CAMERA_ERROR_INVALID_PARAMETER;
4755         }
4756         sock_fd = pc->cb_info->fd;
4757         int get_mode;
4758
4759         LOGD("Enter, remote_handle : %x", pc->remote_handle);
4760         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4761
4762         if (ret == CAMERA_ERROR_NONE) {
4763                 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
4764                 *mode = (camera_attr_flash_mode_e)get_mode;
4765         }
4766         LOGD("ret : 0x%x", ret);
4767         return ret;
4768 }
4769
4770 int camera_get_flash_state(camera_device_e device, camera_flash_state_e *state)
4771 {
4772         int sock_fd = -1;
4773         char *sndMsg;
4774         int ret = CAMERA_ERROR_NONE;
4775         camera_cli_s *pc = NULL;
4776         int get_flash_state = 0;
4777
4778         /* create muse connection */
4779         muse_camera_api_e api = MUSE_CAMERA_API_GET_FLASH_STATE;
4780         muse_core_api_module_e muse_module = MUSE_CAMERA;
4781         int device_type = (int)device;
4782
4783         sock_fd = muse_core_client_new();
4784         if (sock_fd < 0) {
4785                 LOGE("muse_core_client_new failed - returned fd %d", sock_fd);
4786                 ret = CAMERA_ERROR_INVALID_OPERATION;
4787                 goto Exit;
4788         }
4789
4790         sndMsg = muse_core_msg_json_factory_new(api,
4791                 MUSE_TYPE_INT, "module", muse_module,
4792                 MUSE_TYPE_INT, PARAM_DEVICE_TYPE, device_type,
4793                 0);
4794
4795         muse_core_ipc_send_msg(sock_fd, sndMsg);
4796         muse_core_msg_json_factory_free(sndMsg);
4797
4798         pc = g_new0(camera_cli_s, 1);
4799         if (pc == NULL) {
4800                 LOGE("camera_cli_s alloc failed");
4801                 ret = CAMERA_ERROR_OUT_OF_MEMORY;
4802                 goto Exit;
4803         }
4804
4805         pc->cb_info = _client_callback_new(sock_fd);
4806         if (pc->cb_info == NULL) {
4807                 LOGE("cb_info alloc failed");
4808                 ret = CAMERA_ERROR_OUT_OF_MEMORY;
4809                 goto Exit;
4810         }
4811
4812         ret = _client_wait_for_cb_return(api, pc->cb_info, CALLBACK_TIME_OUT);
4813
4814         if (ret == CAMERA_ERROR_NONE) {
4815                 muse_camera_msg_get(get_flash_state, pc->cb_info->recv_msg);
4816                 *state = (camera_flash_state_e)get_flash_state;
4817         }
4818
4819         LOGD("Flash state : %d\n", *state);
4820
4821 Exit:
4822         /* release resources */
4823         if (pc) {
4824                 g_atomic_int_set(&pc->cb_info->msg_recv_running, 0);
4825                 g_atomic_int_set(&pc->cb_info->msg_handler_running, 0);
4826                 _client_callback_destroy(pc->cb_info);
4827                 pc->cb_info = NULL;
4828                 g_free(pc);
4829                 pc = NULL;
4830         }
4831
4832         return ret;
4833 }
4834
4835 int camera_attr_foreach_supported_af_mode(camera_h camera, camera_attr_supported_af_mode_cb foreach_cb, void *user_data)
4836 {
4837         if (camera == NULL || foreach_cb == NULL) {
4838                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4839                 return CAMERA_ERROR_INVALID_PARAMETER;
4840         }
4841         int ret = CAMERA_ERROR_NONE;
4842
4843         camera_cli_s *pc = (camera_cli_s *)camera;
4844         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_AF_MODE;
4845
4846         LOGD("Enter, handle :%x", pc->remote_handle);
4847
4848         int sock_fd;
4849         if (pc->cb_info == NULL) {
4850                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4851                 return CAMERA_ERROR_INVALID_PARAMETER;
4852         }
4853         sock_fd = pc->cb_info->fd;
4854         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = foreach_cb;
4855         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_AF_MODE] = user_data;
4856
4857         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4858         LOGD("ret : 0x%x", ret);
4859         return ret;
4860 }
4861
4862
4863 int camera_attr_foreach_supported_exposure_mode(camera_h camera, camera_attr_supported_exposure_mode_cb foreach_cb , void *user_data)
4864 {
4865         if (camera == NULL || foreach_cb == NULL) {
4866                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4867                 return CAMERA_ERROR_INVALID_PARAMETER;
4868         }
4869         int ret = CAMERA_ERROR_NONE;
4870
4871         camera_cli_s *pc = (camera_cli_s *)camera;
4872         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EXPOSURE_MODE;
4873
4874         LOGD("Enter, handle :%x", pc->remote_handle);
4875
4876         int sock_fd;
4877         if (pc->cb_info == NULL) {
4878                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4879                 return CAMERA_ERROR_INVALID_PARAMETER;
4880         }
4881         sock_fd = pc->cb_info->fd;
4882         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = foreach_cb;
4883         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EXPOSURE_MODE] = user_data;
4884
4885         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4886         LOGD("ret : 0x%x", ret);
4887         return ret;
4888 }
4889
4890
4891 int camera_attr_foreach_supported_iso(camera_h camera, camera_attr_supported_iso_cb foreach_cb, void *user_data)
4892 {
4893         if (camera == NULL || foreach_cb == NULL) {
4894                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4895                 return CAMERA_ERROR_INVALID_PARAMETER;
4896         }
4897         int ret = CAMERA_ERROR_NONE;
4898
4899         camera_cli_s *pc = (camera_cli_s *)camera;
4900         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_ISO;
4901
4902         LOGD("Enter, handle :%x", pc->remote_handle);
4903
4904         int sock_fd;
4905         if (pc->cb_info == NULL) {
4906                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4907                 return CAMERA_ERROR_INVALID_PARAMETER;
4908         }
4909         sock_fd = pc->cb_info->fd;
4910         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = foreach_cb;
4911         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_ISO] = user_data;
4912
4913         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4914         LOGD("ret : 0x%x", ret);
4915         return ret;
4916 }
4917
4918
4919 int camera_attr_foreach_supported_whitebalance(camera_h camera, camera_attr_supported_whitebalance_cb foreach_cb , void *user_data)
4920 {
4921         if (camera == NULL || foreach_cb == NULL) {
4922                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4923                 return CAMERA_ERROR_INVALID_PARAMETER;
4924         }
4925         int ret = CAMERA_ERROR_NONE;
4926
4927         camera_cli_s *pc = (camera_cli_s *)camera;
4928         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_WHITEBALANCE;
4929
4930         LOGD("Enter, handle :%x", pc->remote_handle);
4931
4932         int sock_fd;
4933         if (pc->cb_info == NULL) {
4934                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4935                 return CAMERA_ERROR_INVALID_PARAMETER;
4936         }
4937         sock_fd = pc->cb_info->fd;
4938         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = foreach_cb;
4939         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_WHITEBALANCE] = user_data;
4940
4941         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4942         LOGD("ret : 0x%x", ret);
4943         return ret;
4944 }
4945
4946
4947 int camera_attr_foreach_supported_effect(camera_h camera, camera_attr_supported_effect_cb foreach_cb , void *user_data)
4948 {
4949         if (camera == NULL || foreach_cb == NULL) {
4950                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4951                 return CAMERA_ERROR_INVALID_PARAMETER;
4952         }
4953         int ret = CAMERA_ERROR_NONE;
4954
4955         camera_cli_s *pc = (camera_cli_s *)camera;
4956         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_EFFECT;
4957
4958         LOGD("Enter, handle :%x", pc->remote_handle);
4959
4960         int sock_fd;
4961         if (pc->cb_info == NULL) {
4962                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4963                 return CAMERA_ERROR_INVALID_PARAMETER;
4964         }
4965         sock_fd = pc->cb_info->fd;
4966         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = foreach_cb;
4967         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_EFFECT] = user_data;
4968
4969         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4970         LOGD("ret : 0x%x", ret);
4971         return ret;
4972 }
4973
4974
4975 int camera_attr_foreach_supported_scene_mode(camera_h camera, camera_attr_supported_scene_mode_cb foreach_cb , void *user_data)
4976 {
4977         if (camera == NULL || foreach_cb == NULL) {
4978                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4979                 return CAMERA_ERROR_INVALID_PARAMETER;
4980         }
4981         int ret = CAMERA_ERROR_NONE;
4982
4983         camera_cli_s *pc = (camera_cli_s *)camera;
4984         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_SCENE_MODE;
4985
4986         LOGD("Enter, handle :%x", pc->remote_handle);
4987
4988         int sock_fd;
4989         if (pc->cb_info == NULL) {
4990                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
4991                 return CAMERA_ERROR_INVALID_PARAMETER;
4992         }
4993         sock_fd = pc->cb_info->fd;
4994         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = foreach_cb;
4995         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_SCENE_MODE] = user_data;
4996
4997         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
4998         LOGD("ret : 0x%x", ret);
4999         return ret;
5000 }
5001
5002
5003 int camera_attr_foreach_supported_flash_mode(camera_h camera, camera_attr_supported_flash_mode_cb foreach_cb , void *user_data)
5004 {
5005         if (camera == NULL || foreach_cb == NULL) {
5006                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5007                 return CAMERA_ERROR_INVALID_PARAMETER;
5008         }
5009         int ret = CAMERA_ERROR_NONE;
5010
5011         camera_cli_s *pc = (camera_cli_s *)camera;
5012         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FLASH_MODE;
5013
5014         LOGD("Enter, handle :%x", pc->remote_handle);
5015
5016         int sock_fd;
5017         if (pc->cb_info == NULL) {
5018                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5019                 return CAMERA_ERROR_INVALID_PARAMETER;
5020         }
5021         sock_fd = pc->cb_info->fd;
5022         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = foreach_cb;
5023         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FLASH_MODE] = user_data;
5024
5025         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5026         LOGD("ret : 0x%x", ret);
5027         return ret;
5028 }
5029
5030
5031 int camera_attr_foreach_supported_fps(camera_h camera, camera_attr_supported_fps_cb foreach_cb , void *user_data)
5032 {
5033         if (camera == NULL || foreach_cb == NULL) {
5034                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5035                 return CAMERA_ERROR_INVALID_PARAMETER;
5036         }
5037         int ret = CAMERA_ERROR_NONE;
5038
5039         camera_cli_s *pc = (camera_cli_s *)camera;
5040         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS;
5041         int sock_fd;
5042         if (pc->cb_info == NULL) {
5043                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5044                 return CAMERA_ERROR_INVALID_PARAMETER;
5045         }
5046         sock_fd = pc->cb_info->fd;
5047         LOGD("Enter, handle :%x", pc->remote_handle);
5048         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = foreach_cb;
5049         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS] = user_data;
5050
5051         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5052         LOGD("Enter, handle :%x", pc->remote_handle);
5053         return ret;
5054 }
5055
5056 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)
5057 {
5058         if (camera == NULL || foreach_cb == NULL) {
5059                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5060                 return CAMERA_ERROR_INVALID_PARAMETER;
5061         }
5062         int ret = CAMERA_ERROR_NONE;
5063
5064         camera_cli_s *pc = (camera_cli_s *)camera;
5065         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_FPS_BY_RESOLUTION;
5066         int sock_fd;
5067         if (pc->cb_info == NULL) {
5068                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5069                 return CAMERA_ERROR_INVALID_PARAMETER;
5070         }
5071         sock_fd = pc->cb_info->fd;
5072         LOGD("Enter, handle :%x", pc->remote_handle);
5073         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = foreach_cb;
5074         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_FPS_BY_RESOLUTION] = user_data;
5075
5076         muse_camera_msg_send2(api, sock_fd, pc->cb_info, ret, INT, width, INT, height);
5077         LOGD("ret : 0x%x", ret);
5078         return ret;
5079 }
5080
5081 int camera_attr_foreach_supported_stream_flip(camera_h camera, camera_attr_supported_stream_flip_cb foreach_cb, void *user_data)
5082 {
5083         if (camera == NULL || foreach_cb == NULL) {
5084                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5085                 return CAMERA_ERROR_INVALID_PARAMETER;
5086         }
5087         int ret = CAMERA_ERROR_NONE;
5088
5089         camera_cli_s *pc = (camera_cli_s *)camera;
5090         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_FLIP;
5091         int sock_fd;
5092         if (pc->cb_info == NULL) {
5093                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5094                 return CAMERA_ERROR_INVALID_PARAMETER;
5095         }
5096         sock_fd = pc->cb_info->fd;
5097         LOGD("Enter, handle :%x", pc->remote_handle);
5098         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = foreach_cb;
5099         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_FLIP] = user_data;
5100
5101         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5102         LOGD("ret : 0x%x", ret);
5103         return ret;
5104 }
5105
5106
5107 int camera_attr_foreach_supported_stream_rotation(camera_h camera, camera_attr_supported_stream_rotation_cb foreach_cb, void *user_data)
5108 {
5109         if (camera == NULL || foreach_cb == NULL) {
5110                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5111                 return CAMERA_ERROR_INVALID_PARAMETER;
5112         }
5113         int ret = CAMERA_ERROR_NONE;
5114
5115         camera_cli_s *pc = (camera_cli_s *)camera;
5116         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_FOREACH_SUPPORTED_STREAM_ROTATION;
5117         int sock_fd;
5118         if (pc->cb_info == NULL) {
5119                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5120                 return CAMERA_ERROR_INVALID_PARAMETER;
5121         }
5122         sock_fd = pc->cb_info->fd;
5123         LOGD("Enter, handle :%x", pc->remote_handle);
5124         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = foreach_cb;
5125         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_FOREACH_SUPPORTED_STREAM_ROTATION] = user_data;
5126
5127         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5128         LOGD("ret : 0x%x", ret);
5129         return ret;
5130 }
5131
5132
5133 int camera_attr_set_stream_rotation(camera_h camera , camera_rotation_e rotation)
5134 {
5135         if (camera == NULL) {
5136                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5137                 return CAMERA_ERROR_INVALID_PARAMETER;
5138         }
5139
5140         int ret = CAMERA_ERROR_NONE;
5141         camera_cli_s *pc = (camera_cli_s *)camera;
5142         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_ROTATION;
5143         int sock_fd;
5144         if (pc->cb_info == NULL) {
5145                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5146                 return CAMERA_ERROR_INVALID_PARAMETER;
5147         }
5148         sock_fd = pc->cb_info->fd;
5149         int set_rotation = (int)rotation;
5150
5151         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5152         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_rotation);
5153         LOGD("ret : 0x%x", ret);
5154         return ret;
5155 }
5156
5157
5158 int camera_attr_get_stream_rotation(camera_h camera , camera_rotation_e *rotation)
5159 {
5160         if (camera == NULL || rotation == NULL) {
5161                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5162                 return CAMERA_ERROR_INVALID_PARAMETER;
5163         }
5164
5165         int ret = CAMERA_ERROR_NONE;
5166         camera_cli_s *pc = (camera_cli_s *)camera;
5167         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_ROTATION;
5168         int sock_fd;
5169         if (pc->cb_info == NULL) {
5170                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5171                 return CAMERA_ERROR_INVALID_PARAMETER;
5172         }
5173         sock_fd = pc->cb_info->fd;
5174         int get_rotation;
5175
5176         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5177         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5178
5179         if (ret == CAMERA_ERROR_NONE) {
5180                 muse_camera_msg_get(get_rotation, pc->cb_info->recv_msg);
5181                 *rotation = (camera_rotation_e)get_rotation;
5182         }
5183         LOGD("ret : 0x%x", ret);
5184         return ret;
5185 }
5186
5187
5188 int camera_attr_set_stream_flip(camera_h camera , camera_flip_e flip)
5189 {
5190         if (camera == NULL) {
5191                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5192                 return CAMERA_ERROR_INVALID_PARAMETER;
5193         }
5194
5195         int ret = CAMERA_ERROR_NONE;
5196         camera_cli_s *pc = (camera_cli_s *)camera;
5197         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_STREAM_FLIP;
5198         int sock_fd;
5199         if (pc->cb_info == NULL) {
5200                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5201                 return CAMERA_ERROR_INVALID_PARAMETER;
5202         }
5203         sock_fd = pc->cb_info->fd;
5204         int set_flip = (int)flip;
5205
5206         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5207         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_flip);
5208         LOGD("ret : 0x%x", ret);
5209         return ret;
5210 }
5211
5212
5213 int camera_attr_get_stream_flip(camera_h camera , camera_flip_e *flip)
5214 {
5215         if (camera == NULL || flip == NULL) {
5216                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5217                 return CAMERA_ERROR_INVALID_PARAMETER;
5218         }
5219
5220         int ret = CAMERA_ERROR_NONE;
5221         camera_cli_s *pc = (camera_cli_s *)camera;
5222         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_STREAM_FLIP;
5223         int sock_fd;
5224         if (pc->cb_info == NULL) {
5225                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5226                 return CAMERA_ERROR_INVALID_PARAMETER;
5227         }
5228         sock_fd = pc->cb_info->fd;
5229         int get_flip;
5230
5231         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5232         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5233
5234         if (ret == CAMERA_ERROR_NONE) {
5235                 muse_camera_msg_get(get_flip, pc->cb_info->recv_msg);
5236                 *flip = (camera_flip_e)get_flip;
5237         }
5238         LOGD("ret : 0x%x", ret);
5239         return ret;
5240 }
5241
5242 int camera_attr_set_hdr_mode(camera_h camera, camera_attr_hdr_mode_e mode)
5243 {
5244         if (camera == NULL) {
5245                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5246                 return CAMERA_ERROR_INVALID_PARAMETER;
5247         }
5248
5249         int ret = CAMERA_ERROR_NONE;
5250         camera_cli_s *pc = (camera_cli_s *)camera;
5251         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_MODE;
5252         int sock_fd;
5253         if (pc->cb_info == NULL) {
5254                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5255                 return CAMERA_ERROR_INVALID_PARAMETER;
5256         }
5257         sock_fd = pc->cb_info->fd;
5258         int set_mode = (int)mode;
5259
5260         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5261         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_mode);
5262         LOGD("ret : 0x%x", ret);
5263         return ret;
5264 }
5265
5266
5267 int camera_attr_get_hdr_mode(camera_h camera, camera_attr_hdr_mode_e *mode)
5268 {
5269         if (camera == NULL) {
5270                 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
5271                 return CAMERA_ERROR_INVALID_PARAMETER;
5272         }
5273         if (mode == NULL) {
5274                 LOGE("CAMERA_ERROR_NOT_SUPPORTED(0x%08x) - mode", CAMERA_ERROR_NOT_SUPPORTED);
5275                 return CAMERA_ERROR_NOT_SUPPORTED;
5276         }
5277         int ret = CAMERA_ERROR_NONE;
5278         camera_cli_s *pc = (camera_cli_s *)camera;
5279         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_GET_HDR_MODE;
5280         int sock_fd;
5281         if (pc->cb_info == NULL) {
5282                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5283                 return CAMERA_ERROR_INVALID_PARAMETER;
5284         }
5285         sock_fd = pc->cb_info->fd;
5286         int get_mode;
5287
5288         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5289         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5290
5291         if (ret == CAMERA_ERROR_NONE) {
5292                 muse_camera_msg_get(get_mode, pc->cb_info->recv_msg);
5293                 *mode = (camera_attr_hdr_mode_e)get_mode;
5294         }
5295         LOGD("ret : 0x%x", ret);
5296         return ret;
5297 }
5298
5299
5300 bool camera_attr_is_supported_hdr_capture(camera_h camera)
5301 {
5302         if (camera == NULL) {
5303                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5304                 return false;
5305         }
5306
5307         int ret = CAMERA_ERROR_NONE;
5308         camera_cli_s *pc = (camera_cli_s *)camera;
5309         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_HDR_CAPTURE;
5310         int sock_fd;
5311         if (pc->cb_info == NULL) {
5312                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5313                 return CAMERA_ERROR_INVALID_PARAMETER;
5314         }
5315         sock_fd = pc->cb_info->fd;
5316         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5317         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5318         LOGD("ret : 0x%x", ret);
5319         return (bool)ret;
5320 }
5321
5322
5323 int camera_attr_set_hdr_capture_progress_cb(camera_h camera, camera_attr_hdr_progress_cb callback, void *user_data)
5324 {
5325         if (camera == NULL) {
5326                 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
5327                 return CAMERA_ERROR_INVALID_PARAMETER;
5328         }
5329         if (callback == NULL) {
5330                 LOGE("CAMERA_ERROR_NOT_SUPPORTED(0x%08x) - callback", CAMERA_ERROR_NOT_SUPPORTED);
5331                 return CAMERA_ERROR_NOT_SUPPORTED;
5332         }
5333         int ret = CAMERA_ERROR_NONE;
5334
5335         camera_cli_s *pc = (camera_cli_s *)camera;
5336         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_SET_HDR_CAPTURE_PROGRESS_CB;
5337         int sock_fd;
5338         if (pc->cb_info == NULL) {
5339                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5340                 return CAMERA_ERROR_INVALID_PARAMETER;
5341         }
5342         sock_fd = pc->cb_info->fd;
5343         LOGD("Enter, handle :%x", pc->remote_handle);
5344
5345         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = callback;
5346         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = user_data;
5347
5348         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5349         LOGD("ret : 0x%x", ret);
5350         return ret;
5351 }
5352
5353
5354 int camera_attr_unset_hdr_capture_progress_cb(camera_h camera)
5355 {
5356         if (camera == NULL) {
5357                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5358                 return CAMERA_ERROR_INVALID_PARAMETER;
5359         }
5360
5361         int ret = CAMERA_ERROR_NONE;
5362
5363         camera_cli_s *pc = (camera_cli_s *)camera;
5364         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_UNSET_HDR_CAPTURE_PROGRESS_CB;
5365         int sock_fd;
5366         if (pc->cb_info == NULL) {
5367                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5368                 return CAMERA_ERROR_INVALID_PARAMETER;
5369         }
5370         sock_fd = pc->cb_info->fd;
5371         LOGD("Enter, handle :%x", pc->remote_handle);
5372
5373         pc->cb_info->user_cb[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)NULL;
5374         pc->cb_info->user_data[MUSE_CAMERA_EVENT_TYPE_HDR_PROGRESS] = (void *)NULL;
5375
5376         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5377         LOGD("ret : 0x%x", ret);
5378         return ret;
5379 }
5380
5381
5382 int camera_attr_enable_anti_shake(camera_h camera, bool enable)
5383 {
5384         if (camera == NULL) {
5385                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5386                 return CAMERA_ERROR_INVALID_PARAMETER;
5387         }
5388
5389         int ret = CAMERA_ERROR_NONE;
5390         camera_cli_s *pc = (camera_cli_s *)camera;
5391         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_ANTI_SHAKE;
5392         int sock_fd;
5393         if (pc->cb_info == NULL) {
5394                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5395                 return CAMERA_ERROR_INVALID_PARAMETER;
5396         }
5397         sock_fd = pc->cb_info->fd;
5398         int set_enable = (int)enable;
5399
5400         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5401         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable);
5402         LOGD("ret : 0x%x", ret);
5403         return ret;
5404 }
5405
5406
5407 int camera_attr_is_enabled_anti_shake(camera_h camera , bool *enabled)
5408 {
5409         if (camera == NULL) {
5410                 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
5411                 return CAMERA_ERROR_INVALID_PARAMETER;
5412         }
5413         if (enabled == NULL) {
5414                 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
5415                 return CAMERA_ERROR_NOT_SUPPORTED;
5416         }
5417         int ret = CAMERA_ERROR_NONE;
5418         camera_cli_s *pc = (camera_cli_s *)camera;
5419         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_ANTI_SHAKE;
5420         int sock_fd;
5421         if (pc->cb_info == NULL) {
5422                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5423                 return CAMERA_ERROR_INVALID_PARAMETER;
5424         }
5425         sock_fd = pc->cb_info->fd;
5426         int get_enabled;
5427
5428         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5429         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5430
5431         if (ret == CAMERA_ERROR_NONE) {
5432                 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
5433                 *enabled = (bool)get_enabled;
5434         }
5435         LOGD("ret : 0x%x", ret);
5436         return ret;
5437 }
5438
5439
5440 bool camera_attr_is_supported_anti_shake(camera_h camera)
5441 {
5442
5443         if (camera == NULL) {
5444                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5445                 return false;
5446         }
5447
5448         int ret = CAMERA_ERROR_NONE;
5449         camera_cli_s *pc = (camera_cli_s *)camera;
5450         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_ANTI_SHAKE;
5451         int sock_fd;
5452         if (pc->cb_info == NULL) {
5453                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5454                 return CAMERA_ERROR_INVALID_PARAMETER;
5455         }
5456         sock_fd = pc->cb_info->fd;
5457         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5458         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5459         LOGD("ret : 0x%x", ret);
5460         return ret;
5461 }
5462
5463
5464 int camera_attr_enable_video_stabilization(camera_h camera, bool enable)
5465 {
5466         if (camera == NULL) {
5467                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5468                 return CAMERA_ERROR_INVALID_PARAMETER;
5469         }
5470
5471         int ret = CAMERA_ERROR_NONE;
5472         camera_cli_s *pc = (camera_cli_s *)camera;
5473         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_VIDEO_STABILIZATION;
5474         int sock_fd;
5475         if (pc->cb_info == NULL) {
5476                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5477                 return CAMERA_ERROR_INVALID_PARAMETER;
5478         }
5479         sock_fd = pc->cb_info->fd;
5480         int set_enable = (int)enable;
5481
5482         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5483         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable);
5484         LOGD("ret : 0x%x", ret);
5485         return ret;
5486 }
5487
5488
5489 int camera_attr_is_enabled_video_stabilization(camera_h camera, bool *enabled)
5490 {
5491         if (camera == NULL) {
5492                 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
5493                 return CAMERA_ERROR_INVALID_PARAMETER;
5494         }
5495         if (enabled == NULL) {
5496                 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
5497                 return CAMERA_ERROR_NOT_SUPPORTED;
5498         }
5499         int ret = CAMERA_ERROR_NONE;
5500         camera_cli_s *pc = (camera_cli_s *)camera;
5501         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_VIDEO_STABILIZATION;
5502         int sock_fd;
5503         if (pc->cb_info == NULL) {
5504                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5505                 return CAMERA_ERROR_INVALID_PARAMETER;
5506         }
5507         sock_fd = pc->cb_info->fd;
5508         int get_enabled;
5509
5510         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5511         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5512
5513         if (ret == CAMERA_ERROR_NONE) {
5514                 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
5515                 *enabled = (bool)get_enabled;
5516         }
5517         LOGD("ret : 0x%x", ret);
5518         return ret;
5519 }
5520
5521
5522 bool camera_attr_is_supported_video_stabilization(camera_h camera)
5523 {
5524         if (camera == NULL) {
5525                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5526                 return false;
5527         }
5528
5529         int ret = CAMERA_ERROR_NONE;
5530         camera_cli_s *pc = (camera_cli_s *)camera;
5531         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_VIDEO_STABILIZATION;
5532         int sock_fd;
5533         if (pc->cb_info == NULL) {
5534                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5535                 return CAMERA_ERROR_INVALID_PARAMETER;
5536         }
5537         sock_fd = pc->cb_info->fd;
5538         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5539         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5540         LOGD("ret : 0x%x", ret);
5541         return ret;
5542 }
5543
5544
5545 int camera_attr_enable_auto_contrast(camera_h camera, bool enable)
5546 {
5547         if (camera == NULL) {
5548                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5549                 return CAMERA_ERROR_INVALID_PARAMETER;
5550         }
5551
5552         int ret = CAMERA_ERROR_NONE;
5553         camera_cli_s *pc = (camera_cli_s *)camera;
5554         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_ENABLE_AUTO_CONTRAST;
5555         int sock_fd;
5556         if (pc->cb_info == NULL) {
5557                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5558                 return CAMERA_ERROR_INVALID_PARAMETER;
5559         }
5560         sock_fd = pc->cb_info->fd;
5561         int set_enable = (int)enable;
5562
5563         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5564         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_enable);
5565         LOGD("ret : 0x%x", ret);
5566         return ret;
5567 }
5568
5569
5570 int camera_attr_is_enabled_auto_contrast(camera_h camera, bool *enabled)
5571 {
5572         if (camera == NULL) {
5573                 LOGE("INVALID_PARAMETER(0x%08x) - handle", CAMERA_ERROR_INVALID_PARAMETER);
5574                 return CAMERA_ERROR_INVALID_PARAMETER;
5575         }
5576         if (enabled == NULL) {
5577                 LOGE("INVALID_PARAMETER(0x%08x) - enabled", CAMERA_ERROR_INVALID_PARAMETER);
5578                 return CAMERA_ERROR_INVALID_PARAMETER;
5579         }
5580         int ret = CAMERA_ERROR_NONE;
5581         camera_cli_s *pc = (camera_cli_s *)camera;
5582         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_ENABLED_AUTO_CONTRAST;
5583         int sock_fd;
5584         if (pc->cb_info == NULL) {
5585                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5586                 return CAMERA_ERROR_INVALID_PARAMETER;
5587         }
5588         sock_fd = pc->cb_info->fd;
5589         int get_enabled;
5590
5591         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5592         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5593
5594         if (ret == CAMERA_ERROR_NONE) {
5595                 muse_camera_msg_get(get_enabled, pc->cb_info->recv_msg);
5596                 *enabled = (bool)get_enabled;
5597         }
5598         LOGD("ret : 0x%x", ret);
5599         return ret;
5600 }
5601
5602
5603 bool camera_attr_is_supported_auto_contrast(camera_h camera)
5604 {
5605         if (camera == NULL) {
5606                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5607                 return false;
5608         }
5609
5610         int ret = CAMERA_ERROR_NONE;
5611         camera_cli_s *pc = (camera_cli_s *)camera;
5612         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_IS_SUPPORTED_AUTO_CONTRAST;
5613         int sock_fd;
5614         if (pc->cb_info == NULL) {
5615                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5616                 return CAMERA_ERROR_INVALID_PARAMETER;
5617         }
5618         sock_fd = pc->cb_info->fd;
5619         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5620         muse_camera_msg_send(api, sock_fd, pc->cb_info, ret);
5621         LOGD("ret : 0x%x", ret);
5622         return ret;
5623 }
5624
5625
5626 int camera_attr_disable_shutter_sound(camera_h camera, bool disable)
5627 {
5628         if (camera == NULL) {
5629                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5630                 return CAMERA_ERROR_INVALID_PARAMETER;
5631         }
5632
5633         int ret = CAMERA_ERROR_NONE;
5634         camera_cli_s *pc = (camera_cli_s *)camera;
5635         muse_camera_api_e api = MUSE_CAMERA_API_ATTR_DISABLE_SHUTTER_SOUND;
5636         int sock_fd;
5637         if (pc->cb_info == NULL) {
5638                 LOGE("INVALID_PARAMETER(0x%08x)", CAMERA_ERROR_INVALID_PARAMETER);
5639                 return CAMERA_ERROR_INVALID_PARAMETER;
5640         }
5641         sock_fd = pc->cb_info->fd;
5642         int set_disable = (int)disable;
5643
5644         LOGD("Enter, remote_handle : %x", pc->remote_handle);
5645         muse_camera_msg_send1(api, sock_fd, pc->cb_info, ret, INT, set_disable);
5646         LOGD("ret : 0x%x", ret);
5647         return ret;
5648 }