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