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