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