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